Open nicholaschuayunzhi opened 5 years ago
Does a piece moving into a piece which stays stationary count as an invalid move?
What about if a piece is moving into a piece which is moving out of that space? Consider
1 | 2 | 3 | 4 |
---|---|---|---|
B left | C left |
Is C invalid?
What if a piece is moving into a piece which is moving into an invalid move, is that considered an invalid move? Consider
1 | 2 | 3 | 4 |
---|---|---|---|
A right | B left | C left |
Is C invalid now?
For the first case C is valid. The fact that we remove all stationary pieces from consideration and mark their squares means we can assume that C will be moving to an empty square.
For second case C left is invalid. The algorithm would have locked a and b in their positions. When we recheck C, we see that C is attempting to enter a locked square. I think i forgot to add that moving to a locked square is invalid. Thanks for checking, will update
So what happens is that the game logic will first figure out all potential movement by pointing to the square that the unit is moving into. In scenario 1:
1 2 3 4 B left C left
The game will list out all the squares a unit will move into as: { 2, 3} As there are no repeated references to a square, all moves are considered valid and executed.
For scenario 2, this is where the game processes the data in steps. So for scenario 2:
1 2 3 4 A right B left C left
The game will list out all the squares a unit will move into as: {2, 2, 3}
As there is a repeated reference, the game detects an invalid move and first consider those units as not moving. Units that do not move will refer to their current square in this system. the game re-checks the board and now the array looks like: {1,3,3}
Now there is another invalid move. the game will once again make the conflicting units not move and re-check.
{1,3,4}
The game has detected no more issues as all references are valid and will now process the initial movement commands as attacks, determining if there is combat or bounces.
Combat check has been updated based on today's discussion. Formula will be updated soon.
Board State Manager
Input
Output
Algorithm
Movement Check:
Invalid Moves:
After this we will have a resolved board state where movement has already been applied and we can infer combat information from the direction each piece is facing.
EDIT: Combat Check: