aboutsummaryrefslogtreecommitdiff
path: root/src/game.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.rs')
-rw-r--r--src/game.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/game.rs b/src/game.rs
index 04bd76a..be9d23d 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -650,6 +650,7 @@ impl GameState {
return None;
}
+ // TODO: this does not handle the case dragon edge case
fn check_win(&self) -> Option<WinType> {
if let Some(w) = self.check_road_win() {
return Some(w);
@@ -731,17 +732,20 @@ impl Game {
pub fn query_action_lines(&self) -> String {
let mut result = String::new();
let mut newline = true;
- result += "0. ";
- for i in 0..self.actions.len() {
- if i > 1 && newline {
- // TODO: Is placing the opponent's first stone the zeroeth action?
- result += &format!("{}. ", i);
- }
- result += &format!("{} ", self.actions[i]);
- if i > 0 && !newline {
- result.push('\n');
+ let num_actions = self.actions.len();
+ if num_actions > 0 {
+ result += "0. ";
+ for i in 0..num_actions {
+ if i > 1 && newline {
+ // TODO: Is placing the opponent's first stone the zeroeth action?
+ result += &format!("{}. ", i);
+ }
+ result += &format!("{} ", self.actions[i]);
+ if i > 0 && !newline {
+ result.push('\n');
+ }
+ newline = !newline;
}
- newline = !newline;
}
result
}