Example #1
0
void gen_move::generate_move(const board& b, int side, location_list& valid_moves)
{
  location_list::location m ;

  for(m.y = 0 ; m.y < 8 ; m.y++) {
    for(m.x = 0 ; m.x < 8 ; m.x++) {
      if(b.get_at(m) == board::EMPTY && b.check_move_at(m, side)) {
        valid_moves.insert(m) ;
      }
    }
  }
}
Example #2
0
int evaluate::count_move(const board& b, int side) 
{
  int count = 0 ;
  location_list::location m ;

  for(m.y = 0 ; m.y < 8 ; m.y++) {
    for(m.x = 0 ; m.x < 8 ; m.x++) {
      if(b.get_at(m) == board::EMPTY && b.check_move_at(m, side)) {
        count++ ;
      }
    }
  }
  return count ;
}
Example #3
0
evaluate::score evaluate::corner(const board& b, int turn) {
    
  location_list::location m ;
  int count  ;
  int c[4] ;
  int d ;
  int ch1, ch2 ;
  score s ;

  s = 0 ;
  count = 0 ;
  for(m.y = 0 ; m.y < 8 ; m.y+=7) {
    for(m.x = 0 ; m.x < 8 ; m.x+=7) {
      if((c[count] = b.get_at(m)) == side) {
        s += 20 ;
      } else if(c[count] == (side+1) % 2) {
        s -= 25 ;
      } else {
        ch1 = b.check_move_at(m, side) ;
        ch2 = b.check_move_at(m, (side+1)%2) ;
        if(ch1 && (turn == side || (!ch2))) {
          s += 20 ;
        } else if(ch2 && (turn != side || (!ch1))) {
          s -= 25 ;
        }
        c[count] = -1 ;
      } 
      count++ ;
    }
  } 

  if(c[0] == -1) {
    m.x = 1 ;
    m.y = 1 ;
    if((d = b.get_at(m)) == side) {
      s -= 25 ;
    } else if(d == (side + 1) % 2) {
      s += 20 ;
    }
  } 

  if(c[1] == -1) {
    m.x = 1 ;
    m.y = 6 ;
    if((d = b.get_at(m)) == side) {
      s -= 25 ;
    } else if(d == (side + 1) % 2) {
      s += 20 ;
    }
  }

  if(c[2] == -1) {
    m.x = 6 ;
    m.y = 1 ;
    if((d = b.get_at(m)) == side) {
      s -= 25 ;
    } else if(d == (side + 1) % 2) {
      s += 20 ;
    }
  }
  
  if(c[3] == -1) {
    m.x = 6 ;
    m.y = 6 ;
    if((d = b.get_at(m)) == side) {
      s -= 25 ;
    } else if(d == (side + 1) % 2) {
      s += 20 ;
    }
  }
  return s ; 
}