AI taking part in a game of Battle of the Centerländ.
  • Rust 88.7%
  • Makefile 8.4%
  • Shell 2.9%
Find a file
Jan Baudisch aec28948e0 Merge branch '43-catch-ping-error-in-ai' into 'dev'
Resolve "catch ping error in ai"

Closes #43

See merge request softwaregrundprojekt/2022-2023/gruppenprojekt/group-03/ai-03!37
2023-07-12 21:55:21 +00:00
ai Resolve "catch ping error in ai" 2023-07-12 21:55:21 +00:00
ai_train Resolve "catch ping error in ai" 2023-07-12 21:55:21 +00:00
.gitattributes Resolve "Include model in repo (LFS) and image" 2023-07-02 19:01:29 +00:00
.gitignore Resolve "Include model in repo (LFS) and image" 2023-07-02 19:01:29 +00:00
.gitlab-ci.yml Resolve "update README" 2023-07-04 11:50:06 +00:00
Cargo.lock Resolve "catch ping error in ai" 2023-07-12 21:55:21 +00:00
Cargo.toml Resolve "Rename components" 2023-07-03 10:54:23 +00:00
forest.model Resolve "Include updated model" 2023-07-12 21:53:18 +00:00
LICENSE feat: initial commit 2023-03-23 19:14:54 +01:00
Makefile fix(ci): adapt to new component names 2023-07-05 11:18:51 +02:00
README.md Resolve "Update README" 2023-07-04 19:43:03 +00:00

ai

AI taking part in a game of Battle of the Centerländ.

Structure

This project contains two programs: ai and ai_train. ai is the actual program implementing the AI. ai_train is a wrapper used to train the model for the AI.

Usage

AI

The AI takes the following arguments:

Short Long Environment Description Default
-t --host HOST Host to connect to.
-p --port PORT Port of host to connect to. 3018
-n --name NAME Name to use in game.
-d --delay DELAY Delay in ms to wait before declaring as ready to the server.
-m --mode MODE AI Mode for card choice, on of trained or random. trained
-o --model-path MODEL_PATH Model file to use in the trained mode. Ignored in other modes. /var/lib/app/model/forest.model
-e --exploration-rate EXPLORATION_RATE Exploration rate to use in the trained mode. Ignored in other modes.
-c --compatible COMPATIBLE Enable compatibility mode, where the client will wait before sending messages. false
-r --reconnect-tries RECONNECT_TRIES Maximum times to try a reconnection. 10
-l --log-level LOG_LEVEL Logging level, one of trace, debug, info, warn or error. info

Run ai --help to see the full help message.

Training Wrapper

The training wrapper takes the following arguments:

Short Long Environment Description Default
-o --model-path MODEL_PATH File to save the model to. forest.model
-i --iteration ITERATIONS Exploration rate to use in the trained mode. Ignored in other modes. 10
-g --games GAMES Enable compatibility mode, where the client will wait before sending messages. 100
-s --server-path SERVER_PATH Path to server binary. /usr/bin/server
-a --ai-path AI_PATH Path to ai binary. /usr/bin/ai
-l --log-level LOG_LEVEL Logging level, one of trace, debug, info, warn or error. info

Run ai_train --help to see the full help message.

Podman/Docker

To run the AI via Podman or Docker, use

podman run \
    --name AI1
    --delay 1000
    --host <host>
    gitlab.uni-ulm.de:5050/softwaregrundprojekt/2022-2023/gruppenprojekt/group-03/ai-03

This will:

  • connect to <host>:3018
  • wait for 1 second
  • log in as AI1

Note: You might need to log in first:

podman login -u <username> -p <access token> gitlab.uni-ulm.de:5050

Build

Prerequisites

Everything can be installed with rustup:

# Update rustup's information.
rustup update

# Install the stable Rust toolchain (if not already present).
rustup toolchain add stable

# Add rustfmt.
rustup component add rustfmt

# Add clippy.
rustup component add clippy

Building

To run the binary:

cargo run

To build both binaries:

cargo build

The resulting binary will be under target/debug/ai.

To build the binary in release mode:

cargo build --release

The resulting binary will be under target/release/ai.

Testing

Code Formatting

This should not output anything when the code is formatted corretcly:

cargo fmt --check

Run the following to automatically format the Rust code:

cargo fmt

Code Analysis

Run the following to check the code for common mistakes:

cargo clippy

Tests

Run tests with the following:

cargo test