pseudocode algo for the game
This commit is contained in:
BIN
Binary file not shown.
+1
-4
@@ -1,8 +1,5 @@
|
||||
#include "chess.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
int board[BOARD_VERTICAL][BOARD_HORIZONTAL];
|
||||
|
||||
bool init_board() {
|
||||
bool init_board(board_t *board) {
|
||||
|
||||
}
|
||||
+7
-2
@@ -12,9 +12,14 @@
|
||||
* 6 - king
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
// board size constraints
|
||||
#define BOARD_HORIZONTAL 8
|
||||
#define BOARD_VERTICAL 8
|
||||
//int board[BOARD_VERTICAL][BOARD_HORIZONTAL];
|
||||
|
||||
// just a simple type abstraction
|
||||
typedef int board_t[BOARD_HORIZONTAL][BOARD_VERTICAL];
|
||||
|
||||
// the default arrangment of pieces on the board
|
||||
#define BOARD_DEFAULT_CONFIG \
|
||||
@@ -29,6 +34,6 @@
|
||||
}
|
||||
|
||||
// initializes the board with the default configuration of pieces
|
||||
bool init_board();
|
||||
bool init_board(board_t *board);
|
||||
|
||||
#endif // CHESS_H
|
||||
+23
-1
@@ -1,7 +1,29 @@
|
||||
// a chess implementation in pure C :)
|
||||
|
||||
#include <stdio.h>
|
||||
#include "util.h"
|
||||
#include "chess.h"
|
||||
|
||||
/**
|
||||
* steps to victory:
|
||||
* 1. init the board with the default config
|
||||
* 2. game loop
|
||||
* 2a. select the current player (if first round - white starts)
|
||||
* 2b. wait for the movement of the current player
|
||||
* 2c. once a move is registered, perform it IF POSSIBLE
|
||||
* 2d. check for captures and/or promotions and/or mates (check, stale...)
|
||||
* 2e. if there is an end condition that is met, end the game; announce
|
||||
* the results
|
||||
*/
|
||||
|
||||
int main() {
|
||||
board_t board;
|
||||
bool running = true;
|
||||
|
||||
init_board(&board);
|
||||
|
||||
while (running) {
|
||||
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
// misc. defines and methods
|
||||
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
#endif // UTIL_H
|
||||
Reference in New Issue
Block a user