aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--include/negamax.c32
-rw-r--r--src/ctaklm.c23
3 files changed, 3 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index eacaff8..2b0b6a2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
IDIR=include
DEFINES=-DDETERMINISTIC
-CFLAGS=-g -Wall -Wextra -Wpedantic -std=c99 -D_DEFAULT_SOURCE $(DEFINES) -I$(IDIR) -lm
+CFLAGS=-O3 -Wall -Wextra -Wpedantic -std=c99 -D_DEFAULT_SOURCE $(DEFINES) -I$(IDIR) -lm
LIBS=
SRCS=$(wildcard include/*.c)
diff --git a/include/negamax.c b/include/negamax.c
index abb4e27..912705d 100644
--- a/include/negamax.c
+++ b/include/negamax.c
@@ -115,16 +115,11 @@ negamax(const uint8_t cur_depth, float alpha, float beta,
const float colour) {
float value = -infty;
-
- data_t bd[5*5];
- colour_stack_t bc[25];
-
action_list_t *list = action_list_generate();
if (list == NULL) return value; // ???
for (action_node_t *node=list->head; node!=NULL; node=node->next) {
- for (int k=0; k<25; k++) { bd[k]=celldat[k]; bc[k]=colours[k]; }
action_take(node);
// Compute the value of the node
@@ -143,31 +138,6 @@ negamax(const uint8_t cur_depth, float alpha, float beta,
}
action_undo(node);
- for (int k=0; k<25; k++) {
- if (bd[k]!=celldat[k]) {
- printf("Depth %d %.3f %.3f %d: { .type = %s, .loc = 0x%02X, .data0 = 0x%02X, .data1 = 0x%02X} DIFF 0x%02X \n",
- cur_depth,
- alpha,
- beta,
- ply,
- (node->type == A_PLACE) ? "A_PLACE" : "A_MOVE",
- node->loc,
- node->data0,
- node->data1,
- k);
- puts("Before:");
- for (int j=0; j<25;j++) printf("0x%02X ",bd[j]);
- putchar('\n');
- for (int j=0; j<25;j++) printf("0x%02X ",bc[j]);
- putchar('\n');
- puts("After:");
- for (int j=0; j<25;j++) printf("0x%02X ",celldat[j]);
- putchar('\n');
- for (int j=0; j<25;j++) printf("0x%02X ",colours[j]);
- putchar('\n');
- exit(1);
- }
- }
negamax_display_progress(cur_depth, list->length);
@@ -178,7 +148,7 @@ negamax(const uint8_t cur_depth, float alpha, float beta,
if (alpha >= beta) break;
}
}
- prune:
+
action_list_free(list);
return value;
}
diff --git a/src/ctaklm.c b/src/ctaklm.c
index c395c29..dda6eb1 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -416,32 +416,11 @@ main(int argc, char **argv) {
(void)(argc);
(void)(argv);
- negamax_search_depth = 2;
+ negamax_search_depth = 5;
new_game(5);
negamax_init(5);
tt_init();
- auto_board = 1;
- auto_info = 0;
- negamax_search_depth = 4;
- for (int k=0; k<10; k++) negamax_turn();
- return 0;
-
- ply = 7; current_colour=C_BLACK;
- celldat[0x00]=0x22; colours[0x00]=0x05;
- celldat[0x01]=0x10; colours[0x01]=0x00;
- celldat[0x02]=0x11; colours[0x02]=0x00;
- print_board();
-
- action_list_t *list = action_list_generate();
-
-
- action_node_t a = {.next = NULL, .type = A_MOVE, .loc = 0x0, .data0 = 0x80, .data1 = 0x31};
- action_take(&a); print_board();
- action_undo(&a); print_board();
- return 0;
-
-
// Test harness
if (argc > 1) {
negamax_search_depth = 5;