diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-17 21:06:04 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 8915093ce1ed103cc52481118e1ab47bec663236 (patch) | |
| tree | 31364afb829258d83688e95e02b17fbcda0cf918 | |
| parent | e2530bfb517b7a0dc0a9d3b6c7e3d074258b1405 (diff) | |
Revert "Starting work on MCU port"
This reverts commit 43eec01361eb6174142180c29afef960e041514e.
| -rw-r--r-- | .clang_complete | 2 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 47 | ||||
| -rw-r--r-- | include/ct1986.c | 4 | ||||
| -rw-r--r-- | src/ctaklm.c | 4 | ||||
| -rw-r--r-- | src/mcu.c | 76 |
6 files changed, 7 insertions, 128 deletions
diff --git a/.clang_complete b/.clang_complete index c98e7b6..e9c2aee 100644 --- a/.clang_complete +++ b/.clang_complete @@ -1,4 +1,2 @@ -Iinclude/ -I3rd-party/ --I/usr/lib/gcc/avr/10.2.0/include/ --I/usr/avr/include/ @@ -2,5 +2,3 @@ data/ ctaklm pptdb -mcu.hex -*.s @@ -1,7 +1,4 @@ IDIR=include - -# ------------------------------------------------------------------- -# Computer stuff TPDIR=3rd-party DEFINES=-DDETERMINISTIC CFLAGS=-O3 -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE $(DEFINES) -I$(IDIR) -I$(TPDIR) @@ -14,27 +11,6 @@ PROG=ctaklm STAT=pptdb SIZE=size -# ------------------------------------------------------------------- -# MCU stuff -MCU=atmega32u4 -F_CPU=20000000UL -ACC=avr-gcc -ACFLAGS=-Os -Wall -fpack-struct -fshort-enums -funsigned-bitfields -funsigned-char -I$(IDIR) -AOBJCOPY=avr-objcopy -AOBJSIZE=avr-size - -AVRDUDE=avrdude -ADFLAGS=-p $(MCU) -c avr109 -b 57600 -P /dev/serial/by-id/usb-Arduino_LLC_Arduino_Micro-if00 - -TARGET=mcu -AHEX=$(TARGET).hex -ASRC=src/$(TARGET).c $(wildcard include/*.c) -AOBJ=$(patsubst %.c, %.o, $(ASRC)) -AASM=$(patsubst %.c, %.s, $(ASRC)) - -# ------------------------------------------------------------------- -# Targets - %.o: %.c cc -c $< -o $@ $(CFLAGS) @@ -45,25 +21,8 @@ $(PROG): src/$(PROG).o $(OBJS) $(STAT): src/$(STAT).o $(OBJS) $(CC) $(CFLAGS) src/$(STAT).o $(OBJS) -o $(STAT) -avr: $(AHEX) $(AASM) ASUMMARY upload - -$(AHEX): $(AOBJ) - $(AOBJCOPY) -S -j .text -j .data -O ihex $< $@ - -$(AOBJ): $(ASRC) - $(ACC) $(ACFLAGS) -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(ASRC) -o $@ - -%.s: %.c - $(ACC) -S $(ACFLAGS) -DF_CPU=$(F_CPU) -mmcu=$(MCU) $< -o $@ - -ASUMMARY: $(AOBJ) - @echo ---------------------------------------------------------------------- - @$(AOBJSIZE) $(AOBJ) $(AHEX) - -upload: $(TARGET).hex - $(AVRDUDE) $(ADFLAGS) -D -U flash:w:$<:i - clean: - rm -f $(PROG) $(STAT) $(OBJS) - rm -f $(AOBJ) $(AHEX) $(AASM) + rm -f $(PROG) + rm -f $(STAT) rm -f src/*.o + rm -f $(OBJS) diff --git a/include/ct1986.c b/include/ct1986.c index 88cba26..1d1d253 100644 --- a/include/ct1986.c +++ b/include/ct1986.c @@ -41,7 +41,7 @@ ct1986_evaluate_black_win(void) { for (uint8_t kx = 0; kx < KERN_SIZE; kx++) { for (uint8_t c = 0; c < KERN_CHAN; c++) { // Where we are on the board - const uint8_t loc = kx+by+(ky+bx)*board_size; + const uint8_t loc = kx+by+(ky+bx)*5; // Look up what's on the board at this location, and // multiply it. For c=0 we have to do some extra work float lookup = 0; @@ -129,7 +129,7 @@ static enum WIN_TYPE w; #define WIN_EVALUATE_OR_RECURSE(store) { \ w = 0xFF; \ - if (ply >= 2*board_size - 2) w = check_win(); \ + if (ply >= 2*5 - 2) w = check_win(); \ if (w < 0xFF) { \ /* Somebody won, assign weights accordingly */ \ if (min == 0) { \ diff --git a/src/ctaklm.c b/src/ctaklm.c index 9f5af4d..d2208a0 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -198,8 +198,8 @@ handle_turn(char *line) { uint8_t new_win = (won == 0xFF); switch (do_ptn(line)) { // Errors - case PTN_INVALID: { puts("Invalid PTN."); return EXIT_FAILURE; break; } - case ACT_ILLEGAL: { puts("Illegal action."); return EXIT_FAILURE; break; } + case PTN_INVALID: { puts("Invalid PTN."); return -1; break; } + case ACT_ILLEGAL: { puts("Illegal action."); return -1; break; } case ACT_OVERFLOW: { puts("Move would cause internal overflow, select another."); return EXIT_FAILURE; diff --git a/src/mcu.c b/src/mcu.c deleted file mode 100644 index 7248200..0000000 --- a/src/mcu.c +++ /dev/null @@ -1,76 +0,0 @@ -#include <avr/io.h> -#include <tak.h> -#include <ct1986.h> - -#define EXIT_SUCCESS 0 -#define EXIT_FAILURE -1 - -/* - * static int - * handle_turn(char *line) { - * // Track win state - * uint8_t new_win = (won == 0xFF); - * switch (do_ptn(line)) { - * // Errors - * case PTN_INVALID: { return EXIT_FAILURE; break; } - * case ACT_ILLEGAL: { return EXIT_FAILURE; break; } - * case ACT_OVERFLOW: { return EXIT_FAILURE; break; } - * // Game has ended - * case GAME_END: { - * // Did it end this turn? - * if (new_win) { - * switch (won) { - * case WIN_DRAW: { break; } - * case WIN_FLAT_BLACK: { break; } - * case WIN_FLAT_WHITE: { break; } - * case WIN_ROAD_BLACK: { break; } - * case WIN_ROAD_WHITE: { break; } - * } - * } - * if (! new_win) return EXIT_FAILURE; - * break; - * } - * // Valid, append to game log - * case PTN_VALID: - * case ACT_OK: { break; } - * } - * return EXIT_SUCCESS; - * } - */ - -static void -dot(const uint8_t depth) { - PORTD ^= _BV(4); -} - - -static int -ct1986_turn(const uint8_t max_depth) { - // Prepare progress bar - // Run the minimax - float minimax = ct1986_generate(max_depth); - // Failed to find a move? - if ((minimax <= -infty && (ply & 1) == 1) - ||(minimax >= infty && (ply & 1) == 0)) { - // puts("] Opponent concedes!"); - return EXIT_FAILURE; - } else { - do_ptn(ct1986_ptn); - return EXIT_SUCCESS; - } -} - - -int main(void) { - DDRD = _BV(0) | _BV(4); - PORTD = 0; - - reset_state(5); - ct1986_display_progress = ˙ - PORTD = _BV(0) | _BV(4); - ct1986_turn(1); - PORTD = 0; - - while (1); - return 0; -} |
