-
Notifications
You must be signed in to change notification settings - Fork 10
Baba Simulation Code
M Charity edited this page Apr 1, 2022
·
10 revisions
The Baba is You simulator code is defined in simulation.js. This is the same simulation code that runs the game for the Baba is Y'all website.
These properties make up the state object for the Baba is You simulation map. They can be accessed from any state
| Name | Type | Description |
|---|---|---|
| orig_map | (2d array) | Has the ascii form of the initially passed map of the state |
| obj_map | (2d array) | Ascii characters of all interactable sprites on the map |
| back_map | (2d array) | Ascii characters of all NON-interactable sprites on the map |
| words | (array of objects [x,y]) | Word-based sprite objects (i.e. KEKE, IS, WIN) with X,Y coordinates |
| phys | (array of objects [x,y]) | Object-based sprite objects with X,Y coordinates that can be interacted with |
| is_connectors | (array of objects [x,y]) | 'IS' keyword objects with X,Y coordinates |
| sort_phys | (dict of array of objects [x,y]) | Objects with X,Y coordinates grouped by name (i.e. all 'BABA' objects) |
| players | (array of objects [x,y]) | All objects with the 'IS-YOU' rule attributed on the map |
| auto_movers | (array of objects [x,y]) | All objects with the 'IS-MOVE' rule attributed on the map |
| winnables | (array of objects [x,y]) | All objects with the 'IS-WIN' rule attributed on the map |
| pushables | (array of objects [x,y]) | All objects with the 'IS-PUSH' rule attributed on the map |
| killers | (array of objects [x,y]) | All objects with the 'IS-KILL' rule attributed on the map |
| sinkers | (array of objects [x,y]) | All objects with the 'IS-SINK' rule attributed on the map |
| featured | (array of objects [x,y]) | All objects with the 'IS-HOT' or 'IS-MELT' rule attributed on the map |
| overlaps | (array of objects [x,y]) | All objects capable of being overlapped by another object on the map |
| unoverlaps | (array of objects [x,y]) | All objects that CANNOT be overlapped by another object on the map |
The following helper functions can be accessed by the agents via this NodeJS module.
| Name | Inputs | Outputs | Description |
|---|---|---|---|
| setupLevel | ascii_map (str) | - | Sets up the initial global game state based on the ascii map of the level passed |
| getGamestate | - | state (object) | Returns the global game state |
| clearLevel | state (object) | - | Resets all the values in a game state |
| setState | state (object) ascii_map (str) |
- | resets a state to a given ascii map |
| newState | ascii_map (str) | state (obj) | returns a new state object based on a given ascii map |
| showState | state (object) | ascii_map (str) | Returns a string format of the state passed |
| Name | Inputs | Outputs | Description |
|---|---|---|---|
| parseMap | ascii_map (str) | 2d character map (2d array) | Turns the string version of the map to a 2d character array |
| map2Str | 2d character map (2d array) | ascii_map (str) | Turns the 2d character array version of the map to a string |
| doubleMap2Str | o map (2d array) b map (2d array) |
ascii_map (str) | Turns the object and background map interactable maps interpreted by the simulator into a combined ascii map |
| splitMap | 2d character map (str) | o map (2d array) b map (2d array) |
Splits the 2d character map into the object (interactable) and background (non-interactable) 2d maps |
| getMapKey | - | map key (dict) | Returns dictionary of map ascii characters to the sprite object name |
| Name | Inputs | Outputs | Description |
|---|---|---|---|
| assignMapObjs | state (obj) | - | Assigns the text characters on the map as objects definitions stored in the state |
| interpretRules | state (obj) | - | Parses any rule changes and updates the objects with the properties defined (ex. 'FLAG-is-KILL' -> all flag objects will become part of the 'killers' set |
| nextMove | action (str) state (object) |
state (object) win (bool) |
Returns the resulting game state and win condition after an action has been taken on the input game state |
| Name | Inputs | Outputs | Description |
|---|---|---|---|
| miniSol | solution (list str) | solution (str) | Returns solution in minimized form (first characters only) as a single string |
| transSol | solution (str) | solution (list str) | Returns string abbreviated solution to full text list of actions |