···11+- when asked to implement a new feature, you must always follow the same steps:
22+ 1. implement/scaffold the feature to a minimal state where it compiles
33+ 2. write tests for the expected behavour against this scaffold (all will be red)
44+ 3. fix the implementation so that all tests are green
55+ (this is the basic tdd red->green pattern)
66+77+- when asked to fix a bug, always start by trying to replicate it through a target test-case,
88+ then fix the implementation, and finally validate the target-test-case is now green
99+1010+- for writing tests, always try to think about the intended behaviour, not what the implementation is doing
1111+- targetted tests are fine, but always consider first if this could be covered better by a property-test or fuzzer
···11+# go-engine spec
22+33+## rules
44+- japanese rules
55+- simple ko only (TODO: superko, other rulesets)
66+- normal geometry, variable board size at compile time
77+88+## types
99+1010+```
1111+Board<const W: usize, const H: usize>
1212+ - stones: [Option<Color>; W * H]
1313+ - no knowledge of turns, captures, or history
1414+1515+Coord<const W: usize, const H: usize>
1616+ - x, y as u8 (or smaller int if useful)
1717+ - compile-time bounds guarantee
1818+ - TryFrom<(u8, u8)> for runtime input
1919+ - TryFrom<&str> for GTF/SGF notation
2020+2121+Game<const W: usize, const H: usize>
2222+ - board: Board<W, H>
2323+ - to_move: Color
2424+ - captures: (u16, u16) // black, white
2525+ - prev_board: Option<Board<W, H>> // for simple ko
2626+2727+Color: Black | White
2828+```
2929+3030+## errors (thiserror)
3131+- OutOfBounds
3232+- Occupied
3333+- Suicide
3434+- Ko
3535+- NotYourTurn (if checked at Game level)
3636+- InvalidCoordinateFormat
3737+3838+## invariants
3939+- Board checks occupancy and bounds on every stone placement
4040+- Game checks suicide, ko, and turn order on play()
4141+- Board never knows captures; Game tracks them
4242+4343+## scoring
4444+- territory scoring (japanese)
4545+- manual dead stone marking required
4646+- implemented as method on Game only
4747+- TODO: area scoring, automatic life/death
4848+4949+## open questions / TODO
5050+- superko (positional / situational)
5151+- other rulesets (chinese, aga)
5252+- automatic life/death detection
5353+- komi / handicap
5454+- ko fight counting
5555+- time control
5656+- sgf import/export
5757+- gtp protocol