I'm trying to wrap my mind around property-based testing and chess. Currently I represent my chess game as a 2d-array and the only pieces I have implemented are pawns and knights for grokking this.
The pawn and knight represent their moves as the set of allMoves(x,y) \ invalidMoves(board,x,y)
. So one property I can think of is to test that allMoves(x,y) ∪ invalidMoves(board,x,y) === allMoves
. But beyond that I'm not sure what else to test. I assume that I need to set up a simplified oracle model for the chess board but I'm not sure what such a model would be.
Start by just saying some obvious things that are true about real-life chess boards, no matter how dumb they sound. Many of those will be reasonable properties to test. Here are some ideas:
Many more ideas like this exist. They seem simple, but I guarantee your early implementations will miss some of them. Figure out how to write these invariants as properties, and grow your test suite from there.