Updated benchmark to only take constant map size into account
authorJustin Worthe <justin@worthe-it.co.za>
Sat, 30 Jun 2018 13:38:45 +0000 (15:38 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Sat, 30 Jun 2018 13:38:45 +0000 (15:38 +0200)
src/bin/perf-test.rs
tests/state0.json

index 71044ad..054258f 100644 (file)
@@ -5,17 +5,10 @@ use time::{PreciseTime, Duration};
 use zombot::*;
 
 const STATE_PATH: &str = "tests/state0.json";
-const STATE_BIG_PATH: &str = "tests/bigstate.json";
 
 use std::process;
 
 fn main() {
-    normal_state();
-    big_state();
-}
-
-fn normal_state() {
-    println!("Normal size state file");
     let start_time = PreciseTime::now();
     let (settings, state) = match input::json::read_state_from_file(STATE_PATH) {
         Ok(ok) => ok,
@@ -27,17 +20,3 @@ fn normal_state() {
     let max_time = Duration::milliseconds(1950);
     strategy::monte_carlo::choose_move(&settings, &state, &start_time, max_time);
 }
-
-fn big_state() {
-    println!("Big state file");
-    let start_time = PreciseTime::now();
-    let (settings, state) = match input::json::read_state_from_file(STATE_BIG_PATH) {
-        Ok(ok) => ok,
-        Err(error) => {
-            println!("Error while parsing JSON file: {}", error);
-            process::exit(1);
-        }
-    };
-    let max_time = Duration::milliseconds(1950);
-    strategy::monte_carlo::choose_move(&settings, &state, &start_time, max_time);
-}
index ef5cd39..9e52de6 100644 (file)
@@ -1,310 +1 @@
-{
-  "gameDetails": {
-    "round": 0,
-    "mapWidth": 8,
-    "mapHeight": 4,
-    "roundIncomeEnergy": 5,
-    "buildingPrices": {
-      "TESLA": 300,
-      "ENERGY": 20,
-      "ATTACK": 30,
-      "DEFENSE": 30
-    },
-    "buildingsStats": {
-      "TESLA": {
-        "health": 5,
-        "constructionTime": 11,
-        "price": 300,
-        "weaponDamage": 20,
-        "weaponSpeed": 0,
-        "weaponCooldownPeriod": 10,
-        "energyGeneratedPerTurn": 0,
-        "destroyMultiplier": 1,
-        "constructionScore": 1
-      },
-      "ENERGY": {
-        "health": 5,
-        "constructionTime": 2,
-        "price": 20,
-        "weaponDamage": 0,
-        "weaponSpeed": 0,
-        "weaponCooldownPeriod": 0,
-        "energyGeneratedPerTurn": 3,
-        "destroyMultiplier": 1,
-        "constructionScore": 1
-      },
-      "ATTACK": {
-        "health": 5,
-        "constructionTime": 2,
-        "price": 30,
-        "weaponDamage": 5,
-        "weaponSpeed": 1,
-        "weaponCooldownPeriod": 3,
-        "energyGeneratedPerTurn": 0,
-        "destroyMultiplier": 1,
-        "constructionScore": 1
-      },
-      "DEFENSE": {
-        "health": 20,
-        "constructionTime": 4,
-        "price": 30,
-        "weaponDamage": 0,
-        "weaponSpeed": 0,
-        "weaponCooldownPeriod": 0,
-        "energyGeneratedPerTurn": 0,
-        "destroyMultiplier": 1,
-        "constructionScore": 1
-      }
-    }
-  },
-  "players": [
-    {
-      "playerType": "A",
-      "energy": 20,
-      "health": 100,
-      "hitsTaken": 0,
-      "score": 0
-    },
-    {
-      "playerType": "B",
-      "energy": 20,
-      "health": 100,
-      "hitsTaken": 0,
-      "score": 0
-    }
-  ],
-  "gameMap": [
-    [
-      {
-        "x": 0,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 1,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 2,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 3,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 4,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 5,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 6,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 7,
-        "y": 0,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      }
-    ],
-    [
-      {
-        "x": 0,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 1,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 2,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 3,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 4,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 5,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 6,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 7,
-        "y": 1,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      }
-    ],
-    [
-      {
-        "x": 0,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 1,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 2,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 3,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 4,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 5,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 6,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 7,
-        "y": 2,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      }
-    ],
-    [
-      {
-        "x": 0,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 1,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 2,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 3,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "A"
-      },
-      {
-        "x": 4,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 5,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 6,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      },
-      {
-        "x": 7,
-        "y": 3,
-        "buildings": [],
-        "missiles": [],
-        "cellOwner": "B"
-      }
-    ]
-  ]
-}
+{"gameDetails":{"round":0,"maxRounds":400,"mapWidth":16,"mapHeight":8,"roundIncomeEnergy":5,"buildingPrices":{"ENERGY":20,"ATTACK":30,"DEFENSE":30,"TESLA":300},"buildingsStats":{"ENERGY":{"health":5,"constructionTime":2,"price":20,"weaponDamage":0,"weaponSpeed":0,"weaponCooldownPeriod":0,"energyGeneratedPerTurn":3,"destroyMultiplier":1,"constructionScore":3},"ATTACK":{"health":5,"constructionTime":2,"price":30,"weaponDamage":5,"weaponSpeed":2,"weaponCooldownPeriod":3,"energyGeneratedPerTurn":0,"destroyMultiplier":1,"constructionScore":4},"DEFENSE":{"health":20,"constructionTime":4,"price":30,"weaponDamage":0,"weaponSpeed":0,"weaponCooldownPeriod":0,"energyGeneratedPerTurn":0,"destroyMultiplier":1,"constructionScore":10},"TESLA":{"health":5,"constructionTime":11,"price":300,"weaponDamage":20,"weaponSpeed":0,"weaponCooldownPeriod":10,"energyGeneratedPerTurn":0,"destroyMultiplier":10,"constructionScore":20}}},"players":[{"playerType":"A","energy":20,"health":100,"hitsTaken":0,"score":0},{"playerType":"B","energy":20,"health":100,"hitsTaken":0,"score":0}],"gameMap":[[{"x":0,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":0,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":0,"buildings":[],"missiles":[],"cellOwner":"B"}],[{"x":0,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":1,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":1,"buildings":[],"missiles":[],"cellOwner":"B"}],[{"x":0,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":2,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":2,"buildings":[],"missiles":[],"cellOwner":"B"}],[{"x":0,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":3,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":3,"buildings":[],"missiles":[],"cellOwner":"B"}],[{"x":0,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":4,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":4,"buildings":[],"missiles":[],"cellOwner":"B"}],[{"x":0,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":5,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":5,"buildings":[],"missiles":[],"cellOwner":"B"}],[{"x":0,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":6,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":6,"buildings":[],"missiles":[],"cellOwner":"B"}],[{"x":0,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":1,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":2,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":3,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":4,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":5,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":6,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":7,"y":7,"buildings":[],"missiles":[],"cellOwner":"A"},{"x":8,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":9,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":10,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":11,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":12,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":13,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":14,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"},{"x":15,"y":7,"buildings":[],"missiles":[],"cellOwner":"B"}]],"teslaHitList":[]}
\ No newline at end of file