Skip to content

Commit 2625ae7

Browse files
committed
Merge pull request #145 from ujh/reduce-warnings
Reduce warnings
2 parents c5144b9 + c1ba864 commit 2625ae7

File tree

17 files changed

+39
-194
lines changed

17 files changed

+39
-194
lines changed

src/board/chain/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ use board::Coord;
2525

2626
use std::collections::HashSet;
2727

28-
mod test;
29-
3028
#[derive(Clone, Eq, PartialEq, Debug)]
3129
pub struct Chain {
3230
color: Color,
@@ -45,10 +43,6 @@ impl Chain {
4543
}
4644
}
4745

48-
pub fn color(&self) -> Color {
49-
self.color
50-
}
51-
5246
#[inline(always)]
5347
pub fn coords<'a>(&'a self) -> &'a Vec<Coord> {
5448
&self.coords
@@ -87,7 +81,4 @@ impl Chain {
8781
self.libs.len() == 0
8882
}
8983

90-
pub fn show(&self) -> String {
91-
format!("{:<3}| {:?}, libs: {:?}, stones: {:?}", self.id, self.color, self.libs, self.coords)
92-
}
9384
}

src/board/chain/test.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/board/coord/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ impl Coord {
4545
coords
4646
}
4747

48-
pub fn from_index(id: usize, board_size: u8) -> Coord {
49-
Coord {col: (id%board_size as usize + 1) as u8, row: (id/board_size as usize + 1) as u8}
50-
}
51-
5248
pub fn neighbours(&self, board_size: u8) -> Vec<Coord> {
5349
let mut neighbours = Vec::new();
5450

src/board/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,18 +582,10 @@ impl Board {
582582
self.consecutive_passes == 2 || self.resigned_by != Empty
583583
}
584584

585-
pub fn ruleset(&self) -> Ruleset {
586-
self.ruleset
587-
}
588-
589585
pub fn size(&self) -> u8 {
590586
self.size
591587
}
592588

593-
pub fn chains<'b>(&'b self) -> &'b Vec<Chain> {
594-
&self.chains
595-
}
596-
597589
pub fn vacant_point_count(&self) -> u16 {
598590
self.vacant.len() as u16
599591
}

src/board/test/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn legal_moves_only_contains_legal_moves() {
468468
#[test]
469469
fn ruleset_returns_the_correct_ruleset() {
470470
let b = Board::new(1, 6.5, Minimal);
471-
assert_eq!(b.ruleset(), Minimal);
471+
assert_eq!(b.ruleset, Minimal);
472472
}
473473

474474
#[test]

src/engine/controller/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Engine for EarlyReturnEngine {
6262
#[test]
6363
fn the_engine_can_use_less_time_than_allocated() {
6464
let game = Game::new(19, 6.5, Minimal);
65-
let color = game.next_player();
65+
let color = game.board().next_player();
6666
let timer = Timer::new(config());
6767
let budget = timer.budget(&game);
6868
let engine = Box::new(EarlyReturnEngine::new());
@@ -100,7 +100,7 @@ impl Engine for WaitingEngine {
100100
#[test]
101101
fn the_controller_asks_the_engine_for_a_move_when_the_time_is_up() {
102102
let game = Game::new(19, 6.5, Minimal);
103-
let color = game.next_player();
103+
let color = game.board().next_player();
104104
let mut timer = Timer::new(config());
105105
timer.setup(1, 0, 0);
106106
let budget = timer.budget(&game);

src/engine/move_stats/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ impl MoveStats {
6464
self.stats.values().all(|stat| stat.all_losses())
6565
}
6666

67-
pub fn all_wins(&self) -> bool {
68-
self.stats.values().all(|stat| stat.all_wins())
69-
}
70-
7167
pub fn best(&self) -> (Move, MoveStat) {
7268
let mut m = Pass(self.color);
7369
let mut move_stats = MoveStat::new();
@@ -112,10 +108,6 @@ impl MoveStat {
112108
self.plays = self.plays + 1;
113109
}
114110

115-
pub fn all_wins(&self) -> bool {
116-
self.wins == self.plays
117-
}
118-
119111
pub fn all_losses(&self) -> bool {
120112
self.wins == 0
121113
}

src/engine/move_stats/test.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,6 @@ mod move_stats {
5555
assert_eq!(ms.wins, 2);
5656
}
5757

58-
#[test]
59-
fn all_wins_returns_true_when_no_losses_were_recorded() {
60-
let moves = vec![Play(Black, 1, 1), Play(Black, 2, 2)];
61-
let mut stats = MoveStats::new(&moves, Black);
62-
stats.record_win(Play(Black, 1, 1));
63-
stats.record_win(Play(Black, 2, 2));
64-
assert!(stats.all_wins());
65-
}
66-
67-
#[test]
68-
fn all_wins_returns_false_when_a_loss_was_recorded() {
69-
let moves = vec![Play(Black, 1, 1), Play(Black, 2, 2)];
70-
let mut stats = MoveStats::new(&moves, Black);
71-
stats.record_loss(Play(Black, 1, 1));
72-
assert!(!stats.all_wins());
73-
}
74-
7558
#[test]
7659
fn all_losses_returns_true_when_no_wins_were_recorded() {
7760
let moves = vec![Play(Black, 1, 1), Play(Black, 2, 2)];

src/game/mod.rs

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
use board::Board;
2424
use board::Color;
25-
use board::Coord;
2625
use board::IllegalMove;
2726
use board::Move;
2827
use board::NoMove;
@@ -47,7 +46,6 @@ pub trait Info {
4746
pub struct Game {
4847
board: Board,
4948
last_move: Move,
50-
move_number: u16,
5149
zobrist_hash_table: ZobristHashTable,
5250
}
5351

@@ -58,16 +56,14 @@ impl Game {
5856
Game {
5957
board: new_board,
6058
last_move: NoMove,
61-
move_number: 0,
6259
zobrist_hash_table: ZobristHashTable::new(size),
6360
}
6461
}
6562

66-
pub fn with_new_state(board: Board, move_number: u16, zobrist_hash_table: ZobristHashTable, last_move: Move) -> Game {
63+
pub fn with_new_state(board: Board, zobrist_hash_table: ZobristHashTable, last_move: Move) -> Game {
6764
Game {
6865
board: board,
6966
last_move: last_move,
70-
move_number: move_number,
7167
zobrist_hash_table: zobrist_hash_table,
7268
}
7369
}
@@ -77,7 +73,7 @@ impl Game {
7773

7874
match new_board.play(m) {
7975
Ok(_) => {
80-
let mut new_game_state = Game::with_new_state(new_board, self.move_number + 1, self.zobrist_hash_table.clone(), m);
76+
let mut new_game_state = Game::with_new_state(new_board, self.zobrist_hash_table.clone(), m);
8177
if !m.is_pass() && !m.is_resign() {
8278
match new_game_state.check_and_update_super_ko(&m) {
8379
Err(_) => return Err(IllegalMove::SuperKo),
@@ -94,20 +90,6 @@ impl Game {
9490
self.zobrist_hash_table.check_and_update_super_ko(m, &self.board)
9591
}
9692

97-
// Note: This method uses 1-1 as the origin point, not 0-0. 19-19 is a valid coordinate in a 19-sized board, while 0-0 is not.
98-
// this is done because I think it makes more sense in the context of go. (Least surprise principle, etc...)
99-
pub fn get(&self, col: u8, row: u8) -> Color {
100-
self.board.color(&Coord::new(col, row))
101-
}
102-
103-
pub fn ruleset(&self) -> Ruleset {
104-
self.board.ruleset()
105-
}
106-
107-
pub fn move_number(&self) -> u16 {
108-
self.move_number
109-
}
110-
11193
pub fn last_move(&self) -> Move {
11294
self.last_move
11395
}
@@ -136,24 +118,10 @@ impl Game {
136118
self.board.set_komi(komi);
137119
}
138120

139-
pub fn board_size(&self) -> u8 {
140-
self.board.size()
141-
}
142-
143121
pub fn board(&self) -> Board {
144122
self.board.clone()
145123
}
146124

147-
pub fn show_chains(&self) {
148-
for c in self.board.chains().iter() {
149-
println!("{}", c.show());
150-
}
151-
}
152-
153-
pub fn next_player(&self) -> Color {
154-
self.board.next_player()
155-
}
156-
157125
pub fn legal_moves(&self) -> Vec<Move> {
158126
self.board
159127
.legal_moves_without_superko_check()

src/game/test/mod.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,9 @@ use board::Resign;
3030
use board::White;
3131
use game::Game;
3232
use ruleset::KgsChinese;
33-
use ruleset::Minimal;
3433

3534
mod ko;
3635

37-
#[test]
38-
fn should_start_counting_moves_at_0() {
39-
let g = Game::new(5, 6.5, Minimal);
40-
assert_eq!(0, g.move_number());
41-
}
42-
43-
#[test]
44-
fn should_increment_move_count_by_1_for_each_move() {
45-
let mut g = Game::new(5, 6.5, Minimal);
46-
g = g.play(Play(Black, 1, 1)).unwrap();
47-
assert_eq!(1, g.move_number());
48-
}
49-
5036
#[test]
5137
fn catch_suicide_moves_in_chinese() {
5238
let mut g = Game::new(3, 6.5, KgsChinese);
@@ -69,12 +55,6 @@ fn catch_suicide_moves_in_chinese() {
6955
}
7056
}
7157

72-
#[test]
73-
fn next_player_should_return_board_next_player() {
74-
let g = Game::new(3, 6.5, KgsChinese);
75-
assert_eq!(g.board.next_player(), g.next_player());
76-
}
77-
7858
#[test]
7959
fn it_should_handle_resign() {
8060
let g = Game::new(9, 6.5, KgsChinese);

0 commit comments

Comments
 (0)