Represent a chessboard as a data structure

maybe something like this?

UENUM() enum chess_piece { Pawn, Knight, Bishop, Rook, Queen, King };

UENUM() enum player_color { Black, White };


USTRUCT(BlueprintType) struct Fchess_cell
{
	GENERATED_BODY()
	UPROPERTY(BlueprintReadWrite)
	int32 Coord_X;

	UPROPERTY(BlueprintReadWrite)
	int32 Coord_Y;

	UPROPERTY(BlueprintReadWrite)
	TEnumAsByte<chess_piece> piece;

	UPROPERTY(BlueprintReadWrite)
	TEnumAsByte<player_color> Player;
};

and then you create an array for the cells:

	UPROPERTY(BlueprintReadWrite)
	TArray<Fchess_cell> myCells;

and get something like this:

image

3 Likes