Renamed variable to be more concise master
authorJustin Worthe <justin@worthe-it.co.za>
Sat, 8 Dec 2018 20:02:19 +0000 (22:02 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Sat, 8 Dec 2018 20:02:19 +0000 (22:02 +0200)
src/engine/bitwise_engine.rs
src/engine/geometry.rs
src/input/json.rs
src/strategy/monte_carlo.rs

index f03f1c0..694a309 100644 (file)
@@ -224,7 +224,7 @@ impl BitwiseGameState {
                 player.energy -= TESLA_FIRING_ENERGY;
                 tesla.cooldown = TESLA_COOLDOWN;
 
-                if tesla.pos.to_either_bitfield() & RIGHT_COL_MASK != 0 {
+                if tesla.pos.to_bitfield() & RIGHT_COL_MASK != 0 {
                     opponent.health = opponent.health.saturating_sub(TESLA_DAMAGE);
                 }
 
@@ -291,7 +291,7 @@ impl BitwiseGameState {
 
     fn update_tesla_activity(buildings: &mut Player) {
         let occupied = buildings.occupied;
-        buildings.tesla_cooldowns.retain(|t| (t.pos.to_either_bitfield() & occupied) != 0);
+        buildings.tesla_cooldowns.retain(|t| (t.pos.to_bitfield() & occupied) != 0);
     }
     
     
@@ -356,7 +356,7 @@ impl Player {
     pub fn location_of_unoccupied_cell(&self, i: usize) -> Point  {
         let bit = find_bit_index_from_rank(self.occupied, i as u64);
         let point = Point { index: bit };
-        debug_assert!(point.to_either_bitfield() & self.occupied == 0);
+        debug_assert!(point.to_bitfield() & self.occupied == 0);
         point
     }
 
@@ -365,7 +365,7 @@ impl Player {
         match command {
             Command::Nothing => {},
             Command::Build(p, b) => {
-                let bitfield = p.to_either_bitfield();
+                let bitfield = p.to_bitfield();
 
                 let price = match b {
                     BuildingType::Attack => MISSILE_PRICE,
@@ -415,7 +415,7 @@ impl Player {
                 let health = if building_type == BuildingType::Defence { DEFENCE_HEALTH } else { 1 };
 
                 let pos = self.unconstructed[i].pos;
-                let bitfield = pos.to_either_bitfield();
+                let bitfield = pos.to_bitfield();
 
                 for health_tier in 0..health {
                     self.buildings[health_tier] |= bitfield;
index b8b38dd..9cd1d90 100644 (file)
@@ -24,7 +24,7 @@ impl Point {
     }
 
     pub fn new_double_bitfield(x: u8, y: u8, is_left_player: bool) -> (u64, u64) {
-        let bitfield = Point::new(x, y).to_either_bitfield();
+        let bitfield = Point::new(x, y).to_bitfield();
         if (x >= SINGLE_MAP_WIDTH) == is_left_player {
             (0, bitfield)
         } else {
@@ -51,7 +51,7 @@ impl Point {
      * This involves mirroring the x dimension for the opponent's side
      */
 
-    pub fn to_either_bitfield(self) -> u64 {
+    pub fn to_bitfield(self) -> u64 {
         1u64 << self.index
     }
 }
index 4e10f9a..a71d49e 100644 (file)
@@ -89,7 +89,7 @@ impl State {
                     } else {
                         &mut opponent
                     };
-                    let bitfield = point.to_either_bitfield();
+                    let bitfield = point.to_bitfield();
 
                     bitwise_buildings.occupied |= bitfield;
                     if building.construction_time_left >= 0 {
index 543d5d7..adbb911 100644 (file)
@@ -2,7 +2,6 @@ use engine::command::*;
 use engine::status::GameStatus;
 use engine::bitwise_engine::{Player, BitwiseGameState};
 use engine::constants::*;
-use engine::geometry::*;
 
 use std::fmt;
 
@@ -234,7 +233,7 @@ pub fn random_move<R: Rng>(player: &Player, opponent: &Player, rng: &mut R) -> C
     if needs_energy && player.energy >= ENERGY_PRICE {
         for p in 0..NUMBER_OF_MAP_POSITIONS as u8 {
             let point = Point::new_index(p);
-            let weight = if player.occupied & point.to_either_bitfield() != 0 {
+            let weight = if player.occupied & point.to_bitfield() != 0 {
                 0
             } else {
                 2
@@ -252,7 +251,7 @@ pub fn random_move<R: Rng>(player: &Player, opponent: &Player, rng: &mut R) -> C
             let point = Point::new_index(p);
             let y = usize::from(point.y());
 
-            let weight = if player.occupied & point.to_either_bitfield() != 0 || point.x() < 4 {
+            let weight = if player.occupied & point.to_bitfield() != 0 || point.x() < 4 {
                 0
             } else {
                 defence_metric_per_row[y]
@@ -268,7 +267,7 @@ pub fn random_move<R: Rng>(player: &Player, opponent: &Player, rng: &mut R) -> C
     if player.energy >= MISSILE_PRICE {
         for p in 0..NUMBER_OF_MAP_POSITIONS as u8 {
             let point = Point::new_index(p);
-            let weight = if player.occupied & point.to_either_bitfield() != 0 {
+            let weight = if player.occupied & point.to_bitfield() != 0 {
                 0
             } else {
                 let y = usize::from(point.y());
@@ -286,7 +285,7 @@ pub fn random_move<R: Rng>(player: &Player, opponent: &Player, rng: &mut R) -> C
     if !cant_tesla {
         for p in 0..NUMBER_OF_MAP_POSITIONS as u8 {
             let point = Point::new_index(p);
-            let weight = if (player.occupied & point.to_either_bitfield() != 0) || point.y() < 7 {
+            let weight = if (player.occupied & point.to_bitfield() != 0) || point.y() < 7 {
                 0
             } else {
                 10