removed dbgs and hint comments

This commit is contained in:
LinlyBoi
2023-05-01 23:19:31 +03:00
parent 23fc7aa872
commit f992f2331f

View File

@@ -14,7 +14,6 @@ pub fn one_direction(board: &Array2D<Disk>, index: &(usize, usize), direction: D
match board.get(current_index.0, current_index.1) { match board.get(current_index.0, current_index.1) {
Some(_disk) => { Some(_disk) => {
if variant_eq(current_disk, _disk) && !matches!(_disk, Disk::EMPTY) { if variant_eq(current_disk, _disk) && !matches!(_disk, Disk::EMPTY) {
dbg!(current_index, in_a_row, current_disk, _disk);
// add in a row by 1 // add in a row by 1
in_a_row += 1; in_a_row += 1;
//go to next element //go to next element
@@ -53,21 +52,21 @@ pub fn one_direction(board: &Array2D<Disk>, index: &(usize, usize), direction: D
current_index.0 += 1; current_index.0 += 1;
} }
Direction::UPBACK => { Direction::UPBACK => {
if current_index.0 == 0 || current_index.1 == board.num_rows() - 1 { if current_index.0 == board.num_columns() - 1 || current_index.1 == 0 {
break; break;
} }
current_index.1 -= 1; current_index.1 -= 1;
current_index.0 += 1; current_index.0 += 1;
} }
Direction::DOWNFORW => { Direction::DOWNFORW => {
if current_index.1 == 0 || current_index.0 == board.num_columns() - 1 { if current_index.0 == 0 || current_index.1 == board.num_columns() - 1 {
break; break;
} }
current_index.1 += 1; current_index.1 += 1;
current_index.0 -= 1; current_index.0 -= 1;
} }
Direction::DOWNBACK => { Direction::DOWNBACK => {
if current_index.1 == 0 || current_index.0 == 0 { if current_index.0 == 0 || current_index.1 == 0 {
break; break;
} }
current_index.1 -= 1; current_index.1 -= 1;
@@ -82,7 +81,6 @@ pub fn one_direction(board: &Array2D<Disk>, index: &(usize, usize), direction: D
None => break, None => break,
} }
} }
dbg!(in_a_row);
if in_a_row == 4 { if in_a_row == 4 {
//score added //score added
return 1; return 1;
@@ -98,13 +96,6 @@ pub fn two_direction(board: &Array2D<Disk>, index: &(usize, usize)) -> i32 {
unimplemented!() unimplemented!()
//+-1 -+2 //+-1 -+2
} }
//1 == number
//dbg!()
//println!()
//matches!()
//assert!()
// for _num 0..n {}
pub enum Direction { pub enum Direction {
UP, UP,
DOWN, DOWN,
@@ -116,6 +107,7 @@ pub enum Direction {
DOWNBACK, DOWNBACK,
//TODO add more directions for diagonals //TODO add more directions for diagonals
} }
// serves nothing except do what matches!() should have done all along
fn variant_eq<T>(a: &T, b: &T) -> bool { fn variant_eq<T>(a: &T, b: &T) -> bool {
std::mem::discriminant(a) == std::mem::discriminant(b) std::mem::discriminant(a) == std::mem::discriminant(b)
} }