Sly 2:Game state

From SlyMods
(Redirected from DAG)
Jump to navigation Jump to search
Game state
Game Mechanic
The official DAG for Sly 2 Episode 2
GameSly 2: Band of Thieves

The game state is the current state of everything in the game world. It was the subject of a 2005 GDC presentation by Bruce Oberg, the Principal Engineer at Sucker Punch.[1]


The current game state is represented by a directed acyclic graph (DAG), which is a directed graph with no cycles. Each node on the DAG is called a task. For example, t1_follow_dmitri_on_streets is the task of tailing Dimitri in the "Follow Dimitri" job (the prefix t1 indicates that it is a task in Episode 1, and follow is the codename for the "Follow Dimitri" job).

Task States

Each task has a state value which can be one of the following:

  • 0 – Unavailable
  • 1 – Available
  • 2 – Complete
  • 3 – Final

All tasks begin as Unavailable. A task becomes Available once all of its predecessors are Complete. Tasks become Complete through conditions being met in the level scripts, and tasks become Final through completing missions.

State Forcing

At all times, every task before an Available task must be Complete or Final. Additionally, every task after an Available task must be unavailable. It is possible to "force" a task to a particular state, which propagates throughout the DAG to ensure those conditions are always met.


Tasks are grouped into missions, where each mission is typically a particular job in the story. For instance, m1_follow[check] is the job "Follow Dmitri". The prefix m1 indicates that it is a mission in Episode 1, and follow is the codename for the mission.

When the task marked as the "exit task" for a mission is Completed, then all the tasks in that mission become Final.


Some tasks are "checkpoint tasks". A task is a checkpoint if it has some associated checkpoint data, which includes

  • the character to respawn as
  • a location to spawn at

When a checkpoint task becomes Available, that checkpoint is set as the latest checkpoint.


A rollback is when the game state rewinds to an earlier state (such as when the player dies). This is accomplished by:

  • Resetting the world
  • Placing the player at the latest checkpoint
  • Forcing the checkpoint task to Available (which may result in the states of other tasks being updated)


The following are all DAGs for Sly 2. The DAG for Episode 2 is the official DAG as the developers would have seen it. The rest are reconstructed from data structures in the game's memory.

See also

  • DAGviz - A tool for viewing and editing the DAG in real time
  • Sly 1:GS - The game state struct in Sly Cooper and the Thievius Raccoonus.


  1. The Picture Worth a Thousand Bugs - YouTube, 3 April 2021 (archived from a 2005 GDC conference)