/* SPDX-License-Identifier: GPL-2.0-only */ /* * AnnaConnect is a silly little text-based connect 4 game c: * Copyright (C) 2025 Anna Snoeijs. anna@snoeijs.tech * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "macros.h" #include "config.h" #include "logic.h" #include "types.h" #include "ui.h" #define VERSION 0.0.2 int main(){ // First the boilerplate stuffs printf( "AnnaConnect version "XSTR(VERSION)", Copyright (C) Anna Snoeijs\n" "AnnaConnect comes with ABSOLUTELY NO WARRANTY\n" "This is free software, and you are welcome to redistribute it\n" "under certain condtions\n" ); // board, innit? initBoard(); board_t playboard = { .player = 0, .column = {0}, .heigth = {0}, }; wins_t wins = { .count0 = { .total = 0, .vertical = 0, .horizontal = 0, .diagonalUp = 0, .diagonalDown = 0, }, .count1 = { .total = 0, .vertical = 0, .horizontal = 0, .diagonalUp = 0, .diagonalDown = 0, }, .win0 = {0}, .win1 = {0}, }; for(;; playboard.player = !playboard.player ){ #ifndef ONLYPUT move_t move = askMove(); int column = askColumn( playboard, move ); playMove( &playboard, move, column ); #else /* ONLYPUT */ int column = askColumn( playboard ); playMove( &playboard, column ); #endif /* ONLYPUT */ calcWins( &wins, playboard ); updateBoard( wins, playboard, column ); } }