From b77da9b3135e5f1a77e3759db7adca50f8df443d Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 26 Nov 2017 11:14:26 +0100 Subject: Add Markov chain test --- test/Makefile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/Makefile (limited to 'test/Makefile') diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..3b9b4a7 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,27 @@ +EXE:=Test +DEP:=ArbitraryMove +AUX:=$(addsuffix .o, $(EXE) $(DEP))\ + $(addsuffix .hi, $(EXE) $(DEP))\ + $(addsuffix .dyn_o, $(EXE) $(DEP))\ + $(addsuffix .dyn_hi,$(EXE) $(DEP)) +SRC:=$(addsuffix .hs,$(DEP)) +GHC:=ghc +GHCFLAGS:=-O -main-is Test.main + +.PHONY=all data run clean + +all: $(EXE) + +dataset.pgn: + for i in $$(seq 1000 1020); do wget -q http://www.theweekinchess.com/zips/twic$${i}g.zip; unzip -q twic$${i}g.zip; rm twic$${i}g.zip; done + cat twic*.pgn > $@ + $(RM) twic*.pgn + +run: $(EXE) + ./$(EXE) < dataset.pgn + +$(EXE): %: %.hs $(SRC) + $(GHC) $(GHCFLAGS) $< -o $@ + +clean: + $(RM) $(EXE) $(AUX) -- cgit v1.2.3 From 3b3752d5bd9c21f24072f6f6030938d85a48bc11 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 26 Nov 2017 13:35:48 +0100 Subject: Cleanup --- test/ArbitraryMove.hs | 12 ++---------- test/Makefile | 12 ++++++++---- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'test/Makefile') diff --git a/test/ArbitraryMove.hs b/test/ArbitraryMove.hs index e786a68..4c6fb48 100644 --- a/test/ArbitraryMove.hs +++ b/test/ArbitraryMove.hs @@ -19,15 +19,7 @@ instance Arbitrary Board where arbitrary = return defaultBoard type Move = String arbitraryMove :: Gen Move -arbitraryMove = frequency - [ (2, probableArbitraryMove) - --, (1, invalidMove) - ] - where - invalidMove :: Gen Move - invalidMove = oneof - [ liftM2 (\r c -> [r,c]) (choose ('i', 'z')) (elements "09") - ] +arbitraryMove = probableArbitraryMove instance Arbitrary PGN where @@ -69,7 +61,7 @@ instance Arbitrary PGN - on a set of PGN games, e.g. from http://theweekinchess.com/twic. -} -probableArbitraryMove :: Gen String +probableArbitraryMove :: Gen Move probableArbitraryMove = frequency $ map (return <$>) [ (8, "a1=B") , (2, "a1=B+") diff --git a/test/Makefile b/test/Makefile index 3b9b4a7..ba62dab 100644 --- a/test/Makefile +++ b/test/Makefile @@ -7,21 +7,25 @@ AUX:=$(addsuffix .o, $(EXE) $(DEP))\ SRC:=$(addsuffix .hs,$(DEP)) GHC:=ghc GHCFLAGS:=-O -main-is Test.main +DATA:=dataset.pgn -.PHONY=all data run clean +.PHONY=all run clean all: $(EXE) -dataset.pgn: +$(DATA): for i in $$(seq 1000 1020); do wget -q http://www.theweekinchess.com/zips/twic$${i}g.zip; unzip -q twic$${i}g.zip; rm twic$${i}g.zip; done cat twic*.pgn > $@ $(RM) twic*.pgn -run: $(EXE) - ./$(EXE) < dataset.pgn +run: $(EXE) $(DATA) + ./$(EXE) < $(DATA) $(EXE): %: %.hs $(SRC) $(GHC) $(GHCFLAGS) $< -o $@ clean: $(RM) $(EXE) $(AUX) + +distclean: clean + $(RM) $(DATA) -- cgit v1.2.3