Encodable & decodable to pass from client to server and back
Provides rules of the games to the AI to allow it to determine valid, playable moves
HiveMind (Swift)
Given a game state, explores various moves to determine best play
Relies on alpha-beta pruning
Usage
The HiveMind uses a WebSocket for communication. By default, it listens on ws://localhost:8080, but you can change the port by providing an alternative through the command line arguments, described below.
To interact with the HiveMind, you can provide various commands over the WebSocket, which it will reply to in turn. The available commands are:
[new, n] <IsFirst> <ExplorationTime>
Start a new game
IsFirst is a Bool which indicates if the HiveMind will play first.
ExplorationTime is a Double which specifies the maximum amount of time the HiveMind can explore a state.
[move, m] <Movement>
Parse a given HiveEngine.Movement (encoded as JSON) and update the HiveMind’s internal state. This is how opponent’s moves are received
[play, p]
Instruct the HiveMind to explore the current state. It will respond with the best move it finds after ExplorationTime
[quit]
Instruct the HiveMind to end the current game, but remain active to begin another.
[exit]
Instruct the HiveMind to quit and end the process.
Command Line Arguments
--port <Int>, -p <Int>: Specify the port which the HiveMind should listen on
Getting Started
First, you’ll need to grab a couple other repos to build the entire system and play a game of Hive against the HiveMind.
HiveMind
An AI developed to play the Hive board game.
Components
There are 4 main components which make up the HiveMind AI. This repository contains the main AI logic.
Client (Swift)
Server (Ruby on Rails)
Engine (Swift)
HiveMind (Swift)
Usage
The HiveMind uses a WebSocket for communication. By default, it listens on
ws://localhost:8080
, but you can change the port by providing an alternative through the command line arguments, described below.To interact with the HiveMind, you can provide various commands over the WebSocket, which it will reply to in turn. The available commands are:
[new, n] <IsFirst> <ExplorationTime>
IsFirst
is aBool
which indicates if the HiveMind will play first.ExplorationTime
is aDouble
which specifies the maximum amount of time the HiveMind can explore a state.[move, m] <Movement>
HiveEngine.Movement
(encoded as JSON) and update the HiveMind’s internal state. This is how opponent’s moves are received[play, p]
ExplorationTime
[quit]
[exit]
Command Line Arguments
--port <Int>
,-p <Int>
: Specify the port which the HiveMind should listen onGetting Started
swift build -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.13"
swift build -c release -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.13"
.build/debug/HiveMind
or.build/release/HiveMind
Requirements
Contributing
brew install swiftlint
swiftlint
from the root of the repository.Notice
Hive Mind is not affiliated with Gen42 Games in any way.