logic
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
namespace CheckersSpielBot
|
||||
{
|
||||
public static class BoardHelper
|
||||
{
|
||||
public static bool IsPlayableSquare(int row, int col) => (row + col) % 2 == 1;
|
||||
public static bool IsWithinBounds(int row, int col) => (uint)row < 8 && (uint)col < 8;
|
||||
|
||||
public static bool BelongsToPlayer(int piece, int player) =>
|
||||
player == 1 ? piece == 1 || piece == 3
|
||||
: piece == 2 || piece == 4;
|
||||
|
||||
public static bool IsOpponentPiece(int own, int target)
|
||||
{
|
||||
if (target == 0) return false;
|
||||
bool ownRed = own == 1 || own == 3;
|
||||
bool targetRed = target == 1 || target == 3;
|
||||
return ownRed != targetRed;
|
||||
}
|
||||
|
||||
public static bool IsKing(int piece) => piece == 3 || piece == 4;
|
||||
public static bool IsRedPiece(int piece) => piece == 1 || piece == 3;
|
||||
public static string PlayerLabel(int player) => player == 1 ? "Red" : "Blue";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user