- Rust 88.7%
- Makefile 8.4%
- Shell 2.9%
Resolve "catch ping error in ai" Closes #43 See merge request softwaregrundprojekt/2022-2023/gruppenprojekt/group-03/ai-03!37 |
||
|---|---|---|
| ai | ||
| ai_train | ||
| .gitattributes | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| forest.model | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
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