Add description of header files to README.md

This commit is contained in:
AnnaSnoeijs 2025-08-16 11:12:39 +00:00
parent 4b4ded94b6
commit 03764b7437

View file

@ -2,7 +2,54 @@
AnnaConnect is a silly little text-based connect 4 game c:
Supports vt100 escape codes and ncurses for drawing the UI
Supports vt100 escape codes and ncurses for drawing the UI.
There is also an option to let the game (randomly) play itself,
which does not need a working UI. This is only for testing.
Stuff still be changing so fast that the code is the documentation,
but at least it's got good enough comments methinks
# Header files
## `types.h`
The `types.h` file defines the types used in all of the program.
### Integer types
- `rowsint_t`: row numbers.
- `columnsint_t`: columns numbers.
- `winint_t`: amount of wins.
- `column_t`: the bit field of the pieces in a column, LSB is the bottom of the board.
### Structs
#### `wincount_t`
This struct has all counts for all the wins made my a players.
- `winint_t total`: total amount of wins
- `winint_t horizontal`: amount of wins from a horizontal line
- `winint_t vertical`: amount of wins from a vertical line
- `winint_t diagonalUp`: amount of wins from a line going diagonally up (from left to right)
- `winint_t diagonalDown`: amount of wins from a line going diagonally down (from left to right)
#### `board_t`
This struct has an enire board.
- `bool player`: The current player
- `rowsint_t *height`: An array with the amount of pieces in each column
- `column_t *column`: An array of all the columns in the board
- `rowsint_t rows`: The amount of rows the baord has
- `columnint_t columns`: The amount of columns the board has
- `wincount_t count0`: A struct holding the counts of wins player 0 has gotten
- `wincount_t count1`: A struct holding the counts of wins player 1 has gotten
## `ui.h`
The `ui.h` file describes the functions each `ui_*.c` user interface is expected to implement.
These should be ass cross-platform as possible for the used backend.
So for example the ui_vt100.c supports all platforms where vt100 escape codes are supported.
When implementing a new ui, you can start from `ui_stub.c`.
This "ui" is just the bare minimum to let the rest of the code work.
## `logic.h`
The `logic.h` file has the types used in `logic.c` and the functions it exposes.
## `macros.h`
The `macros.h` file has macros for simple stuff.
## `config.h`
The `config.h` defines default board size, and wether or not the displayed row and column numbers start at 0.