NeurOX 1.0.0 dev-in-progress
Экосистема многопользовательской игры классические крестики-нолики с ИИ
Загрузка...
Поиск...
Не найдено
_XOGame.h
См. документацию.
1#pragma once
2
3#include "XOGame.h"
4
5
6#ifndef OFFSETOF_CONSTEXPR
7#define OFFSETOF_CONSTEXPR(type, member) \
8 ((size_t)(&((type*)0)->member) - (size_t)0)
9#endif
10
11#ifdef __cplusplus
12extern "C" {
13#endif // __cplusplus
14
16 typedef struct XOGameMutable {
18 size_t id;
20 XORetCode (*make_move)(XOGame* _Game, int _CellX, int _CellY, XOPlayerSide _PlayerSide);
21 void (*destruct)(XOGame* _Game);
29 uint8_t turn;
31 uint8_t padding[2];
33
34
35 XORetCode xogame_make_move(XOGame* _Game, int _CellX, int _CellY, XOPlayerSide _PlayerSide);
36 XORetCode xogame_make_move_original_fast(XOGame* _Game, int _CellX, int _CellY, XOPlayerSide _PlayerSide);
37 void xogame_destruct(XOGame* _Game);
38
39// Статические проверки ПОЛНОЙ БИНАРНОЙ СОВМЕСТИМОСТИ XOGame и XOGameMutable
40_Static_assert(sizeof(XOGame) == sizeof(XOGameMutable), "XOGame and XOGameMutable must have the same size");
41_Static_assert(_Alignof(XOGame) == _Alignof(XOGameMutable), "XOGame and XOGameMutable must have the same alignment");
42
43// Проверка смещений полей
44_Static_assert(OFFSETOF_CONSTEXPR(XOGame, make_move) == OFFSETOF_CONSTEXPR(XOGameMutable, make_move), "Field 'make_move' must have the same offset in both structures");
45_Static_assert(OFFSETOF_CONSTEXPR(XOGame, destruct) == OFFSETOF_CONSTEXPR(XOGameMutable, destruct), "Field 'destruct' must have the same offset in both structures");
46_Static_assert(OFFSETOF_CONSTEXPR(XOGame, board) == OFFSETOF_CONSTEXPR(XOGameMutable, board), "Field 'board' must have the same offset in both structures");
47_Static_assert(OFFSETOF_CONSTEXPR(XOGame, log) == OFFSETOF_CONSTEXPR(XOGameMutable, log), "Field 'log' must have the same offset in both structures");
48_Static_assert(OFFSETOF_CONSTEXPR(XOGame, winners) == OFFSETOF_CONSTEXPR(XOGameMutable, winners), "Field 'winners' must have the same offset in both structures");
49_Static_assert(OFFSETOF_CONSTEXPR(XOGame, turn) == OFFSETOF_CONSTEXPR(XOGameMutable, turn), "Field 'turn' must have the same offset in both structures");
50_Static_assert(OFFSETOF_CONSTEXPR(XOGame, padding) == OFFSETOF_CONSTEXPR(XOGameMutable, padding), "Field 'padding' must have the same offset in both structures");
51
52// Проверка размеров полей, это не тоже самое что и смещение!!!
53_Static_assert(sizeof(((XOGame*)0)->make_move) == sizeof(((XOGameMutable*)0)->make_move), "Field 'make_move' must have the same size in both structures");
54_Static_assert(sizeof(((XOGame*)0)->destruct) == sizeof(((XOGameMutable*)0)->destruct), "Field 'destruct' must have the same size in both structures");
55_Static_assert(sizeof(((XOGame*)0)->board) == sizeof(((XOGameMutable*)0)->board), "Field 'board' must have the same size in both structures");
56_Static_assert(sizeof(((XOGame*)0)->log) == sizeof(((XOGameMutable*)0)->log), "Field 'log' must have the same size in both structures");
57_Static_assert(sizeof(((XOGame*)0)->winners) == sizeof(((XOGameMutable*)0)->winners), "Field 'winners' must have the same size in both structures");
58_Static_assert(sizeof(((XOGame*)0)->turn) == sizeof(((XOGameMutable*)0)->turn), "Field 'turn' must have the same size in both structures");
59_Static_assert(sizeof(((XOGame*)0)->padding) == sizeof(((XOGameMutable*)0)->padding), "Field 'padding' must have the same size in both structures");
60
61#ifdef __cplusplus
62}
63#endif // __cplusplus
64
65
66
@ XO_BOARDX
Размер поля по оси X.
Definition XOGame.h:69
@ XO_BOARDY
Размер поля по оси Y.
Definition XOGame.h:71
XORetCode
Перечисление задающее коды возвраща для XOGame::make_move.
Definition XOGame.h:90
XOPlayerSide
Перечисление задающее типы владения
Definition XOGame.h:78
XORetCode xogame_make_move(XOGame *_Game, int _CellX, int _CellY, XOPlayerSide _PlayerSide)
#define OFFSETOF_CONSTEXPR(type, member)
Definition _XOGame.h:7
void xogame_destruct(XOGame *_Game)
XORetCode xogame_make_move_original_fast(XOGame *_Game, int _CellX, int _CellY, XOPlayerSide _PlayerSide)
Definition XOGame.h:114
Изменяемый клон XOGame.
Definition _XOGame.h:16
void(* destruct)(XOGame *_Game)
Definition _XOGame.h:21
uint8_t turn
Текущий ход начиная с 0.
Definition _XOGame.h:29
uint8_t padding[2]
Выравнивающие байты - { 0 }.
Definition _XOGame.h:31
size_t id
Идентификатор игры
Definition _XOGame.h:18
XOCell winners[XO_BOARDX]
Выигравшие клетки. По-умолчанию - { 0 }.
Definition _XOGame.h:27
XOCell board[XO_BOARDX][XO_BOARDY]
Игровое поле
Definition _XOGame.h:23
XORetCode(* make_move)(XOGame *_Game, int _CellX, int _CellY, XOPlayerSide _PlayerSide)
Сделать ход.
Definition _XOGame.h:20
XOCell log[XO_BOARDX *XO_BOARDY]
Лог ходов
Definition _XOGame.h:25
Definition XOGame.h:152