https://github.com/williamsd4808
We decided to use client-server architecture, writing the gen server in Java, a GUI client written in javascript with Electron, a TCP adapter written in Node.js, and an AI also written in Node.js. Directories of interest in this project are electron-client
, server
, tcp-adapter
, and random-ai
.
The idea is that each client (the Electron client and the AI) makes requests to the server, which maintains the game state. This allows us to easily synchronize state between clients (i.e. it's easy for a human to play against the AI and for AIs to play against each other) and allows us to write clients without knowing the details of the game (i.e. we request a list of valid placements of a certain tile instead of calculating them using the rules of TigerZone).
This project should be runnable on Ubuntu 14.04 with node v6.3.1 and OpenJDK 8. There are no guarantees that any other system will work with other configurations, especially those running on Windows.
To run the Electron client, make sure that you have node installed:
TigerZone$ node -v
v6.3.1
If you get a response saying that node isn't installed, go install it.
Next, install electron-prebuilt globally
TigerZone$ npm install -g electron-prebuilt
You should be able to run the Electron client now without any issues since all dependencies are packaged with it.
Tigerzone$ electron electron-client
Now, you can create, join, and load games from the datastore. Remember to scroll down about halfway to view the game board. The client will update every time the datastore updates and automatically display valid moves. You can place and rotate tiles.
In order to compile the gen server, switch to the server/ApiEndpoints directory and run the build script, i.e.
TigerZone$ cd server/ApiEndpoints
ApiEndpoints$ bash build.sh
ApiEndpoints$ cd ../../
We expose 4 endpoints in order to interact with the gen server. As Java can be a little verbose, we provide bash scripts for each endpoint for your convenience.
TigerZone$ bash server/ApiEndpoints/new-game game_id
TigerZone$ bash server/ApiEndpoints/join-game game_id player_id
TigerZone$ bash server/ApiEndpoints/get-moves game_id
TigerZone$ bash server/ApiEndpoints/place-tile game_id tile_id x y orientation
Watch game allows clients to observe the game, and is written in Node.
TigerZone$ ./server/ApiEndpoints/watch-game game_id
To run the adapter, just run
TigerZone$ node main ip port tournament_password user password
We provide a test server, which runs on 127.0.0.1:9000. To use it, just send the server responses to stdin and it will echo them to the client.
TigerZone$ node tcp-adapter/test-server
To prove that the adapter works, we typically just pipe examples from the protocol to the test server. Timestamps are also included for perf purposes.
TigerZone$ node perf
This will print an example challenge that has been parsed. Any errors will get thrown, so a successful test has none.
TigerZone$ node tcp-adapter/test
We scale up to a 5x5 subgrid in order to solve the problem of jungles being errantly separated from each other by a lake. We also introduce a "hole" subtile that acts as a blocker for the flood fill, allowing us to have us to have 2 jungles and 2 lakes instead of 1 jungle and 2 lakes or 2 jungles and 1 lake in the example below.
We also have to select 9 subtiles to act as our tiger tiles, and we chose those below.