Skip to content

Commit

Permalink
if duplicate 3 times, first role loss
Browse files Browse the repository at this point in the history
  • Loading branch information
netcan committed Jun 25, 2020
1 parent 1dff22f commit 9e60b19
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ impl Board {
else { return BLACK; }
}

// if duplicate 3 times, first role loss
let mut dup_times = 0;
for context in self.ctx.iter().rev() {
if self.get_fen() == context.fen {
dup_times += 1;
}
if dup_times >= 3 {
if self.role == RED { // red loss
return BLACK;
} else {
return RED;
}
}
}

RoleType::EMPTY
}

Expand Down

0 comments on commit 9e60b19

Please sign in to comment.