Draft

Pyrga Chess: Find the Cheater!

Description:

Rule of Pyrga Chess :

have you played Pyrga ?
Pyrga need 2 players, The board of Pyrga is a 4x4 matrix, each player have 15 pawns.There are three kinds of pawns: Square, Circle, and Arrow.
Players can put pawns on legal positions, which depends on what kind of pieces the other player placed in the previous round, and where.

Square

If Your opponent put a square in the previous round, you should put your pawn in adjacent cell.

|   | .  |   |
—————————————
| .  | ▢ | .  |
—————————————
|   | .  |   |
Legal locations are marked as points.

Circle

If Your opponent put a circle in the previous round, you should put you pawn on the circle.

|   |   |   |
—————————————
|   | ☉ |   |
—————————————
|   |   |   |

Arrow

If Your opponent put an arrow in the previous round, you should put you pawn in front of it.

|   |   |   |
—————————————
| →  |  .  |  .  |
—————————————
|   |   |   |

A cell cannot be occupied by two pawns whose kind is same at same time, Conversely, a grid can have several kinds at the same time.


Preloaded

Chess

the superclass of Square, Circle, and Arrow.
  • properties:
    Chess.x and Chess.y mark the coordinate of chess. interger, it must equals or greater than 0 ,and smaller than 4 (excluding 4)
  • methods:
    Chess.legalPos(self) returns the legal position where next player should put on. This method is a generator.

Square,Circle,Arrow

They are inherit the Chess class
  • properties:
    Arrow.direction String,it should be 'UP', 'DOWN', 'LEFT', 'RIGHT', and must be capitalized.

Board

  • properties:
    Board.chess, it is a set including the pawns on the board.
  • methods:
    Board.getChess(self,x,y) returns the Chesses on (x,y) this method is a generator. Board.putChess(self,chs) put the pawn on (x,y) this method is useless, but it does exists, so I put it in description.


Your Task

The function will recieve a an object of type "Board", then check whether players have broken the rules =) In other word, every pawn should on it's "prefix pawn's" legalPos, except the first one. For example,
|   |   |   |   |
—————————————————
|   | □ | ↓ |   |
—————————————————
|   |   | ◙ |   |
—————————————————
|   |   |   |   |
This board should return True.
Because there's a path: Square 1,1 ➨ Arrow 2,1 ➨ Circle 2,2 ➨ Square 2,2

Function findTheCheater should return a boolean, if players follow the rules above, return True;Otherwise, return False.

PS: If the board is empty, your function should return True.
PS: In actual case, maybe the number of pawns is not 30.


Invisible Note: I'm a junior high school student in China, if there are some mistakes on grammar in description, please tell me!

Algorithms
Games

More By Author:

Check out these other kata created by Forth-power

Stats:

CreatedMay 8, 2022
Warriors Trained10
Total Skips0
Total Code Submissions58
Total Times Completed5
Python Completions5
Total Stars0
% of votes with a positive feedback rating100% of 1
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes0
Ad
Contributors
  • Forth-power Avatar
Ad