Language

GridTurnWorld

A Godot tactical RPG experiment about autonomous companion creatures, coordinated enemies, A* pathfinding, and procedural exploration.

6 min read

GridTurnWorld is a systems experiment for a turn-based tactical RPG. Its premise is familiar: the player explores a grid world alongside small companion creatures while slimes and other enemies react to the party. The project's real goal, however, was never to ship a complete game as quickly as possible. I wanted to learn how much convincing behavior could emerge from simple rules for perception, communication, movement, and combat.

The prototype was inspired by Stoneshard (opens in a new tab) and its turn-based tactical combat, and by Caves of Qud (opens in a new tab), particularly its vision of a world defined by interacting systems. GridTurnWorld does not attempt to reproduce the scope of either game; it uses that lineage of ideas to explore AI, pathfinding, and procedural generation in Godot.

The project has been paused for a long time and should not be presented as a finished game. Its repository is private, and I would like to return to it someday. What exists today is a playable laboratory with a technical foundation I still find interesting.

One world shared by the player, allies, and enemies

Exploration advances in turns. The player can move, attack, pick up an item, or interact with the inventory; the turn manager then signals the NPCs in combat that they may act. The round advances only after every participant has finished. This signal-driven coordination allows creatures to enter and leave combat without maintaining a rigid global entity sequence.

Creatures can be hostile, neutral, or friendly. Slimes search for valid targets within their field of view and attack both the player and the player's companions. The two small allies follow the character, notice nearby threats, and participate in combat without requiring direct commands every turn. That autonomy was essential if they were to feel like companions rather than extra pieces controlled by the player.

Movement and combat in the GridTurnWorld prototype.

AI built around perception and memory

Each NPC makes decisions using local information. It searches for the nearest visible enemy, checks line of sight, and records the target's last known position. If contact is lost, it can continue investigating that location for a while before abandoning the search.

Nearby NPCs also communicate threats. A creature that spots an enemy can alert allies within range; instead of every agent magically knowing the whole map state, information travels through the group. Visual states for alert, search, hostility, and affection expose part of that reasoning to the player.

Companions introduce another problem: following the player without constantly competing for the same cell. Their AI checks occupancy and movement reservations, attempts to remain nearby, and recalculates when another character blocks the route. The result is not a scripted choreography but collective behavior produced by agents following the same spatial rules.

A* written for the game's rules

Godot includes AStarGrid2D, a ready-made A* implementation for grids,1 but I wrote this project's pathfinding in GDScript to control how terrain, entities, and diagonal movement contribute to route cost.

The search keeps open nodes in a priority queue implemented as a minimum heap. For each cell, it combines the accumulated travel cost with a diagonal estimate to the destination. Orthogonal and diagonal steps have different costs, tiles can carry their own weights, and the algorithm prevents a diagonal step from cutting through the corner formed by two obstacles.

The calculation also accounts for occupied cells and positions reserved by other NPCs. This connects pathfinding to group AI: finding the geometrically shortest route is not enough when several creatures are moving during the same turn. A search limit prevents an unreachable destination from consuming work indefinitely.

Visibility uses a Bresenham line implementation to test obstruction between cells. The same spatial model feeds NPC perception and the fog of war revealed by the player.

Debugging A* pathfinding in GridTurnWorld.

A large world without keeping everything active

The map is organized as a logical grid of 170 by 170 biomes, each containing 250 by 250 cells—a potential space of 42,500 cells on each axis. This does not mean billions of tiles are instantiated simultaneously.

The manager maintains a rendered window of 150 by 150 cells around the player. Nearby biomes are generated and loaded as the position changes, while distant regions leave the active layers. Terrain and objects are selected through biome-specific weights, and separate layers represent ground, objects, characters, and fog of war.

This division turns a theoretically enormous map into a local, bounded cost. It is an architectural optimization, not a benchmark claim: the prototype would still need measurement, persistence, and more variety to support a long-running world. Caves of Qud's procedural generation was an important conceptual reference; Jason Grinblat's GDC presentation illustrates how its regions are composed through multiple generation stages and strategies.2

For another way of connecting terrain, resources, and inhabitants' decisions, see Creating worlds: from tectonic plates to conflict. That article follows those relationships into living conditions and conflicts within a fantasy setting.

Companion creatures and biome exploration in GridTurnWorld.

RPG systems around the experiment

Beyond movement and AI, the project already contains:

  • combat rolls for hits, fumbles, criticals, blocks, and dodges;
  • health, stamina, mana, damage, and resistances as a progression foundation;
  • a spatial inventory, equipment, dropped items, and actions that consume turns;
  • camera controls, destination selection, and route previews;
  • early structures for damage, healing, effect, movement, and summoning powers.

Some of these areas are foundations rather than finished systems. Body parts, effects, and powers contain incomplete ideas. Documenting them honestly is more useful than turning an old prototype into an artificial list of production-ready features.

Relationships between choices also appear in Orion Art Engine, where a visual layer can depend on the skin and outfit already selected. It offers another example of combination rules organizing a creative system.

What I would return to

If I resume GridTurnWorld, I would preserve its core: autonomous companion creatures, tactical encounters, and systemic exploration. The next step would be to shape the existing rules into one small complete experience, with enough goals, progression, and content to test whether the emergent behavior remains fun over time.

I would also profile world generation with real measurements, deepen group behaviors, and build debugging tools that expose perception, memory, costs, and AI decisions. The code already demonstrated its most important idea: pathfinding, turns, and communication become much more interesting when treated as parts of the same system.

A note on the visuals: the prototype uses free third-party sprites found online; the pixel art is not my work. Before any public game distribution, the original asset packs and their licenses must be identified and credited. My own pixel-art work deserves a separate Scriptorium article.

Footnotes

  1. The official AStarGrid2D documentation (opens in a new tab) describes Godot's built-in pathfinding solution for partial 2D grids, including heuristics and diagonal movement. ↩

  2. Jason Grinblat, “End-to-End Procedural Generation in Caves of Qud” (opens in a new tab), GDC 2019. ↩

godotgdscriptgame-aipathfindingprocedural-generationtactical-rpg