Coral and clownfish is a clone of a popular game called Tents and Trees (found on both the Apple app store, and Android play store)
The goal of Coral and Clownfish is to save the reef and determine where the clownfish should be placed.
Each row and column has a specfic number of fish, defined by constraints.
The original game provides a button to provide a suggestion when stuck.
The goal of this competition is to write a suggester to provide a suggestion for what cell to click next. I have written a basic framework to write a suggestion algorithm given a board state, and your goal will be to write a suggester to plug in.
Write a suggester that when plugged in can solve all the provided games. It doesn’t necessarily matter how many moves it requires, but it should be able to solve the game effectively unassisted but pressing “Make suggestion” N times (within reason)
https://github.com/ssirowy/coral-clownfish
At its heart, you are really going to implement one method.
/**
Overridden method of base class. Will return a random cell to click.
@method nextSuggestion
@param {Game} Game object
@return {Cell}
*/
nextSuggestion(game) {
const size = game.board.length - 1;
let row, column = 0;
// Pick a non coral cell
do {
row = this._getRandomInt(1, size);
column = this._getRandomInt(1, size);
} while (game.board[row][column].type == 'coral');
return new CellSuggestion(row, column);
}
For a board for size N, The board is represented as an (N+1)*(N+1) 2D array where the row and column constraints are also represnted as cells.
Constraint cells with be 0-indexed. Clickable board cells are effectively 1-indexed.
// Constraint cell
{
type: 'constraint',
value: 5,
}
// Actual board cell
{
type: 'empty', // might also take on 'clownfish', 'water', or 'coral'
}
This game is built using React and a couple of extra small libraries. The game also uses Redux to maintain state. You won’t really need to know how most of the app is working in order to write a suggester. You can just write basic Javascript to complete the competition part, but feel free to poke around the code and figure out what this game is doing. This is my first React app, so not everything may be up to code (pun intended), but I tried to employ the basic patterns as defined in the docs.
Thats it!
- Clone this repository.
git clone git@github.com:ssirowy/coral-clownfish.git
- Download all dependencies.
cd coral-clownfish
npm install
- Run the game
npm start