A Javascript clone of a fun marble placement board game. Play with two players or against an AI.
Each player takes turns placing a marble on an unoccupied, valid space. A valid space is one that...
- is in the same row or column as the last marble your opponent placed
- is NOT on the same tile as the last marble your opponent placed
- is NOT on the same tile as the last marble YOU placed
For convenience, the most recently placed marbles for each player are marked with a white border, and all valid moves are indicated with a blue highlight.
The game ends when either player has no valid moves on their turn OR both players have completely run out of marbles (each player starts with 28 marbles at the beginning of the game).
The score for each player is computed by the number of tiles that the player has "won". The score value for each tile is the number of mable spaces on that tile (i.e. a tile with six spaces is worth six points). A player wins a tile by having the majority of marbles on that tile at the end of the game. Tiles that are tied are worth no points for either player. For example...
- On a six point tile, the red player has 3 marbles and the black player has 2 marbles - the red player earns 6 points and the black player earns 0 points.
- On a six point tile, the red player has 3 marbles and the black player has 3 marbles - both players earn 0 points.
- On a six point tile, the red player has 1 marbles and the black player has no marbles - the red player earns 6 points and the black player earns 0 points.
- On a three point tile, the black player has 2 marbles and the red player has 1 marble - the black player earns 3 points and the red player earns 0 points.
- On a three point tile, the black player has 3 marbles and the red player has no marbles - the black player earns 3 points and the red player earns 0 points.
The player with the most points once scores are tallied is the winner!
You can play against the AI by checking the "Auto move" box for either player. The AI uses a very simple Minimax strategy, prioritizing game states that are not completely lost and using the current score of the board as a heuristic for all other states. The current strategy only searches to a fixed depth of 6 to balance between computation time and difficulty.
There is currently only one static board included in the code. One of the interesting aspects of this game is that the players can generate a new board at the start of the game by taking turns placing tiles one by one, leading to each game being a totally unique strategic challenge. Game boards could also be randomly generated by computer which is probably a fun and interesting challenge for the future.
$ npm install
$ npm run start