Files
battleship/include/bot_player.h
T

26 lines
855 B
C

#pragma once
#include <stdbool.h>
#include "app_interfaces.h"
#include "game_types.h"
typedef uint8_t bot_cell_t;
enum { BOT_CELL_UNKNOWN, BOT_CELL_MISS, BOT_CELL_HIT, BOT_CELL_BLOCKED };
typedef struct { bool hit; bool sunk; } bot_shot_result_t;
typedef struct {
random_source_t random;
scheduler_t scheduler;
bot_cell_t knowledge[kBotKnowledgeCellCount];
bool turn_pending;
} bot_player_t;
void bot_player_init(bot_player_t *bot, random_source_t random, scheduler_t scheduler);
bool bot_player_next_shot(bot_player_t *bot, coordinate_t *coordinate);
void bot_player_record_result(bot_player_t *bot, coordinate_t coordinate, const bot_shot_result_t *result);
bool bot_player_schedule_turn(bot_player_t *bot);
void bot_player_cancel_turn(bot_player_t *bot);
_Static_assert(sizeof(bot_player_t) <= 160, "bot state grew beyond fixed budget");