Example #1
0
 public ArrayList<Integer> getIndexWillLose() {
   ArrayList<Integer> list = new ArrayList<Integer>();
   for (int i = 0; i < this.children.size(); i++) {
     Option compChoice = ((Option) this.children.get(i));
     if (compChoice.willLoseIfMovedHere()) {
       list.add(i);
     }
   }
   return list;
 }
Example #2
0
 public boolean walkingIntoTrap() {
   if (this.getDepth() == 2) {
     System.out.println(this.pathToThis);
     System.out.println(
         new TreePath() {
           {
             push(-1);
             push(0);
           }
         });
     System.out.println(
         this.pathToThis.equals(
             new TreePath() {
               {
                 push(-1);
                 push(0);
               }
             }));
     System.out.println(this.childrenToString());
   }
   for (int i = 0; i < this.children.size(); i++) {
     Option oponentChoice = (Option) this.getChild(i);
     int count = 0;
     if (this.getDepth() == 2) {
       System.out.println(this.value.board.toString());
       System.out.println(oponentChoice.childrenToString());
     }
     for (int j = 0; j < oponentChoice.children.size(); j++) {
       Option thisChoices2 = (Option) oponentChoice.getChild(j);
       ArrayList<Integer> list = new ArrayList<Integer>();
       if (this.getDepth() == 2) {
         System.out.println(thisChoices2.value.board.toString());
         System.out.println(thisChoices2.childrenToString());
       }
       for (int k = 0; k < thisChoices2.children.size(); k++) {
         Option oponentChoice2 = ((Option) this.children.get(k));
         if (this.getDepth() == 2) {
           System.out.println(oponentChoice2.value.board.toString());
           System.out.println(oponentChoice2.score);
         }
         if (oponentChoice2.score < -10) {
           list.add(k);
         }
       }
       if (list.size() == thisChoices2.children.size()) {
         count++;
       }
     }
     if (count == oponentChoice.children.size()) {
       return true;
     }
   }
   return false;
 }
Example #3
0
 public void generateNodes() {
   if (this.score == 0) {
     for (int rowNum = 0; rowNum < this.value.board.squares.length; rowNum++) {
       for (int colNum = 0; colNum < this.value.board.squares.length; colNum++) {
         if (this.value.board.squares[rowNum][colNum] == ' ') {
           Option choice =
               new Option(
                   this.value.copy(), rowNum, colNum, this.team, (Mind) this.hostTree, this);
           choice.generateNodes();
           this.addChild(choice);
         }
       }
     }
   }
 }