3x3 Windows.
- Apply Action
- Get Legal Moves
- Board Get Captured Groups
- Board Get Group At
- Recursive Add Point
- HashSet.Contains: Point.Equals
- Recursive Add Point
- Board Get Group At
- Board Get Captured Groups
- Get Legal Moves
- Pool groups.
- Pool boards.
- Pool games.
-
DISABLE_GROUP_POINTS
hypothesizes next hotspots. - Store in super ko previous board state and move that will be made.
- Query has liberty before suicide.
- Do not calculate captures for legal moves.
- Cache legal moves. Copy when cloning game. Update after making a move.
- When making a move from AI, assume legal.
- Board: clone: group caches.
- Game: black capture advantage.
- When no legal move, cache loss for that player. Do not calc territory or score. if komi, other player keeps playing. captures modifies local komi delta. black wins ties.
- Minimal group data.
- Groups: Preallocate fixed length data.
- Groups: Merge groups.
- Liberties mask per group.
- Static: board size.
- Weight exploratory actions toward center position on the 3x3 or 5x5 board.
- Flyweight board data structure.
- when capturing, update legal moves. when playing reexamine legal moves.
- Super ko: Preallocate fixed length data, circular array of bitmasks.
- When applying action, reuses game instead of cloning game.
- Precompute bitmask of move.
- Bitmask 5x5 board into 25 bits of a 32-bit integer. Masks: Black, White.
- With each move, modify only necessary data.
- Localize memory access.
- Legal moves: modifies board with minimal data copying.
- Legal moves as mask.
- captures as bitmask.
- Index instead of point.
- Bitmask instead of groups.
-
DISABLE_CALC_TERRITORY
- Cache boards.
-
DISABLE_CAPTURES_DICTIONARY
- Pool actions.
- +30%: Cache boards of legal moves for reuse in make move.
- With the above disabled, 5x5 runs 1000 iterations in 200 ms in editor.
- class references array of values.
- profile struct vs class
- seal classes
- Custom HashSet comparison.
- MCTS: Collections without Linq. Get max element. Random choice.
- Thread.
- burst compiler.
- Job System.
- Pool game tree node.
- 700 ms: Cloning 20000 Go State 5x5.
- 500 ms: Cloning Go Game State 5x5.
- 200 ms: Cloning arrays.
- 50 ms: Constructing lists.
- 500 ms: Cloning Go Game State 5x5.
- 400 ms: Apply Action 20000 times.
- 380 ms: Go Game State 5x5 Move
- 100 ms: Try Forbid Suicide At Index
- 40 ms: Would Share Any Liberty
- 20 ms: Would Capture Any
- 100 ms: String concat.
- 70 ms: Convert Move Mask.
- 40 ms: Add Board To History
- 100 ms: Try Forbid Suicide At Index
- 380 ms: Go Game State 5x5 Move
-
On each move, log liberties, occupied.
-
Merge groups after capture. See audit below.
-
Diagnose cause of suicide:
..... .xxxx .oooo oxxo.
-
Correct so that will not play suicide.
-
Displays cells on 3x1.
-
Pool go game state 5x5.
-
Pool go state 5x5.
-
Select move from mask.
-
Bias central move.
White just captured. Expected one group. Got two groups.
Audit:
Board Diagram:
ooo
o..
o..
Illegal Move Masks: 111/100/100, 111/100/100
Turn Index: 0
Player Index 0:
Player Index 1:
Group Liberty Mask: 000/010/010, Group Occupied Mask: 110/100/100
Group Liberty Mask: 000/001/000, Group Occupied Mask: 001/000/000