Garth Wallace wrote on Tue, Nov 20, 2018 07:31 AM UTC:
Because of the "inside-out rook" problem, I started trying to define equivalence for pieces in terms of what conditions (relative piece positions) a move can be performed under, until I realized that this was a much better way of defining moves in the first place. the inside-out rook demonstrates that the sequence of steps is entirely irrelevant, only which squares relative to the starting square can it be blocked on and how.
So at this point, I changed my approach. Instead of a path being a sequence of steps, it becomes a destination vector and a set of "tests", where a test is a pair of a vector and a state that must be true of the square that vector away from the starting square for the move to be legal.
A welcome byproduct of defining everything in terms of vectors from the starting square, instead of vectors from the previous step in a sequence, is that "exotic" board topologies become much easier to deal with. The sequence method was fine for hex boards (it's just a different set of basis vectors), but trying to define, say, a bishop on a moebius strip board was weird (try it!). But if all vectors are treated as having the same origin, there's nothing special about it.
Nice, right? Oops, forgot about divergent captures. Okay, instead of just a destination vector, we have a set of results, a set of "things that happen when the move is taken", which can include a destination and/or capture vectors. The Chu Shogi Lion's igui capture can be expressed as a move with a capture vector but no destination vector, since the Lion doesn't move; a null-move like the Lion's jitto is a move where the result set is the empty set ∅. Promotions? Another kind of member of a result set.
There's still a problem with promotion though. We need to know when it's an option. All moves are relative, but pawn promotion happens at a certain absolute position. Let's say that there is a "promotion zone" state for squares, and any pawn step onto a square with that state is a move with a promotion result. En passant can be defined in terms of a capture move to a "just stepped over by a pawn's double move" state. Of course hte problem here is that "state" is very vague. A promotion zone is permanent, but the en passant square only exists for one turn, and there's no way of specifying that sort of thing within this system yet.
Another important thing has been left out: black and white, or more generally sides. At this point I'd been mostly ignoring them and was thinking in terms of just e.g. "knight" rather than "black knight" and "white knight". I was more or less treating captures as explicitly affecting the opposite side. But that's not very flexible (it disallows, say, a hopper that can only use friendly hurdles, or a piece that can capture friendly pieces). Abstracting away the actual human players (who may not even exist, e.g. in a chess problem), what is the distinction between the sides? Alternating turns! Counting from the beginning of a game, white pieces move on odd-numbered plies and black on even-numbered plies (and neutral on all). So we should include, as part of a move's condition (set of tests), which plies it may be performed on, in most cases some number modulo the number of sides. Together with obligate promotion, we can even define oddities like Petkovian half-neutrals, which change sides when moved. Now that we've introduced a time dimension, we can even include that in our test vectors, allowing us to define en passant more concretely in terms of the previous turn's position instead of hand-waving an "en passant square" state.
I'll get into royal status, mimics, what a "state" really is, rethinking captures, and generalizing to almost everything later, but it's getting late and I have work tomorrow.
Because of the "inside-out rook" problem, I started trying to define equivalence for pieces in terms of what conditions (relative piece positions) a move can be performed under, until I realized that this was a much better way of defining moves in the first place. the inside-out rook demonstrates that the sequence of steps is entirely irrelevant, only which squares relative to the starting square can it be blocked on and how.
So at this point, I changed my approach. Instead of a path being a sequence of steps, it becomes a destination vector and a set of "tests", where a test is a pair of a vector and a state that must be true of the square that vector away from the starting square for the move to be legal.
A welcome byproduct of defining everything in terms of vectors from the starting square, instead of vectors from the previous step in a sequence, is that "exotic" board topologies become much easier to deal with. The sequence method was fine for hex boards (it's just a different set of basis vectors), but trying to define, say, a bishop on a moebius strip board was weird (try it!). But if all vectors are treated as having the same origin, there's nothing special about it.
Nice, right? Oops, forgot about divergent captures. Okay, instead of just a destination vector, we have a set of results, a set of "things that happen when the move is taken", which can include a destination and/or capture vectors. The Chu Shogi Lion's igui capture can be expressed as a move with a capture vector but no destination vector, since the Lion doesn't move; a null-move like the Lion's jitto is a move where the result set is the empty set ∅. Promotions? Another kind of member of a result set.
There's still a problem with promotion though. We need to know when it's an option. All moves are relative, but pawn promotion happens at a certain absolute position. Let's say that there is a "promotion zone" state for squares, and any pawn step onto a square with that state is a move with a promotion result. En passant can be defined in terms of a capture move to a "just stepped over by a pawn's double move" state. Of course hte problem here is that "state" is very vague. A promotion zone is permanent, but the en passant square only exists for one turn, and there's no way of specifying that sort of thing within this system yet.
Another important thing has been left out: black and white, or more generally sides. At this point I'd been mostly ignoring them and was thinking in terms of just e.g. "knight" rather than "black knight" and "white knight". I was more or less treating captures as explicitly affecting the opposite side. But that's not very flexible (it disallows, say, a hopper that can only use friendly hurdles, or a piece that can capture friendly pieces). Abstracting away the actual human players (who may not even exist, e.g. in a chess problem), what is the distinction between the sides? Alternating turns! Counting from the beginning of a game, white pieces move on odd-numbered plies and black on even-numbered plies (and neutral on all). So we should include, as part of a move's condition (set of tests), which plies it may be performed on, in most cases some number modulo the number of sides. Together with obligate promotion, we can even define oddities like Petkovian half-neutrals, which change sides when moved. Now that we've introduced a time dimension, we can even include that in our test vectors, allowing us to define en passant more concretely in terms of the previous turn's position instead of hand-waving an "en passant square" state.
I'll get into royal status, mimics, what a "state" really is, rethinking captures, and generalizing to almost everything later, but it's getting late and I have work tomorrow.