Push version 0.3.0
This commit is contained in:
parent
f660377768
commit
bb344cb956
7 changed files with 311 additions and 108 deletions
42
logic.h
42
logic.h
|
|
@ -1,16 +1,54 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include "config.h"
|
||||
#include "types.h"
|
||||
|
||||
// Types for using a bit more ram to avoid duplicated computations
|
||||
typedef struct {
|
||||
column_t *vertical2;
|
||||
column_t *horizontal2;
|
||||
column_t *diagonalUp2;
|
||||
column_t *diagonalDown2;
|
||||
column_t *vertical4;
|
||||
column_t *horizontal4;
|
||||
column_t *diagonalUp4;
|
||||
column_t *diagonalDown4;
|
||||
} directions_t;
|
||||
|
||||
typedef struct {
|
||||
column_t *win0;
|
||||
column_t *win1;
|
||||
directions_t same;
|
||||
} wins_t;
|
||||
|
||||
extern winint_t countcmp(
|
||||
const board_t a,
|
||||
const board_t b
|
||||
);
|
||||
|
||||
// Get a random column in the board
|
||||
extern columnsint_t randomColumn(
|
||||
const board_t board
|
||||
);
|
||||
|
||||
// Put a piece in the board
|
||||
extern void playMove(
|
||||
board_t *boardptr,
|
||||
const columnsint_t column
|
||||
);
|
||||
|
||||
// Calculate wins
|
||||
extern void calcWins(
|
||||
wins_t *wins,
|
||||
const board_t board,
|
||||
// Null pointer on systems where the extra ram is not available
|
||||
wins_t *wins,
|
||||
board_t *boardptr,
|
||||
const columnsint_t column
|
||||
);
|
||||
|
||||
// Reference implementation for calculating wins,
|
||||
// slow AF especially on big boards
|
||||
extern void calcWins_slow(
|
||||
board_t *boardptr
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue