public Move makeMove(int yStart, int xStart, int yEnd, int xEnd) { Piece start = board.getCellContents(yStart, xStart); Piece end = board.getCellContents(yEnd, xEnd); if (start == null) //there is no piece here { throw new CellEmptyException(); } if (end != null) { throw new CellFullException(); } if (start.getColor() != whoseMove()) { throw new PieceWrongColorException(); } PieceType originalPieceType = start.getType(); System.Diagnostics.Debug.WriteLine("makeMove called"); Move myMove = getMove(start, yEnd, xEnd, this.whoseMove()); doMove(myMove); successMoves.Add(new MoveAttempt(yStart, xStart, yEnd, xEnd)); movesMade.Add(myMove); Piece add = myMove.getAdditions()[0]; if (originalPieceType != add.getType()) { lastAdvantage = turnNumber; } if (myMove.getRemovals().Count > 1) //that means a piece has been taken { lastAdvantage = turnNumber; } if (originalPieceType == add.getType() && myMove.getRemovals().Count == 2 && getDoableJumps(add).Count != 0) { this.multiJumpLoc = myMove.getAdditions()[0].getCoordinates(); //don't change turnNumber } else { this.turnNumber++; this.multiJumpLoc = null; } this.moveNumber++; //getOptimizedHeuristic(0, 3, new GameLogic(this)); return(myMove); }
private static void handleMove(Move move) { List <Piece> added = move.getAdditions(); List <Piece> removed = move.getRemovals(); foreach (Piece p in removed) { Vector co = p.getCoordinates(); delete(co.getX(), co.getY()); } foreach (Piece p in added) { Vector co = p.getCoordinates(); int col = co.getX(); int row = co.getY(); Checker c = new Checker(col, row, p.getColor() == PieceColor.BLACK ? DarkGrey : Colors.Red, p.getColor() == PieceColor.BLACK ? Colors.Black : DarkRed); spaces[col, row].setChecker(c); mainCanvas.Children.Add(spaces[col, row].getChecker().getEl2()); mainCanvas.Children.Add(spaces[col, row].getChecker().getEl1()); mainCanvas.Children.Add(spaces[col, row].getChecker().getCrown()); if (p.getType() == PieceType.KING) { c.king(); } } }
private void doMove(Move move) { lastPlayer = move.getPlayer(); foreach (Piece removal in move.getRemovals()) { removePiece(removal); } foreach (Piece addition in move.getAdditions()) { addPiece(addition); } }
private static void handleMove(Move move) { List<Piece> added = move.getAdditions(); List<Piece> removed = move.getRemovals(); foreach (Piece p in removed) { Vector co = p.getCoordinates(); delete(co.getX(), co.getY()); } foreach (Piece p in added) { Vector co = p.getCoordinates(); int col = co.getX(); int row = co.getY(); Checker c = new Checker(col, row, p.getColor() == PieceColor.BLACK ? DarkGrey : Colors.Red, p.getColor() == PieceColor.BLACK ? Colors.Black : DarkRed); spaces[col, row].setChecker(c); mainCanvas.Children.Add(spaces[col, row].getChecker().getEl2()); mainCanvas.Children.Add(spaces[col, row].getChecker().getEl1()); mainCanvas.Children.Add(spaces[col, row].getChecker().getCrown()); if (p.getType() == PieceType.KING) c.king(); } }
private void doMove(Move move) { movesMade.Add(move); foreach (Piece removal in move.getRemovals()) { removePiece(removal); } foreach (Piece addition in move.getAdditions()) { addPiece(addition); } }