本文整理汇总了C#中ChessPiece类的典型用法代码示例。如果您正苦于以下问题:C# ChessPiece类的具体用法?C# ChessPiece怎么用?C# ChessPiece使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChessPiece类属于命名空间,在下文中一共展示了ChessPiece类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getNotation
public override string getNotation(ChessSide side,
ChessPiece[,]
positions, int sr,
int sf, int dr,
int df,
PromotionType
promotion_type)
{
string str;
if (sf == df)
{
str = "" + (char) ('a' + df) + (dr +
1);
}
else
{
str = "" + (char) ('a' + sf);
if (positions[dr, df] != null)
str += 'x';
str += "" + (char) ('a' + df) +
(dr + 1);
}
if (dr == 7 || dr == 0)
{
/* No need to verify for specific colors
* only whites can reach 7 and blacks can reach 0
*/
str += ChessPiece.
getPromotionString
(promotion_type);
}
return str;
}
示例2: IsReady
///////////////////////////////////////////////////////////////////////////
public override bool IsReady()
{
potentialTargets = new ArrayList ();
foreach (ChessPiece player1Piece in scenario.GetAllChessPiecesForPlayer(1)) {
foreach (ChessPiece player2Piece in scenario.GetAllChessPiecesForPlayer(2)) {
if (player1Piece.CanCaptureXY (player2Piece.x, player2Piece.y))
potentialTargets.Add (player1Piece);
}
}
int targetValue = 0;
foreach (ChessPiece piece in potentialTargets) {
if (piece.GetValue () > targetValue) {
targetValue = piece.GetValue ();
targetChessPiece = piece;
}
}
if (targetChessPiece == null)
{
return false;
}
else
{
potentialPlacesToMoveTarget = new ArrayList ();
foreach (PotentialMove move in targetChessPiece.GetMoveList())
{
//Debug.Log (player2Piece.gameObject.name + ": Has " + player2Piece.GetMoveList().Count + " potential moves");
//int goodmoves = 0;
foreach (ChessPiece player2Piece in scenario.GetAllChessPiecesForPlayer(2)) {
//Debug.Log ("checked" + counter + "moves");
if (player2Piece.CanCaptureChessPieceIfItMovedToXY (targetChessPiece, move.x, move.y))
{
if (GameObject.FindGameObjectWithTag ("Scenario").GetComponent<Scenario> ().GetPieceAtXY (move.x, move.y) == null)
{
//goodmoves++;
potentialPlacesToMoveTarget.Add (move);
Debug.Log(potentialPlacesToMoveTarget.Count);
}
}
}
// Debug.Log (player2Piece.gameObject.name + ": Potential Places to Move Target: " + goodmoves);
}
}
if(potentialPlacesToMoveTarget.Count > 0){
return true;
}
else {
return false;
}
}
示例3: ChessPieceViewModel
public ChessPieceViewModel(ChessPiece i_ChessPiece, PieceColor i_PieceColor, PieceSide i_PieceSide, int i_File, int i_Rank)
{
ChessCoord tempChessCoord = new ChessCoord();
tempChessCoord.File = i_File;
tempChessCoord.Rank = i_Rank;
m_ChessPieceModel = new ChessPieceModel(i_ChessPiece, i_PieceColor, i_PieceSide, tempChessCoord);
}
示例4: IsReady
///////////////////////////////////////////////////////////////////////////
public override bool IsReady()
{
potentialTargets = new ArrayList ();
foreach (ChessPiece player1Piece in scenario.GetAllChessPiecesForPlayer(1)) {
foreach (ChessPiece player2Piece in scenario.GetAllChessPiecesForPlayer(2)) {
if (player1Piece.CanCaptureXY (player2Piece.x, player2Piece.y) && !player1Piece.IsDepressed())
{
potentialTargets.Add (player1Piece);
}
}
}
int targetValue = 0;
foreach (ChessPiece piece in potentialTargets) {
if (piece.GetValue () > targetValue) {
targetValue = piece.GetValue ();
targetChessPiece = piece;
}
}
if (targetChessPiece == null)
{
return false;
}
else
{
return true;
}
}
示例5: isValidMove
public override bool isValidMove(int i, int j,
ChessPiece[,]
positions,
int flags)
{
if (!base.
isValidMove (i, j, positions, flags))
return false;
int r_diff = i - rank;
int f_diff = j - file;
if (r_diff < 0)
r_diff = -r_diff;
if (f_diff < 0)
f_diff = -f_diff;
if (r_diff < 2 && f_diff < 2)
return true;
// if( castling ) {
// if( file == ChessBoardConstants.e && j == ChessBoardConstants.g )
// return true;
// if( file == ChessBoardConstants.e && j == ChessBoardConstants.c )
// return true;
// }
return false;
}
示例6: SetPiece
public void SetPiece( ChessPiece chessPiece )
{
this.gameObject = chessPiece.gameObject;
this.playerSide = chessPiece.playerSide;
this.pieceType = chessPiece.pieceType;
this.piecePlayerType = chessPiece.piecePlayerType;
}
示例7: ChessBoard
/// <summary>
/// Helper constructor that creates a new chess board based off of a Fen string.
/// </summary>
/// <param name="fenBoard">The Fen string that represents the board.</param>
public ChessBoard(string fenBoard)
{
Profiler.AddToMainProfile((int)ProfilerMethodKey.ChessBoard_ctor_string);
Board = new ChessPiece[NumberOfRows, NumberOfColumns];
FromFenBoard(fenBoard);
}
示例8: CopyFrom
public void CopyFrom( ChessPiece chessPiece )
{
this.gameObject = chessPiece.gameObject;
this.playerSide = chessPiece.playerSide;
this.pieceType = chessPiece.pieceType;
this.piecePlayerType = chessPiece.piecePlayerType;
this.bEnPassantCapture = chessPiece.bEnPassantCapture;
}
示例9: Evaluate
protected override Int32 Evaluate(ChessBoard myBoard, ChessPiece turn, Int16 depth)
{
IncrementSearchCount();
var materialValue = (turn == ChessPiece.White ? 1 : -1) * myBoard.GetMaterialValue(this.ChessPieceRelativeValues, depth);
var positionalValue = (turn == ChessPiece.White ? 1 : -1) * myBoard.GetPositionalValue();
return MaterialFactor * materialValue + PositionalFactor * positionalValue;
}
示例10: ChessBoardSquare
public ChessBoardSquare( ChessPiece piece, ParticleSystem moveablePSystem, int nPile, int nRank )
{
this.position = new ChessPosition( nRank, nPile );
this.piece = piece;
if( this.piece != null )
this.piece.SetPosition( this.position.Get3DPosition() );
SetMovableEffect( moveablePSystem );
}
示例11: getNotation
public override string getNotation(ChessSide side,
ChessPiece[,]
positions, int sr,
int sf, int dr,
int df,
PromotionType
promotion)
{
return "K" + (char) ('a' + df) + (dr + 1);
}
示例12: GetRelativePaths
public List<Tuple<int, int>[]> GetRelativePaths(ChessPiece p)
{
int direction = p.Direction;
return new List<Tuple<int, int>[]>()
{
new[] { new Tuple<int, int>(direction, -1), },
new[] { new Tuple<int, int>(direction, 0), },
new[] { new Tuple<int, int>(direction * 2, 0), },
new[] { new Tuple<int, int>(direction, 1) },
};
}
示例13: GetRelativePaths
public List<Tuple<int, int>[]> GetRelativePaths(ChessPiece p)
{
var l = new List<Tuple<int, int>[]>();
foreach (var subPath in new RookRelativePathProvider().GetRelativePaths(p))
l.Add(subPath);
foreach (var subPath in new BishopRelativePathProvider().GetRelativePaths(p))
l.Add(subPath);
return l;
}
示例14: TestEquality
public static void TestEquality()
{
ChessPiece piece1 = new ChessPiece(Piece.King, Player.White);
ChessPiece piece2 = new ChessPiece(Piece.King, Player.White);
Assert.AreEqual(piece1, piece2, "piece1 and piece2 are not equal");
Assert.True(piece1.Equals(piece2), "piece1.Equals(piece2) should be True");
Assert.True(piece2.Equals(piece1), "piece2.Equals(piece1) should be True");
Assert.True(piece1 == piece2, "piece1 == piece2 should be True");
Assert.True(piece2 == piece1, "piece2 == piece1 should be True");
Assert.False(piece1 != piece2, "piece1 != piece2 should be false");
Assert.False(piece2 != piece1, "piece2 != piece1 should be false");
Assert.AreEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are different");
}
示例15: TestInequality_DifferentPieceAndPlayer
public static void TestInequality_DifferentPieceAndPlayer()
{
ChessPiece piece1 = new ChessPiece(Piece.King, Player.White);
ChessPiece piece2 = new ChessPiece(Piece.Queen, Player.Black);
Assert.AreNotEqual(piece1, piece2, "piece1 and piece2 are equal");
Assert.False(piece1.Equals(piece2), "piece1.Equals(piece2) should be false");
Assert.False(piece2.Equals(piece1), "piece2.Equals(piece1) should be false");
Assert.False(piece1 == piece2, "piece1 == piece2 should be false");
Assert.False(piece2 == piece1, "piece2 == piece1 should be false");
Assert.True(piece1 != piece2, "piece1 != piece2 should be True");
Assert.True(piece2 != piece1, "piece2 != piece1 should be True");
Assert.AreNotEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are equal");
}