Skip to content

Commit

Permalink
Fix Make file
Browse files Browse the repository at this point in the history
Now we can use 'make ttt_option=mcts to let AI use Monte-Carlo
and default with negamax
  • Loading branch information
HotMercury committed Mar 28, 2024
1 parent 45c13ee commit bf465a7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
33 changes: 22 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@ CFLAGS += -Wvla

GIT_HOOKS := .git/hooks/applied
DUT_DIR := dudect
all: $(GIT_HOOKS) ttt qtest

ttt:
make -C ttt_game/ lab0
all: $(GIT_HOOKS) ttt_start qtest

lab0 = ttt_mode
ttt_option :=
ifeq ($(ttt_option), mcts)
TTT = ttt_game/start.o ttt_game/agents/mcts.o ttt_game/game.o
else ifeq ($(ttt_option), rl)
TTT = ttt_game/start.o ttt_game/agents/reinforcement_learning.o ttt_game/game.o
else ifeq ($(ttt_option), train)
TTT = ttt_game/train.o ttt_game/agents/reinforcement_learning.o ttt_game/game.o
else
TTT = ttt_game/game.o \
ttt_game/mt19937-64.o \
ttt_game/zobrist.o \
ttt_game/agents/negamax.o \
ttt_game/start.o
endif
ttt_start:
make -C ttt_game/ $(lab0) MODE=$(ttt_option)

tid := 0

Expand Down Expand Up @@ -43,16 +58,12 @@ $(GIT_HOOKS):
OBJS := qtest.o report.o console.o harness.o queue.o \
random.o dudect/constant.o dudect/fixture.o dudect/ttest.o \
shannon_entropy.o \
linenoise.o web.o sort_impl.o \
ttt_game/game.o \
ttt_game/mt19937-64.o \
ttt_game/zobrist.o \
ttt_game/agents/negamax.o \
ttt_game/start.o
linenoise.o web.o sort_impl.o


deps := $(OBJS:%.o=.%.o.d)

qtest: $(OBJS)
qtest: $(OBJS) $(TTT)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) $(LDFLAGS) -o $@ $^ -lm

Expand Down
30 changes: 23 additions & 7 deletions ttt_game/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROG = ttt
CFLAGS := -Wall -Wextra -std=c11
CFLAGS := -g -Wall -Wextra -std=c11
CFLAGS += -I. -MMD
LDFLAGS :=
TRAIN = train
Expand All @@ -22,20 +22,36 @@ deps += $(RL).d
deps += $(TRAIN).d
deps += $(MCTS).d

lab0: $(OBJS)
ttt_mode: $(MODE) $(OBJS)

$(OBJS) : %.o : %.c
$(CC) $(CFLAGS) -c $^ -o $@

$(PROG): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)

$(RL): main.c agents/reinforcement_learning.c game.c
$(CC) -o $@ $^ $(RL_CFLAGS)
$(RL): start.c agents/reinforcement_learning.c game.c
$(CC) -o start.o -c start.c $(RL_CFLAGS)
$(CC) -o agents/reinforcement_learning.o -c agents/reinforcement_learning.c $(RL_CFLAGS)
$(CC) -o game.o -c game.c $(RL_CFLAGS)


$(TRAIN): $(TRAIN).c agents/reinforcement_learning.c game.c
$(CC) $(CFLAGS) -o $@ $^
$(CC) -o train.o -c train.c $(CFLAGS)
$(CC) -o agents/reinforcement_learning.o -c agents/reinforcement_learning.c $(CFLAGS)
$(CC) -o game.o -c game.c $(CFLAGS)



$(MCTS): start.c agents/mcts.c game.c
$(CC) -o start.o -c start.c $(MCTS_CFLAGS) $(MCTS_LDFLAGS)
$(CC) -o agents/mcts.o -c agents/mcts.c $(MCTS_CFLAGS) $(MCTS_LDFLAGS)
$(CC) -o game.o -c game.c $(MCTS_CFLAGS) $(MCTS_LDFLAGS)

$(MCTS): main.c agents/mcts.c game.c
$(CC) -o $@ $^ $(MCTS_CFLAGS) $(MCTS_LDFLAGS)

# for i in $^ ; do \
# $(CC) -o $@ -c $$i $(MCTS_CFLAGS) $(MCTS_LDFLAGS); \
# done
clean:
-$(RM) $(PROG) $(OBJS) $(deps) $(TRAIN) $(RL) $(MCTS)
-$(RM) *.bin

0 comments on commit bf465a7

Please sign in to comment.