Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Board Validator Test #11

Open
edkim opened this issue May 10, 2014 · 0 comments
Open

Board Validator Test #11

edkim opened this issue May 10, 2014 · 0 comments

Comments

@edkim
Copy link
Contributor

edkim commented May 10, 2014

We would like to know if a game state is valid. A valid game state means that given a 2D array representing game pieces, those pieces could have actually been created by two players following the rules of the game (alternating turns dropping pieces).

Functional Requirements:

  • Create a new POST route /validate
  • The route should accept a 2D array of game pieces just as they the /save API end point does.
  • If the game board is valid, the server should respond 200 OK with message "Board is valid!"
  • If the game board is NOT valid, the server should respond 200 OK with the message "This board is messed up!"

For this issue, a board should be considered valid if:

  1. Each game piece has other game pieces below it (no floating pieces)
  2. Counting each game piece shows that Player 1 has N or N+1 game pieces on the board, where N is the number of game pieces Player 2 has on the board.

Example of a valid game board:

[[null, null, null, null, null, 1 ],
[null, null, null, null, 1, 2 ],
[null, null, null, null, null, 2 ],
[null, null, null, null, 1, 2 ],
[null, null, null, 2, 1, 1 ],
[null, null, null, null, null, null ],
[null, null, null, null, 1, 2 ]]

connect_four

Examples of invalid game board:

[[null,null,null,null,null,1],
[null,null,null,null,null,2],
[null,null,null,2,1,1],
[null,null,2,2,1,2],
[null,null,null,null,null,2],
[null,null,null,null,null,null],
[null,null,null,null,null,null]]

connect_four

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant