Declared all functions
This commit is contained in:
parent
fa9609d71e
commit
cb6aae6c2b
4 changed files with 61 additions and 1 deletions
|
|
@ -1,7 +1,15 @@
|
|||
/*----------------------------------------------------------
|
||||
* HTBLA-Leonding / Klasse
|
||||
* HTBLA-Leonding / 2IHIF
|
||||
* ---------------------------------------------------------
|
||||
* Description:
|
||||
* Implementation of basic chess functions.
|
||||
* ----------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "chess.h"
|
||||
#include "chess_printer.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,3 +5,53 @@
|
|||
* Basic chess functions.
|
||||
* ----------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef ___CHESS_H
|
||||
#define ___CHESS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "chess_printer.h"
|
||||
|
||||
#define CHESSBOARD_LENGTH 8
|
||||
typedef struct ChessSquare ChessBoard[CHESSBOARD_LENGTH][CHESSBOARD_LENGTH];
|
||||
|
||||
typedef enum {
|
||||
Pawn,
|
||||
Knight,
|
||||
Bishop,
|
||||
Rook,
|
||||
Queen,
|
||||
King,
|
||||
NoPiece
|
||||
} PieceType;
|
||||
|
||||
typedef enum {
|
||||
White,
|
||||
Black,
|
||||
NO_COLOR
|
||||
} Color;
|
||||
|
||||
typedef enum {
|
||||
NormalMove,
|
||||
CaptureMove
|
||||
} MoveType;
|
||||
|
||||
struct ChessPiece {
|
||||
PieceType type;
|
||||
Color color;
|
||||
};
|
||||
|
||||
struct ChessSquare {
|
||||
bool is_occupied;
|
||||
struct ChessPiece piece;
|
||||
};
|
||||
|
||||
typedef char File;
|
||||
typedef int Rank;
|
||||
|
||||
struct ChessPiece get_piece(ChessBoard chess_board, File file, Rank rank);
|
||||
bool squares_share_pawns_move(Color color, MoveType move, File filePiece1, Rank rankPiece1, File filePiece2, Rank rankPiece2);
|
||||
|
||||
#endif
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "chess_printer.h"
|
||||
#include "chess.h"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
* Test functions for chess.
|
||||
* ----------------------------------------------------------
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include "shortcut.h"
|
||||
#include "test_chess.h"
|
||||
#include "chess.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue