AIMA.Core.Environment.NQueens.QueenAction.getLocation C# (CSharp) Method

getLocation() public method

public getLocation ( ) : XYLocation
return AIMA.Core.Util.DataStructure.XYLocation
        public XYLocation getLocation()
        {
            return (XYLocation)getAttribute(ATTRIBUTE_QUEEN_LOC);
        }

Usage Example

 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);
 }