Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/book.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const struct Action* opening_move(const struct State* state)

if (state->piece_count[P1] == 0 || state->piece_count[P2] == 0) {
for (int i = 0; i < state->action_count; i++) {
switch (state->actions[i].from.r) {
switch (state->pieces[state->turn][state->actions[i].from.r].type) {
case BEETLE:
case GRASSHOPPER:
case SPIDER:
Expand Down
3 changes: 3 additions & 0 deletions src/coords.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ bool Coords_map_adjacent(const struct Coords* coords, const struct Coords* other

bool Coords_adjacent(const struct Coords* coords, const struct Coords* other)
{
if (coords->q == IN_HAND || other->q == IN_HAND) {
return false;
}
return Coords_map_adjacent(coords, other);
}

Expand Down
10 changes: 5 additions & 5 deletions src/simulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ int State_beetle_seek_path(
const struct Piece* piece,
struct Coords* path)
{
if (!state->queens[!piece->player]) {
if (state->pieces[!piece->player][QUEEN_INDEX].coords.q == IN_HAND) {
return -1;
}
struct Coords target = state->queens[!piece->player]->coords;
struct Coords target = state->pieces[!piece->player][QUEEN_INDEX].coords;

struct Coords queue[MAX_PIECES];
unsigned int queue_size = 0;
Expand Down Expand Up @@ -165,7 +165,8 @@ float State_simulate(struct State* state,

if (state->beetle_move_count
&& (rand() / (float)RAND_MAX) < options->beetle_seek_move_bias) {
struct Piece* beetle = state->beetles[state->turn][rand() % state->beetle_count[state->turn]];

struct Piece* beetle = &state->pieces[state->turn][BEETLE_INDEX + rand() % (NUM_BEETLES - state->hands[state->turn][BEETLE])];
struct Coords path[MAX_PIECES];
int path_size = State_beetle_seek_path(state, beetle, path);

Expand Down Expand Up @@ -242,8 +243,7 @@ float State_simulate(struct State* state,

if (action->from.q != PLACE_ACTION
&& action->from.q != PASS_ACTION
&& state->queens[!state->turn]
&& Coords_adjacent(&action->from, &state->queens[!state->turn]->coords)
&& Coords_adjacent(&action->from, &state->pieces[!state->turn][QUEEN_INDEX].coords)
&& (rand() / (float)RAND_MAX) < options->from_queen_pass) {
#ifdef WATCH_SIMS
printf("from queen pass\n");
Expand Down
Loading