mardi 6 août 2019

Chess validation moves: the absolute differences approach

This article describes a new approach for validating the moves of chess pieces.

This approach is inspired by what l called the fibochess theory, which apprehends the game of chess by calculating in a different way value pieces taking in account the concepts of mobility and control.

In a later article I will explain what is the Fibochess Theory.

This article is not directly related to the core theory but it proposes another way to define the pieces and the validation of their moves in order to optimize the programming and the choice of the right language.

Definition of the cells:
 First we will define absolute value for the cells. These are constant values.
The first number is the column. The second number is the row. Cell 53: 5th column, 3rd row. 
We can build the whole idea around another array. We can change those values from the point of view of white, by changing 88 to 11 and 11 to 88.

These are the values.

81 71 61 51 41 31 21 11
82 72 62 52 42 32 22 12
83 73 63 53 43 33 23 13
84 74 64 54 44 34 24 14
85 75 65 55 45 35 25 15
86 76 66 56 46 36 26 16
87 77 67 57 47 37 27 17
88 78 68 58 48 38 28 18

Definition of states:
Then we will define four states of the cell: empty, occupied by an opposing piece, occupied by a piece from our camp, impossible. We can assign them a constant value, for example: 0, 1, 2, 3. But as for what follows, it's not really important. We can assign any value.

Definition of the relation to space:
What follows now is particularly original and has very extensive applications in the Fibochess theory.

A piece is defined by the relation it has with the cells board, and in particular with the cell where it can not go, that is to say by the "impossible cells".

Starter and destination
Each piece has a starting cell and multiple destination cells.

Now, return to the previous table and check for each piece the values ​​we found.

1) The King
If the king is on cell 88 (starting cell), he can only move on cells 87, 77, 78, destination cells.
The differences (absolute values) between starting cell and destination cells are: 1, 11, 10.

If you make this calculation on the King's 64 starting cells, the absolute values ​​are only four: 1, 9, 10, 11.
It follows that: if the difference between the start cell and the destination cell is not one of these four numbers, the destination cell is an impossible cell. 

Of course, the cell must be empty or occupied by an opposing piece. Each destination cell may be a pair (a, b) where "a" is the difference in absolute value taking from 1, 9, 10, 11 and "b" = 0 corresponding to an empty cell or b = 1 corresponds to the occupation of an opposing piece. 
(The case of the king is a special case because the King cannot be taken).

2) Bishop
We make the same calculation for the bishop. 
If the difference between the starting cell and the destination cell is not a multiple of 9 or a multiple of 11 it is an impossible cell for a bishop. Possible values ​​are: 9, 18, 27, 36, 45, 54, 63, 11, 22, 33, 44, 55, 66, 77.

3) Rook: If the difference between the starting cell and the destination cell is not a multiple of 10 (up to 70) or a multiple of 1 (up to 7) it is an impossible cell for a Rook. Possible values ​​are: 10, 20, 30, 40, 50, 60, 70, 1, 2, 3, 4, 5, 6, 7.

4) Queen: If the difference between the starting cell and the cell of destination is not one of the following values ​​it is an impossible cell for a queen: 9, 18, 27, 36, 45, 54, 63, 11 , 22, 33, 44, 55, 66, 77, 10, 20, 30, 40, 50, 60, 70, 1, 2, 3, 4, 5, 6, 7.

5) Knight: If the difference between the starting cell and the destination cell is not one of the following values: 8, 12, 19, 21 it is an impossible cell for the knight.

6) Pawn: The values ​​of the differences (between starting cell and destination cells) for the pawn are 1 or 11 so that it is a possible cell for the pawn and if the value (absolute difference) is 2, if the pawns are on their "starter cells". The cells are: 12, 22, 32, 42, 52, 62, 72, 82 (black side) or one of those cells: 17, 27, 37, 47, 57, 67, 77, 87 (white side).

That's it ! 

Next articles: prise en passant, castling, promotion, draw by repeating same position 3 times, pat, draw due to insufficient material, check, mate.