示例#1
0
 public boolean checkCanPut(Type put_type, Coord c) {
   int[] dx = {0, -1, -1, -1, 0, 1, 1, 1};
   int[] dy = {1, 1, 0, -1, -1, -1, 0, 1};
   for (int i = 0; i < 8; i++) {
     Coord temp;
     try {
       temp = new Coord(c.x + dx[i], c.y + dy[i]);
     } catch (IllegalArgumentException e) {
       continue;
     }
     if (st_board.get(temp).equals(put_type.getReverse().toState()) == true) {
       boolean flag = false;
       while (true) {
         try {
           temp = new Coord(temp.x + dx[i], temp.y + dy[i]);
         } catch (IllegalArgumentException e) {
           break;
         }
         if (st_board.get(temp).equals(put_type.toState()) == true) {
           flag = true;
           break;
         }
       }
       if (flag == true) return true;
     }
   }
   return false;
 }
示例#2
0
 public boolean turn_recursion(Type t, Coord c, int dx, int dy) {
   Coord next;
   try {
     next = new Coord(c.x + dx, c.y + dy);
   } catch (IllegalArgumentException e) {
     return false;
   }
   if (st_board.get(next).equals(State.NONE) == true) return false;
   else if (st_board.get(next).equals(t.toState()) == true) {
     st_board.turn(t.toState(), c);
     return true;
   } else {
     boolean b = false;
     if (b = turn_recursion(t, next, dx, dy) == true) st_board.turn(t.toState(), c);
     return b;
   }
 }
示例#3
0
 public boolean put(Type t, Coord c) {
   boolean is_anime;
   switch (t) {
     case BLACK:
       if (black.get(c) == false) return false;
       is_anime = st_board.turn(t.toState(), c);
       turn(t, c);
       break;
     case WHITE:
       if (white.get(c) == false) return false;
       is_anime = st_board.turn(t.toState(), c);
       turn(t, c);
       break;
     default:
       break;
   }
   return true;
 }