private void btnPlay_Click(object sender, EventArgs e) { //load piece on Board Chess tempChess; //pawn for (int i = 0; i < 16; i++) { tempChess = new Pawn(); if (i < 8) { tempChess.Team = (int)ColorTeam.Black; Board[1, i].Chess = tempChess; Board[1, i].Image = Image.FromFile(linkBlackPawn); Board[1, i].Chess.Evaluation = -10; } else { tempChess.Team = (int)ColorTeam.White; Board[6, i - 8].Chess = tempChess; Board[6, i - 8].Image = Image.FromFile(linkWhitePawn); Board[6, i - 8].Chess.Evaluation = 10; } } //Castle for (int i = 0; i < 4; i++) { tempChess = new Castle(); if (i < 2) { tempChess.Team = (int)ColorTeam.Black; Board[0, 0].Chess = tempChess; Board[0, 7].Chess = tempChess; Board[0, 0].Image = Image.FromFile(linkBlackCastle); Board[0, 7].Image = Image.FromFile(linkBlackCastle); Board[0, 0].Chess.Evaluation = -50; Board[0, 7].Chess.Evaluation = -50; } else { tempChess.Team = (int)ColorTeam.White; Board[7, 0].Chess = tempChess; Board[7, 7].Chess = tempChess; Board[7, 0].Image = Image.FromFile(linkWhiteCastle); Board[7, 7].Image = Image.FromFile(linkWhiteCastle); Board[7, 0].Chess.Evaluation = 50; Board[7, 7].Chess.Evaluation = 50; } } //Knight for (int i = 0; i < 4; i++) { tempChess = new Knight(); if (i < 2) { tempChess.Team = (int)ColorTeam.Black; Board[0, 1].Chess = tempChess; Board[0, 6].Chess = tempChess; Board[0, 1].Image = Image.FromFile(linkBlackKnight); Board[0, 6].Image = Image.FromFile(linkBlackKnight); Board[0, 1].Chess.Evaluation = -30; Board[0, 6].Chess.Evaluation = -30; } else { tempChess.Team = (int)ColorTeam.White; Board[7, 1].Chess = tempChess; Board[7, 6].Chess = tempChess; Board[7, 1].Image = Image.FromFile(linkWhiteKnight); Board[7, 6].Image = Image.FromFile(linkWhiteKnight); Board[7, 1].Chess.Evaluation = 30; Board[7, 6].Chess.Evaluation = 30; } } //Bishop for (int i = 0; i < 4; i++) { tempChess = new Bishop(); if (i < 2) { tempChess.Team = (int)ColorTeam.Black; Board[0, 2].Chess = tempChess; Board[0, 5].Chess = tempChess; Board[0, 2].Image = Image.FromFile(linkBlackBishop); Board[0, 5].Image = Image.FromFile(linkBlackBishop); Board[0, 2].Chess.Evaluation = -30; Board[0, 5].Chess.Evaluation = -30; } else { tempChess.Team = (int)ColorTeam.White; Board[7, 2].Chess = tempChess; Board[7, 5].Chess = tempChess; Board[7, 2].Image = Image.FromFile(linkWhiteBishop); Board[7, 5].Image = Image.FromFile(linkWhiteBishop); Board[7, 2].Chess.Evaluation = 30; Board[7, 5].Chess.Evaluation = 30; } } //Queen tempChess = new Queen(); tempChess.Team = (int)ColorTeam.Black; Board[0, 3].Chess = tempChess; Board[0, 3].Image = Image.FromFile(linkBlackQueen); Board[0, 3].Chess.Evaluation = -90; tempChess = new Queen(); tempChess.Team = (int)ColorTeam.White; Board[7, 3].Chess = tempChess; Board[7, 3].Image = Image.FromFile(linkWhiteQueen); Board[7, 3].Chess.Evaluation = 90; //King tempChess = new King(); tempChess.Team = (int)ColorTeam.Black; Board[0, 4].Chess = tempChess; Board[0, 4].Image = Image.FromFile(linkBlackKing); Board[0, 4].Chess.Evaluation = -900; tempChess = new King(); tempChess.Team = (int)ColorTeam.White; Board[7, 4].Chess = tempChess; Board[7, 4].Image = Image.FromFile(linkWhiteKing); Board[7, 4].Chess.Evaluation = 900; Common.Board = Board; }
private void Display() { Chess tempChess; Constants.SetDefaultChessLocation(); Constants.SetDefualtEvaluation(); //pawn for (int i = 0; i < 16; i++) { tempChess = new Pawn(); if (i < 8) { tempChess.Team = (int)ColorTeam.Black; Board[Constants.rowBlackPawnDefault, i].Chess = tempChess; Board[Constants.rowBlackPawnDefault, i].Image = Image.FromFile(Constants.linkBlackPawn); Board[Constants.rowBlackPawnDefault, i].Chess.Evaluation = Constants.blackPawnEvaluation; } else { tempChess.Team = (int)ColorTeam.White; Board[Constants.rowWhitePawnDefault, i - 8].Chess = tempChess; Board[Constants.rowWhitePawnDefault, i - 8].Image = Image.FromFile(Constants.linkWhitePawn); Board[Constants.rowWhitePawnDefault, i - 8].Chess.Evaluation = Constants.whitePawnEvaluation; } } //Castle for (int i = 0; i < 4; i++) { tempChess = new Castle(); if (i < 2) { tempChess.Team = (int)ColorTeam.Black; Board[Constants.rowBlackChessDefault, 0].Chess = tempChess; Board[Constants.rowBlackChessDefault, 7].Chess = tempChess; Board[Constants.rowBlackChessDefault, 0].Image = Image.FromFile(Constants.linkBlackCastle); Board[Constants.rowBlackChessDefault, 7].Image = Image.FromFile(Constants.linkBlackCastle); Board[Constants.rowBlackChessDefault, 0].Chess.Evaluation = Constants.blackCastleEvaluation; Board[Constants.rowBlackChessDefault, 7].Chess.Evaluation = Constants.blackCastleEvaluation; } else { tempChess.Team = (int)ColorTeam.White; Board[Constants.rowWhiteChessDefault, 0].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 7].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 0].Image = Image.FromFile(Constants.linkWhiteCastle); Board[Constants.rowWhiteChessDefault, 7].Image = Image.FromFile(Constants.linkWhiteCastle); Board[Constants.rowWhiteChessDefault, 0].Chess.Evaluation = Constants.whiteCastleEvaluation; Board[Constants.rowWhiteChessDefault, 7].Chess.Evaluation = Constants.whiteCastleEvaluation; } } //Knight for (int i = 0; i < 4; i++) { tempChess = new Knight(); if (i < 2) { tempChess.Team = (int)ColorTeam.Black; Board[Constants.rowBlackChessDefault, 1].Chess = tempChess; Board[Constants.rowBlackChessDefault, 6].Chess = tempChess; Board[Constants.rowBlackChessDefault, 1].Image = Image.FromFile(Constants.linkBlackKnight); Board[Constants.rowBlackChessDefault, 6].Image = Image.FromFile(Constants.linkBlackKnight); Board[Constants.rowBlackChessDefault, 1].Chess.Evaluation = Constants.blackKnightEvaluation; Board[Constants.rowBlackChessDefault, 6].Chess.Evaluation = Constants.blackKnightEvaluation; } else { tempChess.Team = (int)ColorTeam.White; Board[Constants.rowWhiteChessDefault, 1].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 6].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 1].Image = Image.FromFile(Constants.linkWhiteKnight); Board[Constants.rowWhiteChessDefault, 6].Image = Image.FromFile(Constants.linkWhiteKnight); Board[Constants.rowWhiteChessDefault, 1].Chess.Evaluation = Constants.whiteKnightEvaluation; Board[Constants.rowWhiteChessDefault, 6].Chess.Evaluation = Constants.whiteKnightEvaluation; } } //Bishop for (int i = 0; i < 4; i++) { tempChess = new Bishop(); if (i < 2) { tempChess.Team = (int)ColorTeam.Black; Board[Constants.rowBlackChessDefault, 2].Chess = tempChess; Board[Constants.rowBlackChessDefault, 5].Chess = tempChess; Board[Constants.rowBlackChessDefault, 2].Image = Image.FromFile(Constants.linkBlackBishop); Board[Constants.rowBlackChessDefault, 5].Image = Image.FromFile(Constants.linkBlackBishop); Board[Constants.rowBlackChessDefault, 2].Chess.Evaluation = Constants.blackBishopEvaluation; Board[Constants.rowBlackChessDefault, 5].Chess.Evaluation = Constants.blackBishopEvaluation; } else { tempChess.Team = (int)ColorTeam.White; Board[Constants.rowWhiteChessDefault, 2].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 5].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 2].Image = Image.FromFile(Constants.linkWhiteBishop); Board[Constants.rowWhiteChessDefault, 5].Image = Image.FromFile(Constants.linkWhiteBishop); Board[Constants.rowWhiteChessDefault, 2].Chess.Evaluation = Constants.whiteBishopEvaluation; Board[Constants.rowWhiteChessDefault, 5].Chess.Evaluation = Constants.whiteBishopEvaluation; } } //Queen tempChess = new Queen(); tempChess.Team = (int)ColorTeam.Black; Board[Constants.rowBlackChessDefault, 3].Chess = tempChess; Board[Constants.rowBlackChessDefault, 3].Image = Image.FromFile(Constants.linkBlackQueen); Board[Constants.rowBlackChessDefault, 3].Chess.Evaluation = Constants.blackQueenEvaluation; tempChess = new Queen(); tempChess.Team = (int)ColorTeam.White; Board[Constants.rowWhiteChessDefault, 3].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 3].Image = Image.FromFile(Constants.linkWhiteQueen); Board[Constants.rowWhiteChessDefault, 3].Chess.Evaluation = Constants.whiteQueenEvaluation; //King tempChess = new King(); tempChess.Team = (int)ColorTeam.Black; Board[Constants.rowBlackChessDefault, 4].Chess = tempChess; Board[Constants.rowBlackChessDefault, 4].Image = Image.FromFile(Constants.linkBlackKing); Board[Constants.rowBlackChessDefault, 4].Chess.Evaluation = Constants.blackKingEvaluation; tempChess = new King(); tempChess.Team = (int)ColorTeam.White; Board[Constants.rowWhiteChessDefault, 4].Chess = tempChess; Board[Constants.rowWhiteChessDefault, 4].Image = Image.FromFile(Constants.linkWhiteKing); Board[Constants.rowWhiteChessDefault, 4].Chess.Evaluation = Constants.whiteKingEvaluation; Common.Board = Board; }