summaryrefslogtreecommitdiff
path: root/README.md
blob: a0c300817aa48ba256b5daf799371537cd283d66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Steam Powered Wyrm

This is an entry to the 2019 Entelect Challenge.

## Environment Setup

The Rust compiler toolchain can be downloaded from the Rust project
website.

https://www.rust-lang.org/en-US/install.html

The project requires these versions of the toolchain (or later).

- cargo 1.34.0
- rustc 1.34.0

## Building

Rust's official build tool is called Cargo. It will download
dependencies and call the Rust compiler as required. Dependencies are
configured in [Cargo.toml](./Cargo.toml).

Cargo needs to be called from the root of the bot (the folder with the
Cargo.toml file).

```sh
cargo build --release
```

## Running Tests

Rust has support for unit testing built into the language. Any
functions marked with the `#[test]` annotation are considered tests.

Tests can be run using Cargo:

```sh
cargo test
```

More information on how to write tests is available in
[The Rust Programming Language](https://doc.rust-lang.org/book/ch11-00-testing.html).

## Exporting the compiled executable

By default, Rust produces statically linked binaries, so you can just
copy out the executable file from the target directory and put it
wherever you want.

The name of the binary will match the name of the binary crate in
Cargo.toml.

Note: This binary has been built for the platform that it was compiled
on. In other words, if it was compiled on 64 bit Linux, you cannot
copy the binary to a Windows machine and run it. You WILL be able to
copy the binary between similar 64 bit Linux machines.

The machine that the compiled binary is run on does not need to have
the Rust toolchain installed.

```sh
cp ./target/release/<botFileName> <dest>
```

## Running

The compiled binary can be executed directly.

```sh
./target/release/<botFileName>
```

For convenience in development, you can compile and run through Cargo.

Note: This is not recommended for the tournament servers, since there
is a small runtime cost in Cargo checking that the compiled binary is
up to date before running it.

```sh
cargo run --release
```