|
another refactoring of chess
|
Tom Ritchford
|
Jun 11, 2001 00:33 PDT
|
yes, the gallery cheers!
it's only 95% finished yet but I have another and even simpler refactoring
and rewriting of the rules of chess and the board structures.
now,
1. com.editev.chess.position is a set of classes that completely
defines a board position in the game of chess and nothing more.
so the position is COMPLETELY disassociated from the sequence of
moves (the move history).
2. there are complete back and forth constructors from the
PositionName construct ( "rnbqk...A5cCdD") to the Board
Position and back.
3. all the rules of chess are encoded in com.editev.chess.rules.
In fact, there is a single Rule that does this,
a single Rule that distinguishes between false and true moves,
with the truly lovely and aesthetic code:
/** Overall rule for legal moves in Chess. */
public static final Rule RULE = new Rule.Compose(
CANT_MOVE_OUTSIDE_BOARD,
CANT_CAPTURE_SELF,
MUST_MOVE_OWN_PIECE,
PieceBetween.RULE,
PIECE_SPECIFIC_RULE,
ResultsInCheck.RULE,
);
I have already written all the specific instances of Rule
mentioned here and they come from proven code... so this
is not fantasy code!
how can you beat that?
the Javadoc will be up in the next few days
once I have the code proven to be correct.
I'm not in a hurry, it might take a week...
/t
that was fast
.......all legal games of chess <http://solveChess.com/chess?refresh=0>......
.....programmer's documentation <http://solveChess.com/doc>..................
|
|
 |
|