//Retursn number of pieces left for a player private static int getSimpleEval(Board board, Piece.Type type) { int numPieceForPlayer = 0; int numPieceForOpp = 0; List <Piece> boardPieces = new List <Piece>(); foreach (Piece p in FindObjectsOfType <Piece>()) { if (p.cell.mainBoard == board) { boardPieces.Add(p); } } foreach (Piece p in boardPieces) { if (p.type == type && p.isActive) { numPieceForPlayer++; if (p.isKing) { numPieceForPlayer++; } } else if (p.type != type && p.isActive) { numPieceForOpp++; if (p.isKing) { numPieceForOpp++; } } } board.thisHeurusic = numPieceForPlayer - numPieceForOpp; return(numPieceForPlayer - numPieceForOpp); }
public static Block Create(KeyValuePair <string, char[, ]> blueprint) { Block block = (new GameObject()).AddComponent <Block>() as Block; block.name = blueprint.Key; Piece.Type[,] pieces = ConvertBlueprintToBlock(blueprint.Value); Vector3 size = new Vector3((float)(pieces.GetLength(0)), (float)(pieces.GetLength(1)), 1.0f); Vector3 positionOffset = size / 2.0f - Vector3.one / 2.0f; for (int i = 0; i < pieces.GetLength(0); ++i) { for (int j = 0; j < pieces.GetLength(1); ++j) { Piece.Type pieceType = pieces[i, j]; if (pieceType == Piece.Type.EMPTY) { continue; } block.AddPiece(new Vector3(i, j, 0) - positionOffset, pieceType); } } block.SetCollider(size); block.InitRenderables(); return(block); }
public Piece ChoosePiece(int pieceNumber, Player player)//piecenumber is from the for loop, player is from player(Player.A,Player.B) { //STUB Piece.Type type = ChooseType(); return(new Piece(player.ToString() + pieceNumber, player, type)); }
private static void AssignCellType(ref Piece.Type cell, Piece.Type target) { if (target > cell) { cell = target; } }
private bool checkEnemyType(Piece.Type type, int direction, int distance) { if (type == Piece.Type.BISHOP && (direction == FORWARD_LEFT || direction == FORWARD_RIGHT || direction == BACKWARD_LEFT || direction == BACKWARD_RIGHT)) { return(true); } else if (type == Piece.Type.PAWN && (direction == FORWARD_LEFT || direction == FORWARD_RIGHT) && distance == 1) { return(true); } else if (type == Piece.Type.QUEEN) { return(true); } else if (type == Piece.Type.ROOK && (direction == FORWARD || direction == BACKWARD || direction == LEFT || direction == RIGHT)) { return(true); } return(false); }
/// <summary>Places a piece on the board</summary> /// <param name="type">Type of piece to be placed</param> /// <param name="team">Team to assign the piece</param> /// <param name="location">Location to place the piece</param> /// <returns>Returns whether a piece could be placed<returns> public static bool Place(Piece.Type type, Team team, string location) { GameObject plane = null; //Only place if a tile exists and there is no piece on the location if ((plane = board.GetPlane(location)) && !board.GetPiece(location)) { //Get appropriate prefab and create instance GameObject prefab = Piece.GetPrefab(type); GameObject pieceObject = Instantiate(prefab); pieceObject.name = prefab.name; //Add piece component Piece piece = pieceObject.AddComponent <Piece>(); piece.type = type; piece.team = team; piece.heading = team == Team.WHITE ? Direction.Down : Direction.Up; piece.timesMoved = 0; piece.color = piece.color; //Getting the piece's color always returns color based on team while setting can make it any color piece.SetTransformParent(plane.transform); //Cache King piece if (type == Piece.Type.KING) { instance.kings[team] = piece; } return(true); } return(false); }
private bool handleEventCastle(int index_1, int index_2) { Piece.Team team_index_2 = this.pieces [index_1].team; Piece.Type type_index_2 = this.pieces [index_1].type; this.pieces [index_1].team = this.pieces [index_2].team; this.pieces [index_1].type = this.pieces [index_2].type; this.pieces [index_2].team = team_index_2; this.pieces [index_2].type = type_index_2; return(true); }
public void SetSprite(Piece.PlayerColor color, Piece.Type type) { if (color == Piece.PlayerColor.WHITE) { SetSprite(_whiteSprites, type.ToString()); } else { SetSprite(_blackSprites, type.ToString()); } }
public bool hasColision(Piece.Type type) { bool result = false; Piece next_position = board.NextPiece(direction, GetHead()); if (next_position.GetType().Equals(type)) { result = true; } return(result); }
/// <summary>Promotes a piece into a different type</summary> /// <param name="piece">Piece to be promoted</param> /// <param name="type">Type to be promoted into</param> public static void Promote(Piece piece, Piece.Type type, bool record = true) { //Get the piece's location and team string location = piece.GetLocation(); Team team = piece.team; if (record) { AddToRecord("P:" + location + "," + piece.type + "," + type); } //Destroy the piece Remove(piece); //Place a new piece with the promoted type on the same team at the same location Place(type, team, location); }
private static Piece.Type[,] ConvertBlueprintToBlock(char[,] blueprint) { if (blueprint.Rank != 2) { throw new System.ArgumentException("Input structure is not 2-dimensions."); } if (blueprint.GetLength(0) == 0 || blueprint.GetLength(1) == 0) { throw new System.ArgumentException("Input structure is empty."); } Piece.Type[,] block = new Piece.Type[blueprint.GetLength(0) + 2, blueprint.GetLength(1) + 2]; // Set the all the blueprints onto the block. for (int i = 0; i < blueprint.GetLength(0); ++i) { for (int j = 0; j < blueprint.GetLength(1); ++j) { if (blueprint[i, j] == O) { continue; } AssignCellType(ref block[i + 0, j + 0], Piece.Type.OUTLINE_CORNER); AssignCellType(ref block[i + 1, j + 0], Piece.Type.OUTLINE_SIDE); AssignCellType(ref block[i + 2, j + 0], Piece.Type.OUTLINE_CORNER); AssignCellType(ref block[i + 0, j + 1], Piece.Type.OUTLINE_SIDE); AssignCellType(ref block[i + 1, j + 1], Piece.Type.BLOCK); AssignCellType(ref block[i + 2, j + 1], Piece.Type.OUTLINE_SIDE); AssignCellType(ref block[i + 0, j + 2], Piece.Type.OUTLINE_CORNER); AssignCellType(ref block[i + 1, j + 2], Piece.Type.OUTLINE_SIDE); AssignCellType(ref block[i + 2, j + 2], Piece.Type.OUTLINE_CORNER); } } return(block); }
public void AddPiece(Vector3 position, Piece.Type type) { Piece piece = CreatePiece(position); piece.m_type = type; switch (type) { case Piece.Type.BLOCK: m_blocks.Add(piece); break; case Piece.Type.OUTLINE_SIDE: m_sides.Add(piece); break; case Piece.Type.OUTLINE_CORNER: m_corners.Add(piece); break; case Piece.Type.EMPTY: default: break; } }
/// <summary>Undoes the last recorded play</summary> public static void Undo() { if (instance.record.Count > 0) { string lastPlay = instance.record.Pop(); string[] playType = lastPlay.Split(':'); switch (playType[0]) { case "M": //Move { string[] data = playType[1].Split(','); //Get the piece at its current position and set it to its previous position Piece piece = board.GetPiece(data[1]); piece.SetTransformParent(board.GetPlane(data[0]).transform); //Reverse the amount of times moved piece.timesMoved--; } break; case "C": //Capture { string[] data = playType[1].Split(','); string oldLocation = data[0]; string location = data[1]; Piece.Type enemyType = (Piece.Type)Enum.Parse(typeof(Piece.Type), data[2]); Team enemyTeam = (Team)Enum.Parse(typeof(Team), data[3]); //Get the piece at its current position and set it to its previous position Piece piece = board.GetPiece(location); piece.SetTransformParent(board.GetPlane(oldLocation).transform); //Reverse the amount of times moved piece.timesMoved--; //Put the captured piece back Place(enemyType, enemyTeam, location); } break; case "S": //Swap Swap(playType[1], false); break; case "P": //Promote { string[] data = playType[1].Split(','); string location = data[0]; Piece piece = board.GetPiece(location); Team team = piece.team; Piece.Type type = (Piece.Type)Enum.Parse(typeof(Piece.Type), data[1]); int timesMoved = piece.timesMoved; //Remove the promoted piece Remove(piece); //Place the old piece Place(type, team, location); //Copy the times moved over to the unpromoted piece board.GetPiece(location).timesMoved = timesMoved; } break; default: break; } } else { Debug.Log("Unable to undo further"); } }
public virtual ulong Apply(Board b, ulong hash = 0) { typePriorToApply = b.pieces [x, y].type; b.pieces [targetX, targetY].color = b.pieces [x, y].color; b.pieces [targetX, targetY].type = b.pieces [x, y].type; if (targetY == (b.pieces [targetX, targetY].color == Color.White ? 9 : 0)) b.pieces [targetX, targetY].type = Piece.Type.Dam; // update hash hash ^= AI.zobristPieceMask[ToHumanReadablePos(x, y) - 1, b.pieces [x, y].HashCode]; hash ^= AI.zobristPieceMask[ToHumanReadablePos(targetX, targetY) - 1, b.pieces [targetX, targetY].HashCode]; b.pieces [x, y].color = Color.None; return hash; }
private void imgQueen_MouseDown(object sender, MouseButtonEventArgs e) { promoteTo = Piece.Type.Queen; this.Close(); }
private void imgBishop_MouseDown(object sender, MouseButtonEventArgs e) { promoteTo = Piece.Type.Bishop; this.Close(); }
private void imgKnight_MouseDown(object sender, MouseButtonEventArgs e) { promoteTo = Piece.Type.Knight; this.Close(); }
private void MouseDownHandler(object sender, MouseButtonEventArgs e) { int col = Grid.GetColumn((Image)sender); int row = Grid.GetRow((Image)sender); List<int[]> moveable = new List<int[]>(); List<int[]> threatened = new List<int[]>(); List<int[]> enPassant = new List<int[]>(); bool promote = false; cvm.SelectOrMove(row, col, moveable, threatened, enPassant, ref promote); if (promote) { Piece.Type promoteTo = new Piece.Type(); while (promoteTo == Piece.Type.Empty) { Promotion promo = new Promotion(row, ref promoteTo); promo.ShowDialog(); promoteTo = promo.PromoteTo(); } mf.Promote(promoteTo, row, col, cvm.Playfield); } drawPieces(); //draw borders for moveable squares foreach (int[] pair in moveable) drawBorder(pair[0], pair[1], "yellow"); foreach (int[] pair in threatened) //only show red if there's a piece to take if (cvm.Playfield[pair[0], pair[1]].Exists && cvm.Highlight.Contains(pair)) drawBorder(pair[0], pair[1], "red"); foreach (int[] pair in enPassant) drawBorder(pair[0], pair[1], "red"); }
//Get all valid moves for a given piece public List <Move> getAllValidMoves(Piece.Type type) { List <Move> validMoves = new List <Move>(); Piece[] pieces = FindObjectsOfType <Piece>(); List <Piece> boardPieces = new List <Piece>(); foreach (Piece p in pieces) { if (p.cell.mainBoard == GetComponent <Board>()) { boardPieces.Add(p); } } bool canEat = false; foreach (Piece piece in boardPieces) { //Right colour if (piece.isActive && piece.type == type) { //Moving down if (piece.type == Piece.Type.black && !piece.isKing) { //Check if cell is occupied BL if (piece.cell.bottomLeft != null) { if (!(piece.cell.bottomLeft.piece == null)) { if (piece.cell.bottomLeft.bottomLeft != null && piece.cell.bottomLeft.piece.type != piece.type) { //Occupied so check if resultant cell is empty so can eat if (piece.cell.bottomLeft.bottomLeft.piece == null) { Move move = new Move(piece, piece.cell.bottomLeft.bottomLeft, piece.cell.bottomLeft.piece); validMoves.Add(move); canEat = true; } } } //Not occupied so can move else { Move move = new Move(piece, piece.cell.bottomLeft); validMoves.Add(move); } } //Check if cell is occupied BR if (piece.cell.bottomRight != null) { if (!(piece.cell.bottomRight.piece == null)) { if (piece.cell.bottomRight.bottomRight != null && piece.cell.bottomRight.piece.type != piece.type) { if (piece.cell.bottomRight.bottomRight.piece == null) { Move move = new Move(piece, piece.cell.bottomRight.bottomRight, piece.cell.bottomRight.piece); validMoves.Add(move); canEat = true; } } } else { Move move2 = new Move(piece, piece.cell.bottomRight); validMoves.Add(move2); } } } //Moving up else if (piece.type == Piece.Type.white && !piece.isKing) { if (piece.cell.topLeft != null) { if (!(piece.cell.topLeft.piece == null)) { if (piece.cell.topLeft.topLeft != null && piece.cell.topLeft.piece.type != piece.type) { //Occupied so check if resultant cell is empty so can eat if (piece.cell.topLeft.topLeft.piece == null) { Move move = new Move(piece, piece.cell.topLeft.topLeft, piece.cell.topLeft.piece); validMoves.Add(move); canEat = true; } } } //Not occupied so can move else { Move move = new Move(piece, piece.cell.topLeft); validMoves.Add(move); } } //Check if cell is occupied TR if (piece.cell.topRight != null) { if (!(piece.cell.topRight.piece == null)) { if (piece.cell.topRight.topRight != null && piece.cell.topRight.piece.type != piece.type) { if (piece.cell.topRight.topRight.piece == null) { Move move = new Move(piece, piece.cell.topRight.topRight, piece.cell.topRight.piece); validMoves.Add(move); canEat = true; } } } else { Move move2 = new Move(piece, piece.cell.topRight); validMoves.Add(move2); } } } //King movement else if (piece.isKing) { if (piece.cell.topLeft != null) { if (!(piece.cell.topLeft.piece == null)) { if (piece.cell.topLeft.topLeft != null && piece.cell.topLeft.piece.type != piece.type) { //Occupied so check if resultant cell is empty so can eat if (piece.cell.topLeft.topLeft.piece == null) { Move move = new Move(piece, piece.cell.topLeft.topLeft, piece.cell.topLeft.piece); validMoves.Add(move); canEat = true; } } } //Not occupied so can move else { Move move = new Move(piece, piece.cell.topLeft); validMoves.Add(move); } } //Check if cell is occupied TR if (piece.cell.topRight != null) { if (!(piece.cell.topRight.piece == null)) { if (piece.cell.topRight.topRight != null && piece.cell.topRight.piece.type != piece.type) { if (piece.cell.topRight.topRight.piece == null) { Move move = new Move(piece, piece.cell.topRight.topRight, piece.cell.topRight.piece); validMoves.Add(move); canEat = true; } } } else { Move move2 = new Move(piece, piece.cell.topRight); validMoves.Add(move2); } } //Check if cell is occupied BL if (piece.cell.bottomLeft != null) { if (!(piece.cell.bottomLeft.piece == null)) { if (piece.cell.bottomLeft.bottomLeft != null && piece.cell.bottomLeft.piece.type != piece.type) { //Occupied so check if resultant cell is empty so can eat if (piece.cell.bottomLeft.bottomLeft.piece == null) { Move move = new Move(piece, piece.cell.bottomLeft.bottomLeft, piece.cell.bottomLeft.piece); validMoves.Add(move); canEat = true; } } } //Not occupied so can move else { Move move = new Move(piece, piece.cell.bottomLeft); validMoves.Add(move); } } //Check if cell is occupied BR if (piece.cell.bottomRight != null) { if (!(piece.cell.bottomRight.piece == null)) { if (piece.cell.bottomRight.bottomRight != null && piece.cell.bottomRight.piece.type != piece.type) { if (piece.cell.bottomRight.bottomRight.piece == null) { Move move = new Move(piece, piece.cell.bottomRight.bottomRight, piece.cell.bottomRight.piece); validMoves.Add(move); canEat = true; } } } else { Move move2 = new Move(piece, piece.cell.bottomRight); validMoves.Add(move2); } } } } } //Remove all other moves if can eat if (canEat) { validMoves.RemoveAll(m => m.getJumped() == null); } return(validMoves); }
public void setPieceType(Piece.Type type) { this.type = type; }
/// <summary>Uses the Event System to determine when a button is pressed and carry out the appropriate action</summary> /// <param name="id">ID of the button being pressed</param> public void OnClick(int id) { //Ensure buttons are at latest state UpdateButtonStatus(); switch (id) { case 0: //Play if (!GameManager.IsGameOngoing()) { Chessboard.Style style = Chessboard.Style.ANTIPODEAN; //Get the approiate mode switch (display.dropdownStyle.value) { case 0: display.buttonInvert.gameObject.SetActive(true); display.buttonPush.gameObject.SetActive(true); display.buttonPull.gameObject.SetActive(true); style = Chessboard.Style.ANTIPODEAN; break; case 1: display.buttonInvert.gameObject.SetActive(false); display.buttonPush.gameObject.SetActive(false); display.buttonPull.gameObject.SetActive(false); style = Chessboard.Style.SPHERE; break; default: break; } GameManager.SetGameOngoing(true); GameManager.board.Create(style); jail.Create(); } display.menuUI.SetActive(false); display.ingameUI.SetActive(true); break; case 1: //Options break; case 2: //Quit if (Application.isEditor) { GameManager.SetGameOngoing(false); GameManager.board.Clear(); jail.Clear(); } else { Application.Quit(); } break; case 3: //Invert if (display.buttonInvert.interactable) { GameManager.board.isInverted = !GameManager.board.isInverted; BoardAnimation.Inversion(); } break; case 4: //Toggle Names GameManager.board.ToggleTileNames(); break; case 5: //Show Score if (display.buttonShowScore.interactable) { bool jailVisibility = !jail.gameObject.activeSelf; GameManager.board.gameObject.SetActive(!jailVisibility); jail.SetVisible(jailVisibility); } break; case 6: //Push if (display.buttonPush.interactable && Rules.CanPush(selection.selectedPiece)) { //Decolor SetMovementPathsColor(selection.selectedPiece, null); SetAttackPathsColor(selection.selectedPiece, null); //Swap and deselect after animation completed BoardAnimation.onComplete = () => { GameManager.Swap(selection.selectedPiece.GetLocation()); selection.selectedPiece = null; //Use turn GameManager.NextTurn(); }; //Animate push BoardAnimation.PushOrPull(selection.selectedPiece.GetLocation()); } break; case 7: //Pull if (display.buttonPull.interactable && Rules.CanPull(selection.selectedPiece)) { //Decolor SetMovementPathsColor(selection.selectedPiece, null); SetAttackPathsColor(selection.selectedPiece, null); //Swap and deselect after animation completed BoardAnimation.onComplete = () => { GameManager.Swap(selection.selectedPiece.GetLocation()); selection.selectedPiece = null; //Use turn GameManager.NextTurn(); }; //Animate pull or swap Tile tile = selection.selectedPiece.GetTile(); if (tile.GetPiece() && tile.GetInversePiece() && ( (tile.GetPiece().type == Piece.Type.KING && tile.GetInversePiece().type == Piece.Type.QUEEN) || (tile.GetInversePiece().type == Piece.Type.KING && tile.GetPiece().type == Piece.Type.QUEEN)) ) { BoardAnimation.Swap(selection.selectedPiece.GetLocation()); } else { BoardAnimation.PushOrPull(selection.selectedPiece.GetLocation()); } } break; case 8: case 9: case 10: case 11: //Promotion Piece.Type type = Piece.Type.PAWN; //Get type based on button press if (id == 8) { type = Piece.Type.QUEEN; } else if (id == 9) { type = Piece.Type.KNIGHT; } else if (id == 10) { type = Piece.Type.ROOK; } else if (id == 11) { type = Piece.Type.BISHOP; } //Promopte the piece GameManager.Promote(selection.selectedPiece, type); //Change UI display.promotionUI.SetActive(false); display.ingameUI.SetActive(true); //Deselect and end the turn selection.selectedPiece = null; GameManager.NextTurn(); break; case 12: //Rules display.rulesUI.SetActive(true); break; case 13: //Close Rules display.rulesUI.SetActive(false); break; case 14: //Undo GameManager.Undo(); break; default: Debug.Log("Undefined interaction: " + id); break; } }
//Returns an evaluation based on the board state private static int getTacticalEval(Board board, Piece.Type type) { int evalFunc = 0; int evalFuncOpp = 0; int numKings = 0, numKingsOpp = 0, numNormal = 0, numNormalOpp = 0; List <Piece> boardPieces = new List <Piece>(); foreach (Piece p in FindObjectsOfType <Piece>()) { if (p.cell.mainBoard == board) { boardPieces.Add(p); } } //Get amount each side has foreach (Piece p in boardPieces) { if (p.isActive) { if (p.type == type && p.isKing) { numKings++; } else if (p.type == type && !p.isKing) { numNormal++; } else if (p.type != type && p.isKing) { numKingsOpp++; } else if (p.type != type && !p.isKing) { numNormalOpp++; } } } int numTotal = numNormal + numKings; int numTotalOpp = numNormalOpp + numKingsOpp; foreach (Piece p in boardPieces) { //TactialAI if (p.type == type && p.isActive) { //Nearing end game if ((numNormal == 0 && numNormalOpp == 0)) { foreach (Piece opp in boardPieces) { //Find first opponent king piece and reduce distance from them if (opp.type != type) #region eval { int rowDist = Mathf.Abs(opp.cell.row - p.cell.row); int colDist = Mathf.Abs(opp.cell.col - p.cell.col); int totalDist = colDist + rowDist; if (totalDist == 18) { evalFunc += 1; } else if (totalDist == 17) { evalFunc += 2; } else if (totalDist == 16) { evalFunc += 3; } else if (totalDist == 15) { evalFunc += 4; } else if (totalDist == 14) { evalFunc += 5; } else if (totalDist == 13) { evalFunc += 6; } else if (totalDist == 12) { evalFunc += 7; } else if (totalDist == 11) { evalFunc += 8; } else if (totalDist == 10) { evalFunc += 9; } else if (totalDist == 9) { evalFunc += 10; } else if (totalDist == 8) { evalFunc += 11; } else if (totalDist == 7) { evalFunc += 12; } else if (totalDist == 6) { evalFunc += 13; } else if (totalDist == 5) { evalFunc += 14; } else if (totalDist == 4) { evalFunc += 15; } else if (totalDist == 3) { evalFunc += 16; } else if (totalDist == 2) { evalFunc += 17; } else if (totalDist == 1) { evalFunc += 18; } break; } #endregion } } //Normal evaluation else { evalFunc += p.isKing ? 5 : 4; //The closer to being king the higher the evaluation if (!p.isKing) { switch (p.cell.col) { case 5: evalFunc += 1; break; case 6: evalFunc += 2; break; case 7: evalFunc += 3; break; } //Pieces on the edge have an advantage of not being able to be eaten evalFunc += p.cell.specialPosition == Cell.SpecialPosition.edge ? 1 : 0; } } } //Opponent else if (p.type != type && p.isActive) { //Nearing end game if ((numNormal == 0 && numNormalOpp == 0)) { foreach (Piece opp in boardPieces) { //Find first opponent king piece and reduce distance from them if (opp.type == type) { #region eval opp int rowDist = Mathf.Abs(opp.cell.row - p.cell.row); int colDist = Mathf.Abs(opp.cell.col - p.cell.col); int totalDist = colDist + rowDist; if (totalDist == 18) { evalFuncOpp += 1; } else if (totalDist == 17) { evalFuncOpp += 2; } else if (totalDist == 16) { evalFuncOpp += 3; } else if (totalDist == 15) { evalFuncOpp += 4; } else if (totalDist == 14) { evalFuncOpp += 5; } else if (totalDist == 13) { evalFuncOpp += 6; } else if (totalDist == 12) { evalFuncOpp += 7; } else if (totalDist == 11) { evalFuncOpp += 8; } else if (totalDist == 10) { evalFuncOpp += 9; } else if (totalDist == 9) { evalFuncOpp += 10; } else if (totalDist == 8) { evalFuncOpp += 11; } else if (totalDist == 7) { evalFuncOpp += 12; } else if (totalDist == 6) { evalFuncOpp += 13; } else if (totalDist == 5) { evalFuncOpp += 14; } else if (totalDist == 4) { evalFuncOpp += 15; } else if (totalDist == 3) { evalFuncOpp += 16; } else if (totalDist == 2) { evalFuncOpp += 17; } else if (totalDist == 1) { evalFuncOpp += 18; } break; #endregion } } } else { evalFuncOpp += p.isKing ? 5 : 4; //The closer to being king the higher the evaluation (black piece moves downwards) if (!p.isKing) { switch (p.cell.col) { case 4: evalFuncOpp += 1; break; case 3: evalFuncOpp += 2; break; case 2: evalFuncOpp += 3; break; } //Pieces on the edge have an advantage of not being able to be eaten evalFuncOpp += p.cell.specialPosition == Cell.SpecialPosition.edge ? 1 : 0; } } } } board.thisHeurusic = evalFunc - evalFuncOpp; return(evalFunc - evalFuncOpp); }
public void ClearPromotion() { p1PromoChoice = Piece.Type.PAWN; p2PromoChoice = Piece.Type.PAWN; selectedType = Piece.Type.PAWN; p1Promo = false; p2Promo = false; promotionPossible = false; }
void PromotionSelection() { int btnWidth = 120; int btnHeight = 40; if (GUI.Button(new Rect(10, 90, btnWidth, btnHeight), "Queen")) { selectedType = Piece.Type.QUEEN; } if (GUI.Button(new Rect(10, 130, btnWidth, btnHeight), "Knight")) { selectedType = Piece.Type.KNIGHT; } if (GUI.Button(new Rect(10, 170, btnWidth, btnHeight), "Rook")) { selectedType = Piece.Type.ROOK; } if (GUI.Button(new Rect(10, 210, btnWidth, btnHeight), "Bishop")) { selectedType = Piece.Type.BISHOP; Debug.Log("selected " + selectedType); } if (selectedType != Piece.Type.PAWN) { if (GUI.Button(new Rect(10, 250, btnWidth, btnHeight), "Confirm " + selectedType )) { Debug.Log("Selected a " + selectedType); if (whatPlayerAmI == 1) { p1PromoChoice = selectedType; } if (whatPlayerAmI == 2) { p2PromoChoice = selectedType; } promotionPossible = false; readyToMove = true; //Honestly Should probally just open confirm dialog here. } } }