From d94e04f8ef2f53fc78b43d6521120aa5a02641e6 Mon Sep 17 00:00:00 2001 From: Odweta Date: Tue, 17 Feb 2026 16:21:45 +0100 Subject: [PATCH] pseudocode algo for the game --- Makefile | 5 ++++- build/chess | Bin 15896 -> 0 bytes src/chess.c | 5 +---- src/chess.h | 9 +++++++-- src/main.c | 24 +++++++++++++++++++++++- src/util.h | 5 +++++ 6 files changed, 40 insertions(+), 8 deletions(-) delete mode 100755 build/chess diff --git a/Makefile b/Makefile index db67a8d..ac38494 100644 --- a/Makefile +++ b/Makefile @@ -9,4 +9,7 @@ build: run: make -B build - $(OUT) \ No newline at end of file + $(OUT) + +clean: + rm -fr $(OUT) \ No newline at end of file diff --git a/build/chess b/build/chess deleted file mode 100755 index 22d87b203574781f7741917753510b6dbdc4b357..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15896 zcmeHOU2Ggz6~4Pk8kg4gHb2x!pqZio36eLqlUNB=nsxk>ag-lpJ5_;(VeQ@6i`Khl zcedDt3QK{CsEt&RKy4qY_O0TDsNx~KIZA2ydr0X^goJ8AgIvl_Dhf(K%J7|;^G(LX zx=4KhA?8Xu-#yJb^CpxCWiBp@k7JrA*4C%npW%xeck zwuk*$VvJ(>#}GTzju^F*5Uz9v`d1FFL^~bGBZ{;WQS6q~Zb|Jz)c%$fnNP`y{6;jN zaomA6DMZngA}GI$77i$J%=xTb^Pt50yI}=<9F-2!#s0>wxrGnX--y~})Nvel1Y!Kk z`F#d<915!PzQExzs{O5Y{krtJ5%qHTx!i;vHe`@Z|@ zo);eZTw`~+G|{_vce&76E>#+HopbwpJA3zL>(y+JfA5Je`g`ACBaL#78zM5RHYyf{ z2#Wt^`UUV-M32?_Dtrg{k5MU#vkkXy90#X5>D1kP&2?t-r3#qIxx90xRLPf1j}?tH z%Zc}zBgcjh_d7k=p6tG`zGts-hR2UPg<`EZRjRwi+W7JQa?hY<+HH*e%|$ouU9r!;(sJ2PgSYQz zpuLa(0>}34In+d+mbSN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|z`V9UpWCPYgI%lRxm;6Me^r`$6Mb;tbl_Y7dMW=g6^>hx?8>Cx?c{ z2FIQ8zQe}`VG-XlkmJsPf3q7vHXMYyvWvhe7V>W1_@@WAA_RK{AgtUt;1udrXF6Xg z$fknflh7)ZDo&$bEWk+x2WO&QS6ki1fQ<+|McJXyblbtoy$&m5lSCSmt8EwI$xhQ*}{AU9s+c0LCd4XTD?@QtPmWu z)r#f37-(&_?21Q3k#&o6ILatMTh&imwm7ZVeYyZ!N+uhIHCwCB7HjUjQhkSqJ7tji zE`t#gxMUqY=VwZj2&;CX0bOgYg%;K|Y`;^A`DA&-uY>`=RKb&kf30 z5@v8~hW4xNPouu*MvH8h`y2lDvwzNqh@3aEU(Q45BZrF2g=o+D5>fu{NRerb^i6xt zTWoML=b%03UqsHgpyHQ!{3BpxZbN&{XNY*>`i1dRk9ZobGFPI^`4X{9?c?z)ZOW*K zZ`yOdMqE@y_8&k0N7eqY>T&)@WS+!c=7@3o1#prR&R4_dvp%OeFNTU=7zgFAq7t>Y z)GkCSDr$4s%@Z;EoGK7E#x5A`>Gr9ZJ^%g^Iq#=_JpS*fJ@aoY)l_U(kr20k4h<3_ z?Kw{&?x3M!-2SDQ{eCM@Bz{fp2)urjUq&T*|6jC%7Gf?C!(-h3$7qS#->?EzqKW~D zV?6#hz{x$rc|YH$xSufIA7$d3u$3Isp6^>%J3*pQFOY7_dIDzqb}VH~yRJh7!K&}W=< zL%UFhv2cu^^Ry1NkLycc(bB5@t9sZ(`}qA&`zUhkhsLPvSBGEJz~t|M%%>R-pG)$- i#Mn^{%QJg|>NR$xEin;u;^y{`?+XlM-XAS7(fkwnhPVR& diff --git a/src/chess.c b/src/chess.c index e80738d..573f838 100644 --- a/src/chess.c +++ b/src/chess.c @@ -1,8 +1,5 @@ #include "chess.h" -#include -int board[BOARD_VERTICAL][BOARD_HORIZONTAL]; - -bool init_board() { +bool init_board(board_t *board) { } \ No newline at end of file diff --git a/src/chess.h b/src/chess.h index ab1cbd4..b5a028d 100644 --- a/src/chess.h +++ b/src/chess.h @@ -12,9 +12,14 @@ * 6 - king */ +#include + +// 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 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 1d0edd9..c6424b5 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,29 @@ // a chess implementation in pure C :) -#include +#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; } \ No newline at end of file diff --git a/src/util.h b/src/util.h index 1aa2989..ab25d30 100644 --- a/src/util.h +++ b/src/util.h @@ -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 \ No newline at end of file