summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-05-26 18:23:05 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-05-26 18:23:05 +0200
commit9450ab5a6bf6b2aa57c1ebbd0be0a88c1110e140 (patch)
treecd2eedb95ee961e0be3fb15d318b50eecbe18edd
parentd37be51f196eebdb8df57c87e8ab5bb684e1dcd9 (diff)
Setting up makefile for submission
-rw-r--r--.gitignore1
-rw-r--r--Makefile24
-rw-r--r--src/bin/benchmark.rs2
-rw-r--r--src/strategy.rs4
4 files changed, 28 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 84a323e..791452f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
target
**/*.rs.bk
+submission.zip
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7b46d01
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+build:
+ cargo build --release
+
+test:
+ cargo test --release
+
+bench:
+ cargo run --release --features "benchmarking" --bin perf-test
+
+profile:
+ cargo build --release --features "benchmarking single-threaded"
+ mkdir -p target/profile
+ sudo perf record -F 1000 -a -g target/release/perf-test
+ sudo perf script > target/profile/out.perf
+ ../FlameGraph/stackcollapse-perf.pl target/profile/out.perf > target/profile/out.folded
+ ../FlameGraph/flamegraph.pl target/profile/out.folded > target/profile/flamegraph.svg
+
+clean:
+ cargo clean
+
+submission.zip:
+ zip -r9 submission.zip bot.json Cargo.lock Cargo.toml src
+
+.PHONY: build test bench profile clean
diff --git a/src/bin/benchmark.rs b/src/bin/benchmark.rs
index 20f74d0..098192c 100644
--- a/src/bin/benchmark.rs
+++ b/src/bin/benchmark.rs
@@ -7,7 +7,7 @@ use steam_powered_wyrm::json;
use steam_powered_wyrm::game;
fn main() {
- let max_time = Duration::milliseconds(950);
+ let max_time = Duration::milliseconds(19950);
let start_time = PreciseTime::now();
match json::read_state_from_json_file(&Path::new(&format!("./tests/example-state.json"))) {
diff --git a/src/strategy.rs b/src/strategy.rs
index 8e004cf..dd5bece 100644
--- a/src/strategy.rs
+++ b/src/strategy.rs
@@ -185,8 +185,8 @@ fn best_player_move(node: &Node) -> Command {
fn score(state: &GameBoard) -> Score {
Score {
val: match state.outcome {
- SimulationOutcome::PlayerWon(0) => 10000.,
- SimulationOutcome::PlayerWon(1) => -10000.,
+ SimulationOutcome::PlayerWon(0) => 500.,
+ SimulationOutcome::PlayerWon(1) => -500.,
_ => (state.players[0].score() - state.players[1].score()) as f32,
}
}