Skip to content

Commit 395c759

Browse files
committed
fixing confusing not not
1 parent 2166d4a commit 395c759

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/board/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,21 +624,21 @@ impl Board {
624624
set.len() + 1 //plus the stone we're about to play
625625
}
626626

627-
pub fn new_chain_length_greater_than(&self, m: Move, limit: usize) -> bool {
627+
pub fn new_chain_length_less_than(&self, m: Move, limit: usize) -> bool {
628628
let mut set: HashSet<&Coord> = HashSet::new();
629629

630630
for &c in self.neighbours(m.coord()).iter() {
631631
if self.color(&c) == *m.color() {
632632
for coord in self.get_chain(c).unwrap().coords().iter() {
633633
set.insert(coord);
634634
if set.len() + 1 > limit {
635-
return true;
635+
return false;
636636
}
637637
}
638638
}
639639
}
640640

641-
false
641+
true
642642
}
643643

644644
pub fn score(&self) -> Score {

src/board/test/hypotheticals.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn two_stones_have_six_liberties() {
116116

117117
let play = Play(Black, 10, 12);
118118
assert_eq!(2, board.new_chain_length(play));
119-
assert!(board.new_chain_length_greater_than(play, 1));
119+
assert!(board.new_chain_length_less_than(play, 3));
120120
assert_eq!(6, board.new_chain_liberties(play));
121121
assert!(board.new_chain_liberties_greater_than(play, 5));
122122
}
@@ -128,7 +128,7 @@ fn three_stones_have_eight_liberties() {
128128
let board = game.board();
129129
let play = Play(Black, 10, 10);
130130
assert_eq!(3, board.new_chain_length(play));
131-
assert!(board.new_chain_length_greater_than(play, 2));
131+
assert!(board.new_chain_length_less_than(play, 4));
132132
assert_eq!(8, board.new_chain_liberties(play));
133133
assert!(board.new_chain_liberties_greater_than(play, 7));
134134
}
@@ -140,7 +140,7 @@ fn four_stones_have_eight_liberties() {
140140
let board = game.board();
141141
let play = Play(Black, 10, 7);
142142
assert_eq!(4, board.new_chain_length(play));
143-
assert!(board.new_chain_length_greater_than(play, 3));
143+
assert!(board.new_chain_length_less_than(play, 5));
144144
assert_eq!(8, board.new_chain_liberties(play));
145145
assert!(board.new_chain_liberties_greater_than(play, 7));
146146
}
@@ -152,7 +152,7 @@ fn five_stones_have_eight_liberties() {
152152
let board = game.board();
153153
let play = Play(Black, 10, 4);
154154
assert_eq!(5, board.new_chain_length(play));
155-
assert!(board.new_chain_length_greater_than(play, 4));
155+
assert!(board.new_chain_length_less_than(play, 6));
156156
assert_eq!(8, board.new_chain_liberties(play));
157157
assert!(board.new_chain_liberties_greater_than(play, 7));
158158
}
@@ -164,7 +164,7 @@ fn six_stones_have_nine_liberties() {
164164
let board = game.board();
165165
let play = Play(Black, 15, 17);
166166
assert_eq!(6, board.new_chain_length(play));
167-
assert!(board.new_chain_length_greater_than(play, 5));
167+
assert!(board.new_chain_length_less_than(play, 7));
168168
assert_eq!(9, board.new_chain_liberties(play));
169169
assert!(board.new_chain_liberties_greater_than(play, 8));
170170
}
@@ -177,7 +177,7 @@ fn seven_stones_have_ten_liberties() {
177177
let play = Play(Black, 15, 13);
178178

179179
assert_eq!(7, board.new_chain_length(play));
180-
assert!(board.new_chain_length_greater_than(play, 6));
180+
assert!(board.new_chain_length_less_than(play, 8));
181181
assert_eq!(10, board.new_chain_liberties(play));
182182
assert!(board.new_chain_liberties_greater_than(play, 9));
183183
}
@@ -189,7 +189,7 @@ fn nine_stones_have_twelve_liberties() {
189189
let board = game.board();
190190
let play = Play(Black, 15, 9);
191191
assert_eq!(9, board.new_chain_length(play));
192-
assert!(board.new_chain_length_greater_than(play, 8));
192+
assert!(board.new_chain_length_less_than(play, 10));
193193
assert_eq!(12, board.new_chain_liberties(play));
194194
assert!(board.new_chain_liberties_greater_than(play, 11));
195195
}

src/playout/no_eyes.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@ impl Playout for NoSelfAtariPlayout {
4545

4646
fn is_playable(&self, board: &Board, m: &Move) -> bool {
4747
!board.is_eye(&m.coord(), *m.color())
48-
&& (
49-
board.liberty_count(m.coord()) > 1 ||
48+
&& {
49+
let empty = board.liberty_count(m.coord());
50+
empty > 1 ||
5051
{
5152
let removed_enemies = board.removes_enemy_neighbouring_stones(*m);
5253

53-
removed_enemies > 1 ||
54+
empty + removed_enemies > 1 ||
5455
{
5556
(removed_enemies > 0 && board.new_chain_liberties_greater_than(*m, 0)) ||
5657
board.new_chain_liberties_greater_than(*m, 1)
5758
}
58-
}
59-
|| !board.new_chain_length_greater_than(*m, 3) //don't suicide 3 stone groups in the playouts, only in the tree
60-
)
59+
}
60+
|| board.new_chain_length_less_than(*m, 3) //you can self-atari one or two stones in playouts
61+
}
6162
}
6263

6364
fn playout_type(&self) -> String {

0 commit comments

Comments
 (0)