This documentation refers to the Adversarial Search problem.
Your script for the algorithm must evaluate to a function satisfying the following criteria:
Your script for the case must evaluate to a function satisfying the following criteria:
Here, you can do any setup you need to execute before any position is initialized.
Given the root position, this function should grow the game tree by expanding positions using the expand function.
This function is meant to be yielded by your implementation of runExpansion generator.
It will populate the given position's moves field.
This function is meant to be yielded by your implementation of runAlgorithm generator.
The constructor of the game. Note that you will have to return an instance of a game on your case script.
You must implement this function, which will be run on initialization. It will return the initial position of the game.
Here is where you will implement legal move search for your game. If you prefer to do that in your position, simply return the result of calling your position's getActions method.
Here is where you will implement position generation for your game. Given a position and an action taken from that position, return the resulting position. You can assume that the action was taken from calling getActions with the source position as the argument.
This is a subset of moves considered optimal for the current position. This should be populated by your algorithm.
This is your calculated utility for the position. It should range from -1 to 1 and should be populated by your algorithm.
The renderer will use this value to render the border color of nodes.
It will also be rendered as a fixed property in the Position inspector.
This is an object you can use to store serializable data.
It will be shown as a fixed property in the Position inspector
This will allow you to fine-tune the look of nodes in the tree display.
This serves as the initialization for your position. You should call super() at the start of your code to initialize some of the internal properties indicated above.
This can be used in your render function to use the CanvasHelper API.
This function must be implemented and must return a unique string for the given position.
This function must be implemented. It provides a rendering context with which to graphically draw the position onto the canvas.
This function must be implemented and must return true for all terminal position and false for positions where actions can still be taken.
This function must be implemented and must return a value from -1 to 1 for terminal positions. For non-terminal positions, it can return anything.
The closer the value is to 1, the more positive it is for the first player. The closer it is to -1, the better it is for the second player.
This function must be implemented and must return -1, 0, or 1.
1 indicates that the first player is to play, -1 indicates the second player, and 0 indicates a random action turn for non-deterministic games.
This serves as an identifier for the action. It must be unique among all actions that can be taken in any single position.
This property can be assigned to display a different label on action edges than the action name.
This contains the action that goes from the source position containing this move to the target position.
This is the target position reached when this move's action is taken from the source position.