本文整理汇总了C#中ChessColor类的典型用法代码示例。如果您正苦于以下问题:C# ChessColor类的具体用法?C# ChessColor怎么用?C# ChessColor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChessColor类属于命名空间,在下文中一共展示了ChessColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: miniMax
/// <summary>
/// Purpose: To perform the minimax algorithm to determine chess move
/// </summary>
/// <param name="boardState"></param>
/// <param name="color"></param>
/// <returns>char[] board to represent the move</returns>
///
public static char[] miniMax(char[] SRFen, ChessColor color)
{
TimeSpan maxTime = TimeSpan.FromMilliseconds(5500);
Char[] initialBoard = (char[])SRFen.Clone();
bool white;
int alpha = -10000;
int beta = 10000;
int cutoff = 4;
if (color == ChessColor.White) white = true;
else white = false;
int depth = 0;
Stopwatch timer = new Stopwatch();
timer.Start();
int h;
h = minValue(ref SRFen, depth + 1, white, alpha, beta, cutoff, ref timer);
if (h == -5000)
return SRFen;
char[] bestSoFar = (char[])SRFen.Clone();
while (timer.Elapsed < maxTime && h != -9999)
{
cutoff += 2;
char[] temp = (char[])initialBoard.Clone();
h = minValue(ref temp, depth + 1, white, alpha, beta, cutoff, bestSoFar, ref timer);
if (h != -9999) bestSoFar = (char[])temp.Clone();
if (h == -5000)
return bestSoFar;
}
//this.Log("cutoff" + cutoff);
return bestSoFar;
}
示例2: GetSimpleState
/// <summary>
/// Takes a board and color, and returns a simplified state where friend pieces are represented
/// by positive integers and always start on the same side of the board (0,0). Foe pieces are
/// represented as negative values
/// </summary>
/// <param name="board">The board to convert</param>
/// <param name="color">The color of the player (friend)</param>
/// <returns>A simplified representation of the current board</returns>
public static int[,] GetSimpleState(ChessBoard board, ChessColor color)
{
int[,] state = new int[Columns, Rows];
for (int col = 0; col < Columns; col++)
{
for (int row = 0; row < Rows; row++)
{
int stateRow = row;
int stateCol = col;
if (color == ChessColor.White)
{
stateRow = Rows - row - 1;
stateCol = Columns - col - 1;
}
ChessPiece piece = board[col, row];
int multiplier = 1;
if (color == ChessColor.White && piece < ChessPiece.Empty
|| color == ChessColor.Black && piece > ChessPiece.Empty)
multiplier = -1;
state[stateCol, stateRow] = multiplier * GamePieceToStatePiece[piece];
}
}
return state;
}
示例3: GetHeuristicValue
/// <summary>
/// Purpose: To calculate a heuristic value for the given board state
/// </summary>
/// <param name="boardState"></param>
/// <param name="color"></param>
/// <returns>integer representing the heuristic</returns>
public static int GetHeuristicValue(byte[] boardState, ChessColor color)
{
bool white = color == ChessColor.White;
int pH = GetPieceValueHeuristic(boardState, color);
int pS = FEN.GetPieceHazard(boardState, white);
return pH + pS;
}
示例4: Player
public Player(string name, ChessColor color)
{
// TODO: Validate name lenght
this.Name = name;
this.Color = color;
this.figures = new List<IFigure>();
}
示例5: GetPieceValueHeuristic
/// <summary>
/// Purpose: To calculate a heuristic based purely off piece value
/// </summary>
/// <param name="boardState"></param>
/// <param name="color"></param>
/// <returns></returns>
private static int GetPieceValueHeuristic(byte[] boardState, ChessColor color)
{
int whiteValue = 0;
int blackValue = 0;
for (int i = 0; i < boardState.Length; i++)
{
if (boardState[i] != FEN._)
{
if (boardState[i].IsUpper())
whiteValue += (pieceValues[boardState[i]] + GetPiecePositionValue(boardState[i], i));
else
blackValue += (pieceValues[boardState[i]] + GetPiecePositionValue(boardState[i], i));
}
}
//Log("WV -" + whiteValue.ToString());
//Log("BV -" + blackValue.ToString());
if (color == ChessColor.White)
{
if (whiteValue - 20000 < 1500)
{
lateGame = true;
}
return whiteValue - blackValue;
}
else
{
if (blackValue - 20000 < 1500)
{
lateGame = true;
}
return blackValue - whiteValue;
}
}
示例6: GetType
public static Piece GetType(string s, ChessColor color)
{
Piece p;
switch (s)
{
case "Bishop":
p = new Bishop(color);
break;
case "King":
p = new King(color);
break;
case "Knight":
p = new Knight(color);
break;
case "Pawn":
p = new Pawn(color);
break;
case "Queen":
p = new Queen(color);
break;
case "Rook":
p = new Rook(color);
break;
default:
throw new Exception("Piece unknown : " + s);
}
return p;
}
示例7: ChessSquare
public ChessSquare(int y, int x, ChessColor color)
{
Loc = new Location();
Loc.Y = y;
Loc.X = x;
Color = color;
}
示例8: Square
/// <summary>
/// The constructor.
/// </summary>
/// <param name="board">The board in which the square is located.</param>
/// <param name="location">The location of the square.</param>
/// <param name="color">The color of the square.</param>
/// <param name="piece">The Chess piece that is on the square.</param>
public Square(ChessBoard board, Location location, ChessColor color, ChessPiece piece = null)
{
this.Board = board;
this.Location = location;
this.Color = color;
this.Piece = piece;
}
示例9: GenerateMoves
public void GenerateMoves(ChessBoard board, ChessColor color)
{
Moves = new List<ChessMove>();
for (int y = 0; y < ChessBoard.NumberOfRows; y++)
{
for (int x = 0; x < ChessBoard.NumberOfColumns; x++)
{
if (color == ChessColor.White) // if player is white
{
if (board[x, y] > ChessPiece.Empty)
{
switch (board[x, y])
{
case ChessPiece.WhiteBishop:
BishopMoves(board, x, y, color);
break;
case ChessPiece.WhiteQueen:
QueenMoves(board, x, y, color);
break;
case ChessPiece.WhiteKing:
break;
case ChessPiece.WhiteKnight:
KnightMoves(board, x, y, color);
break;
case ChessPiece.WhitePawn:
PawnMoves(board, x, y, color);
break;
case ChessPiece.WhiteRook:
RookMoves(board, x, y, color);
break;
}
}
}
else if ( color == ChessColor.Black)
{
switch (board[x, y])
{
case ChessPiece.BlackBishop:
BishopMoves(board, x, y, color);
break;
case ChessPiece.BlackQueen:
QueenMoves(board, x, y, color);
break;
case ChessPiece.BlackKing:
break;
case ChessPiece.BlackKnight:
KnightMoves(board, x, y, color);
break;
case ChessPiece.BlackPawn:
PawnMoves(board, x, y, color);
break;
case ChessPiece.BlackRook:
RookMoves(board, x, y, color);
break;
}
}
}
}
}
示例10: Piece
public Piece( ChessColor color )
{
Rules = new Collection<Rule>();
Color = color;
InitializeRules();
}
示例11: Hueristic
/// <summary>
/// this will define BoardAfterMove, TheMove, and HValue based on move
/// </summary>
/// <param name="board"></param>
/// <param name="move"></param>
/// <param name="colorofEnemy"></param>
public Hueristic(ChessBoard board, ChessMove move, ChessColor colorofEnemy)
{
BoardBeforeMove = board.Clone();
BoardAfterMove = board.Clone();
BoardAfterMove.MakeMove(move);
TheMove = move;
//HValue = CalculateHueristicBasic(board, colorofEnemy);
HValue = CalculateHueristicAdvanced(colorofEnemy);
}
示例12: CheckOtherFigureIfValid
private bool CheckOtherFigureIfValid(IBoard board, Position to, ChessColor color)
{
var otherFigure = board.GetFigureAtPosition(to);
if (otherFigure != null && otherFigure.Color == color)
{
return false;
}
return true;
}
示例13: PieceSafety
/// <summary>
/// Purpose: Lower the Heuristic value if our queen is put in danger
/// </summary>
/// <param name="boardState"></param>
/// <param name="color"></param>
/// <returns></returns>
private static int PieceSafety(char[] boardState, ChessColor color)
{
int hazardPenalty = 0;
bool white = color == ChessColor.White;
hazardPenalty += FENExtensions.PieceNotSafe(boardState, FENExtensions.GetPiecePos(boardState, white, 'q'), white) ? -400 : 0;
hazardPenalty += FENExtensions.PieceNotSafe(boardState, FENExtensions.GetPiecePos(boardState, white, 'r'), white) ? -200 : 0;
hazardPenalty += FENExtensions.PieceNotSafe(boardState, FENExtensions.GetPiecePos(boardState, white, 'n'), white) ? -150 : 0;
hazardPenalty += FENExtensions.PieceNotSafe(boardState, FENExtensions.GetPiecePos(boardState, white, 'b'), white) ? -155 : 0;
hazardPenalty += FENExtensions.PieceNotSafe(boardState, FENExtensions.GetPiecePos(boardState, white, 'p'), white) ? -40 : 0;
return hazardPenalty;
}
示例14: Node
public Node(ChessColor c, ChessMove m, Node p)
{
color = c;
move = m;
parent = p;
if (parent == null)
{
depth = 0;
}
else
{
depth = parent.depth + 1;
}
}
示例15: GameGump
public GameGump( Mobile m, ChessGame game, ChessColor color, string message, bool move, bool moving ): base( 60, 25 )
{
m.CloseGump( typeof( GameGump ) );
m_Game = game;
m_Message = message;
m_Color = color;
m_Move = move;
m_Moving = moving;
if ( move && ! moving )
m_Game.SendMoveTarget( m );
MakeGump();
}