Skip to content

Latest commit

 

History

85 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AIBG - Medieval Tactics

Description

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.

Visuals

AIBG - Topic - Medival Tactics AIBG - Topic - Medival Tactics AIBG - Topic - Medival Tactics AIBG - Topic - Medival Tactics AIBG - Topic - Medival Tactics

Docs

Attribution

Created by:

License CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Usage

This topic was used in the following events:

How to run

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.

Prerequisites

  1. Install Node.js and npm (for server and JavaScript agent)

  2. (Optional) Install Python 3.7+ (for Python agent)

  3. Install an IDE with Live Server extension (for visuals)

  4. Install required dependencies:

    • For server:

      cd server
      npm install
    • For JavaScript agents:

      cd agents
      npm install
    • For Python agents:

      cd agents
      pip install websockets

Game flow

  1. Start the server
  2. Start the visuals
  3. Connect two clients using valid IDs from logic/src/gameFiles/players.json (game starts automatically when both agents connect)
  4. Server shuts down automatically after the game ends or when a winner is determined

Running the server

  1. The server is part of the logic/ folder and reads its players file from logic/src/gameFiles/players.json. Create or edit that file if you need team IDs.

  2. Start the server from the logic/ directory:

    cd logic
    node src/controller.js
  • The server listens on port 3000.

Running the visuals

  1. Open the project in your IDE (we recommend VS Code)
  2. Right-click on visuals/index.html → "Open with Live Server"
    • Live Server extension has to be installed
  3. The game visualization will open in your default browser and connects to the server on ws://localhost:3000?id=frontend.

Running agents

JavaScript agent

node agents/agent.js <playerID> [modeId]
  • Example: node agents/agent.js 12345 0 will run the agent for player ID 12345 in 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).
    • modeId values supported: 0 = normal (default), 1 = timeout, 2 = illegalMove.

Python agent

python3 agents/simpleAgent.py [playerID] [modeId]
  • Example: python3 agents/simpleAgent.py 12345 0 will run the Python simple agent for player ID 12345 in normal mode.
  • The agent connects to ws://localhost:3000?id=<playerID> and will send placement moves when it receives a placingIndexes message and send moves when it receives a currentTurn message with its id.
  • Default behavior in agents/simpleAgent.py:
    • Default player ID: 12345 (used when no ID is supplied).
    • modeId values supported: 0 or 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 placingIndexes from the server. After prepared moves are exhausted it will wait for further server messages.

Deploy

To deploy the game server on a VPS:

  1. Install prerequisites Make sure git, node, and npm are installed:

    sudo apt update
    sudo apt install git nodejs npm
  2. Get the project files on your VPS You can either clone the public repository (recommended), or use rsync/scp to copy files manually.

    • Clone the repository (recommended):

      git clone https://github.com/AIBG-vault/topic-name.git
      cd AIBG
    • Or copy files using rsync or scp:

      # 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/
  3. Install dependencies and start the server

    cd logic
    npm install
    node src/controller.js
  4. 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>).

(Optional) Set up a custom domain

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:3000
  • ws://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.

About

Medieval Tactics is a two-player, turn-based strategy game set on a grid-based battlefield. Each player commands a medieval army. Players take turns moving their creatures across the board, attacking enemy units using melee or ranged abilities, and aiming to eliminate the opposing team. The game ends when one player’s army is defeated.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages