diff options
| author | tslil clingman <tslil@posteo.de> | 2023-01-29 20:49:04 +0100 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | f0139acd1d648dd1db93ee3d3b75546fb7b24c77 (patch) | |
| tree | 6a95385b30348a75fd2bdd6c2d0c751ed31515a8 /include/actions.h | |
| parent | 0e81096d5ecb6027814e7aae10b461e774f96407 (diff) | |
switch to returning an array of actions instead of a linked list
- attempts to keep the same move ordering as the list method
- saves ~170msec on a depth 7 search for a given board configuration
- there is room to improve the pre-allocation size estimates, these
bounds are not obviously tight and it may or may not be faster to
have tighter bounds or even some form of estimation
Diffstat (limited to 'include/actions.h')
| -rw-r--r-- | include/actions.h | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/include/actions.h b/include/actions.h index 1550cce..0127119 100644 --- a/include/actions.h +++ b/include/actions.h @@ -43,15 +43,6 @@ typedef uint32_t action_t; ((type) | (loc) << A_LOC_SHIFT | (data0) << A_DATA0_SHIFT | \ (data1) << A_DATA1_SHIFT) -typedef struct action_node_s { - struct action_node_s *next; - action_t action; -} action_node_t; - -typedef struct action_list_s { - struct action_node_s *head, *tail; - uint32_t length; -} action_list_t; // =================================================================== // Variables @@ -63,11 +54,14 @@ extern int8_t move_deltas[4]; // Methods // =================================================================== -void action_list_init(const uint8_t board_size); -void action_list_free(action_list_t *list); -action_list_t *action_list_generate(tak_state_p state); +void actions_init(const uint8_t board_size); +void actions_free(action_t *actions); -int action_move_to_front(const action_t action, action_list_t *list); +action_t *actions_generate(tak_state_p state, uint32_t *num_actions); +char action_in_list(action_t action, action_t *actions, + const uint32_t num_actions); +void action_move_to_front(action_t action, action_t *actions, + const uint32_t num_actions); void action_take(tak_state_p state, const action_t action); void action_undo(tak_state_p state, const action_t action); |
