Medieval Tactics is a two-player, turn-based grid strategy game. Each player commands an army composed of distinct units (Pikeman, Marksman, Knight, Archer, Cavalry, Armored Peasant, Phoenix). Players take turns moving units and using melee or ranged attacks; the match ends when one side is defeated.
Created by:
- Petar Hajduk (Topic responsible)
- Jakov Jakovac
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
This topic was used in the following events:
Before you begin, make sure your environment is set up to run the game. The following prerequisites will help you configure your system to run the server, agents, and visuals correctly.
-
Install Node.js and npm (for server and JavaScript agent)
-
(Optional) Install Python 3.7+ (for Python agent)
-
Install an IDE with Live Server extension (for visuals)
-
Install required dependencies:
-
For server:
cd server npm install -
For JavaScript agents:
cd agents npm install -
For Python agents:
cd agents pip install websockets
-
- Start the server
- Start the visuals
- Connect two clients using valid IDs from
logic/src/gameFiles/players.json(game starts automatically when both agents connect) - Server shuts down automatically after the game ends or when a winner is determined
-
The server is part of the
logic/folder and reads its players file fromlogic/src/gameFiles/players.json. Create or edit that file if you need team IDs. -
Start the server from the
logic/directory:cd logic node src/controller.js
- The server listens on port
3000.
- Open the project in your IDE (we recommend VS Code)
- Right-click on
visuals/index.html→ "Open with Live Server"- Live Server extension has to be installed
- The game visualization will open in your default browser and connects to the server on
ws://localhost:3000?id=frontend.
node agents/agent.js <playerID> [modeId]- Example:
node agents/agent.js 12345 0will run the agent for player ID12345in normal mode. - The agent connects to
ws://localhost:3000?id=<playerID>and will send moves when it receives a message indicating it's the current player. - Default behavior in
agents/agent.js:- Default player ID:
12345(used when no ID is supplied). modeIdvalues supported:0= normal (default),1= timeout,2= illegalMove.
- Default player ID:
python3 agents/simpleAgent.py [playerID] [modeId]- Example:
python3 agents/simpleAgent.py 12345 0will run the Python simple agent for player ID12345in normal mode. - The agent connects to
ws://localhost:3000?id=<playerID>and will send placement moves when it receives aplacingIndexesmessage and send moves when it receives acurrentTurnmessage with its id. - Default behavior in
agents/simpleAgent.py:- Default player ID:
12345(used when no ID is supplied). modeIdvalues supported:0or omitted = normal (default),1= timeout (adds delay to simulate slow agent),2= illegalMove (sends one intentionally invalid placement).- The simple agent automatically plays placements (creatureId 1..7) on the left (x=0) or right (x=17) side based on
placingIndexesfrom the server. After prepared moves are exhausted it will wait for further server messages.
- Default player ID:
To deploy the game server on a VPS:
-
Install prerequisites Make sure
git,node, andnpmare installed:sudo apt update sudo apt install git nodejs npm
-
Get the project files on your VPS You can either clone the public repository (recommended), or use
rsync/scpto copy files manually.-
Clone the repository (recommended):
git clone https://github.com/AIBG-vault/topic-name.git cd AIBG -
Or copy files using
rsyncorscp:# Using rsync rsync -av /path/to/AIBG user@your-vps-ip:/home/user/ # Or using scp scp -r /path/to/AIBG user@your-vps-ip:/home/user/
-
-
Install dependencies and start the server
cd logic npm install node src/controller.js -
Open firewall ports Make sure port 3000 is open:
sudo ufw allow 3000
Players can now connect to the server using your VPS IP and the chosen port (e.g., ws://your-vps-ip:3000?id=<playerID>).
For easier access, consider setting up a DNS record (e.g., topic.aibg.best.hr) that points to your VPS IP. This makes it simpler for players to connect and remember the server address.
Example WebSocket connection URLs:
ws://topic.aibg.best.hr:3000ws://your-vps-ip:3000
To set up a DNS record, use your domain provider’s dashboard to create an A record pointing to your VPS.




