No description
Find a file
2025-08-18 06:20:39 +02:00
.gitignore Made .gitignore ignore non-code files by default 2025-06-14 20:22:28 +02:00
commandline.c Fixed a silly 2025-08-18 06:20:39 +02:00
commandline.h Split off command-line options parsing from the main function 2025-08-17 23:29:01 +02:00
config.h Made arrows the only input for ncurses because I never test the rest 2025-06-14 20:35:22 +02:00
connect4.c Fixed a silly 2025-08-18 06:20:39 +02:00
LICENSE.md Moved to markdown version of the GPLv2 2025-06-06 21:31:59 +02:00
logic.c Added cross-compiling to windows 2025-08-16 12:33:59 +02:00
logic.h Push version 0.3.0 2025-08-14 18:38:22 +02:00
macros.h Split off command-line options parsing from the main function 2025-08-17 23:29:01 +02:00
makefile Split off command-line options parsing from the main function 2025-08-17 23:29:01 +02:00
README.md Add commandline.h to README.md 2025-08-18 03:12:42 +00:00
types.h Made code (mostly) follow C99 2025-08-15 19:20:04 +02:00
ui.h Push version 0.3.0 2025-08-14 18:38:22 +02:00
ui_ncurses.c Added LTO and fixed warnings 2025-08-14 21:31:26 +02:00
ui_stub.c Removed unused include 2025-08-16 12:31:51 +02:00
ui_vt100.c Made ui_vt100 able to be used without askColumn between every updateBoard 2025-07-27 22:10:35 +02:00

AnnaConnect

AnnaConnect is a silly little text-based connect 4 game c:

Supports vt100 escape codes and ncurses for drawing the UI. There is also an option to let the game (randomly) play itself for testing, which does not need a UI.

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.

commandline.h

The commandline.h file has the function that handles command-line argument parsing.

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.