From 942c13ee26b180316f46921531c737fa8eb4197e Mon Sep 17 00:00:00 2001 From: tslil clingman <> Date: Sun, 9 Feb 2020 13:45:15 -0800 Subject: Silly error in CPS implementation --- src/game.rs | 6 +++--- src/main.rs | 4 ++-- src/parser.rs | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/game.rs b/src/game.rs index c851e3d..b49f626 100644 --- a/src/game.rs +++ b/src/game.rs @@ -729,7 +729,7 @@ impl StartType { fn player_turnorder_at(&self, turn_num: usize) -> (Player, TurnOrder) { match self { StartType::CPS(c) => { - if turn_num + 1 > (*c as usize) { + if turn_num * 2 > (*c as usize) { if turn_num % 2 == 0 { (Player::White, TurnOrder::Normal) } else { @@ -743,8 +743,8 @@ impl StartType { } } } - StartType::FCS => StartType::CPS(2).player_turnorder_at(turn_num), - StartType::FES => StartType::CPS(2).player_turnorder_at(turn_num), + StartType::FCS => StartType::CPS(1).player_turnorder_at(turn_num), + StartType::FES => StartType::CPS(1).player_turnorder_at(turn_num), StartType::TPS => match turn_num { 0 => (Player::White, TurnOrder::WhitePlacesBlack), 1 => (Player::White, TurnOrder::WhitePlacesBlack), diff --git a/src/main.rs b/src/main.rs index f88fee5..50bfcf4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,7 +48,7 @@ fn main() { &["-v", "--variant-start"], Store, "Select the rule variant for the start of play. Valid choices are CPSn, FCS, FES, TPS, and CZS. - The default starting type, which matches the original rules, is CPS2.", + The default starting type, which matches the original rules, is CPS1.", ) .metavar("VRNT"); @@ -89,7 +89,7 @@ fn main() { Ok(st) => start_type = st, } } else { - start_type = StartType::CPS(2); + start_type = StartType::CPS(1); } let call_proc; diff --git a/src/parser.rs b/src/parser.rs index c88d751..ba58b72 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -190,7 +190,9 @@ pub fn parse_start_type(st: &str) -> Result { if st.len() < 4 { return Err(String::from( - "Expecting CPSn as alternatives failed to match, but variant string was too short.", + "Expecting CPSn as + alternatives failed to match, but variant string was too + short.", )); } else { if st[..3] == String::from("CPS") { @@ -198,7 +200,8 @@ pub fn parse_start_type(st: &str) -> Result { match num { Err(e) => { return Err(format!( - "Failed to parse number, {}. CPS must be followed by a positive integer < 256, e.g., CPS2.", + "Failed to parse number, {}. CPS must be + immediately followed by a positive integer < 256, e.g., CPS1.", e.to_string() )) } -- cgit v1.3.1