moveQueenTo() public method

public moveQueenTo ( XYLocation l ) : void
l AIMA.Core.Util.DataStructure.XYLocation
return void
Exemplo n.º 1
0
 public Object result(Object s, Action a)
 {
     if (a is QueenAction)
     {
         QueenAction  qa       = (QueenAction)a;
         NQueensBoard board    = (NQueensBoard)s;
         NQueensBoard newBoard = new NQueensBoard(board.getSize());
         newBoard.setBoard(board.getQueenPositions());
         if (qa.getName() == QueenAction.PLACE_QUEEN)
         {
             newBoard.AddQueenAt(qa.getLocation());
         }
         else if (qa.getName() == QueenAction.REMOVE_QUEEN)
         {
             newBoard.removeQueenFrom(qa.getLocation());
         }
         else if (qa.getName() == QueenAction.MOVE_QUEEN)
         {
             newBoard.moveQueenTo(qa.getLocation());
         }
         s = newBoard;
     }
     // if action is not understood or is a NoOp
     // the result will be the current state.
     return(s);
 }
Exemplo n.º 2
0
 public Object result(Object s, Action a)
 {
     if (a is QueenAction)
     {
         QueenAction qa = (QueenAction)a;
         NQueensBoard board = (NQueensBoard)s;
         NQueensBoard newBoard = new NQueensBoard(board.getSize());
         newBoard.setBoard(board.getQueenPositions());
         if (qa.getName() == QueenAction.PLACE_QUEEN)
             newBoard.AddQueenAt(qa.getLocation());
         else if (qa.getName() == QueenAction.REMOVE_QUEEN)
             newBoard.removeQueenFrom(qa.getLocation());
         else if (qa.getName() == QueenAction.MOVE_QUEEN)
             newBoard.moveQueenTo(qa.getLocation());
         s = newBoard;
     }
     // if action is not understood or is a NoOp
     // the result will be the current state.
     return s;
 }