diff options
Diffstat (limited to 'include/tak.h')
| -rw-r--r-- | include/tak.h | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/include/tak.h b/include/tak.h index 4b103a0..32e4491 100644 --- a/include/tak.h +++ b/include/tak.h @@ -1,5 +1,63 @@ -#include "state.h" -#include "ptn.h" +#include <stdint.h> + +enum E_RESULT { A_OK, A_ILLEGAL, A_OVERFLOW, + PTN_VALID, PTN_INVALID, W_NONE, W_DRAW, W_DRAGON, + W_ROAD_WHITE, W_ROAD_BLACK, W_FLAT_WHITE, W_FLAT_BLACK }; + +typedef uint8_t data_t; +typedef uint16_t colour_stack_t; + +uint8_t board_size; +data_t celldat[36]; +colour_stack_t colours[36]; +enum COLOUR current_colour; +uint8_t white_flats, black_flats, white_caps, black_caps, turn; + +void reset_state(const uint8_t new_board_size); +void next_turn(void); + +// ------------------------------------------------------------------- +// State management + +enum COLOUR { C_WHITE, C_BLACK }; +enum STONE_VARIANT { STONE_FLAT, STONE_STANDING, STONE_CAPSTONE }; +enum MOVE_DIRECTION { M_UP, M_DOWN, M_LEFT, M_RIGHT }; + +enum E_RESULT +try_place(const int8_t location, const enum COLOUR colour, + const enum STONE_VARIANT stone); + +enum E_RESULT +try_move(const int8_t location, const enum MOVE_DIRECTION direction, + const uint8_t steps, const uint8_t drops[5]); + +enum E_RESULT +check_win(void); + +// ------------------------------------------------------------------- +// PTN related + +enum E_RESULT +parse_place(const uint8_t board_size, char *ptn, + uint8_t *out_location, enum STONE_VARIANT *out_stone); + +enum E_RESULT +parse_move(const uint8_t board_size, char *ptn, + uint8_t *out_location, enum MOVE_DIRECTION *out_direction, + uint8_t *out_steps, uint8_t out_drops[5]); + +void +generate_place(const uint8_t board_size, const uint8_t in_location, + const enum STONE_VARIANT in_stone, char out_ptn[4]); + +void +generate_move(const uint8_t board_size, const uint8_t in_location, + const enum MOVE_DIRECTION in_direction, + const uint8_t in_steps, const uint8_t in_drops[5], + char out_ptn[10]); + +// ------------------------------------------------------------------- +// Game driver enum E_RESULT do_ptn(char *ptn); |
