public void removeQueenFrom(XYLocation l) { if (board[l.getXCoOrdinate(), l.getYCoOrdinate()] == 1) { board[l.getXCoOrdinate(), l.getYCoOrdinate()] = 0; } }
public void removeQueenFrom(XYLocation l) { if (squares[l.getXCoOrdinate()][l.getYCoOrdinate()] == 1) { squares[l.getXCoOrdinate()][l.getYCoOrdinate()] = 0; } }
/** * Moves the queen in the specified column (x-value of <code>l</code>) to * the specified row (y-value of <code>l</code>). The action assumes a * complete-state formulation of the n-queens problem. * * @param l */ public void moveQueenTo(XYLocation l) { for (int i = 0; i < size; i++) { squares[l.getXCoOrdinate()][i] = 0; } squares[l.getXCoOrdinate()][l.getYCoOrdinate()] = 1; }
private bool isLegalPlace(XYLocation forPlace) { if (forPlace.getXCoOrdinate() >= 0 && forPlace.getXCoOrdinate() < this.boardSize && forPlace.getYCoOrdinate() >= 0 && forPlace.getYCoOrdinate() < this.boardSize) { return(true); } else { return(false); } }
public void testXYLocationAtributeSettingOnConstruction() { XYLocation loc = new XYLocation(3, 4); Assert.AreEqual(3, loc.getXCoOrdinate()); Assert.AreEqual(4, loc.getYCoOrdinate()); }
public void mark(XYLocation loc, string symbol) { string[] _whichRow = null; _whichRow = whichRow(loc.getYCoOrdinate()); _whichRow[loc.getXCoOrdinate()] = symbol; }
public void addQueenAt(XYLocation l) { if (!(queenExistsAt(l))) { squares[l.getXCoOrdinate()][l.getYCoOrdinate()] = 1; } }
public void addQueenAt(XYLocation l) { if (!(queenExistsAt(l))) { board[l.getXCoOrdinate(), l.getYCoOrdinate()] = 1; } }
public static int calculateSquareOfDistanceBetweenLocations( XYLocation loc1, XYLocation loc2) { int xdifference = loc1.getXCoOrdinate() - loc2.getXCoOrdinate(); int ydifference = loc1.getYCoOrdinate() - loc2.getYCoOrdinate(); return((xdifference * xdifference) + (ydifference * ydifference)); }
public int getNumberOfAttacksOn(XYLocation l) { int x = l.getXCoOrdinate(); int y = l.getYCoOrdinate(); return(numberOfHorizontalAttacksOn(x, y) + numberOfVerticalAttacksOn(x, y) + numberOfDiagonalAttacksOn(x, y)); }
public bool isSquareUnderAttack(XYLocation l) { int x = l.getXCoOrdinate(); int y = l.getYCoOrdinate(); return(isSquareHorizontallyAttacked(x, y) || isSquareVerticallyAttacked(x, y) || isSquareDiagonallyAttacked( x, y)); }
public void setBoard(List <XYLocation> locs) { int count = 0; for (int i = 0; i < locs.Capacity; i++) { XYLocation loc = locs[i]; this.setValue(loc.getXCoOrdinate(), loc.getYCoOrdinate(), count); count = count + 1; } }
public void setBoard(ArrayList locs) { int count = 0; for (int i = 0; i < locs.Count; i++) { XYLocation loc = (XYLocation)locs[i]; this.setValue(loc.getXCoOrdinate(), loc.getYCoOrdinate(), count); count = count + 1; } }
// // PRIVATE METHODS // private bool withinRadius(int radius, XYLocation agentLocation, XYLocation objectLocation) { int xdifference = agentLocation.getXCoOrdinate() - objectLocation.getXCoOrdinate(); int ydifference = agentLocation.getYCoOrdinate() - objectLocation.getYCoOrdinate(); return(Math.sqrt((xdifference * xdifference) + (ydifference * ydifference)) <= radius); }
public void printPossibleMoves() { System.Console.WriteLine("Possible moves"); List moves = getMoves(presentState); for (int i = 0; i < moves.Count; i++) { XYLocation moveLoc = (XYLocation)moves.get(i); GameState newState = getMove(presentState, moveLoc.getXCoOrdinate(), moveLoc.getYCoOrdinate()); TicTacToeBoard board = (TicTacToeBoard)newState.get("board"); System.Console.WriteLine("utility = " + computeUtility(newState)); System.Console.WriteLine(""); } }
public int evaluateManhattanDistanceOf(int i, XYLocation loc) { int retVal = -1; int xpos = loc.getXCoOrdinate(); int ypos = loc.getYCoOrdinate(); switch (i) { case 1: retVal = Math.Abs(xpos - 0) + Math.Abs(ypos - 1); break; case 2: retVal = Math.Abs(xpos - 0) + Math.Abs(ypos - 2); break; case 3: retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 0); break; case 4: retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 1); break; case 5: retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 2); break; case 6: retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 0); break; case 7: retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 1); break; case 8: retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 2); break; } return(retVal); }
private bool isPlayer(string whichPlayer, XYLocation loc) { string[] _whichRow = whichRow(loc.getYCoOrdinate()); return(_whichRow[loc.getXCoOrdinate()].Equals(whichPlayer)); }
public bool queenExistsAt(XYLocation l) { return(queenExistsAt(l.getXCoOrdinate(), l.getYCoOrdinate())); }
private string whichPlayer(XYLocation loc) { string[] _whichRow = whichRow(loc.getYCoOrdinate()); return(_whichRow[loc.getXCoOrdinate()]); }
private bool isEmpty(XYLocation loc) { string[] _whichRow = whichRow(loc.getYCoOrdinate()); return(_whichRow[loc.getXCoOrdinate()] == " "); }
public int getValueAt(XYLocation loc) { return(getValueAt(loc.getXCoOrdinate(), loc.getYCoOrdinate())); }
public override GameState makeMove(GameState state, Object o) { XYLocation loc = (XYLocation)o; return(makeMove(state, loc.getXCoOrdinate(), loc.getYCoOrdinate())); }