-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
104 lines (79 loc) · 4.38 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Pipemaze.hs this is the solver
notes scratchpad & benchmark data
samples/ here are the samples
problems/ tiny files for ironing out problems
shell.nix declares all dependencies in nix
presentation
https://www.youtube.com/watch?v=tqhWM-uTPjw
documentation
http://raitis.veinbahs.lv/maze/doc/Pipemaze.html
solve videos
http://raitis.veinbahs.lv/maze/content/
--
running
nix-shell shell.nix --run 'ghc Main.hs -o solve && ./solve samples/2'
running with websocket
nix-shell shell.nix --run 'ghc Main.hs -o solve && time bench=True websocket=maze-server/pipes/#1,2,3,4,5,6 ./solve'
generate docs
haddock Pipemaze.hs -o haddock -h --hyperlinked-source --quickjump
fun things to do for visualizations:
remove coloring by equivalent parts in renderWithPositions
screw with the score variable in sortContinues (this will likely lead to bad solve times)
increase the frequency to see more intermediate steps
environment variables
websocket=maze-server-host/websocket-path/#1,2,3,4,5,6,6,6
hide=True # hides passwords
bench=True # skips debug output/image creation
debug=0 # debug modes: 0=show %, 1=print maze, 2=print color maze, 3=2+clear screen, 4=make image, 5=images only during islands
freq=10377 # call debug routine once every $freq iterations
--
benchmarking
% time ghc Main.hs -o solve && time bench=True ./solve ./samples/6-01
% time ghc Main.hs -o solve -threaded -with-rtsopts='-N4' && time bench=True ./solve trash/samples/{6..1}-01
with profiler
% ghc Main.hs -o solve -prof -fprof-auto -rtsopts -with-rtsopts='-p' -fexternal-interpreter && bench=True ./solve samples/5
print trace of crash
% ghc Main.hs -o solve -prof -with-rtsopts='-xc' && ./solve samples/2
restrict heap
$ ghc Main.hs -o solve -rtsopts -with-rtsopts='-M1024m' && ./solve samples/3
run 8 cores
% ghc Main.hs -o solve -threaded -with-rtsopts='-N8' && time ./solve ./samples/3
:l solve without having to resolve all type errors (amazing!)
% ghci -fdefer-type-errors
--
with trace=4 you can make images in images/
after creating images you can animate them by running ./images/animate without any arguments (uses last directory)
insert this after "initSolve" to generate all solutions (works for 1..5 levels)
flip (iterateMaybeM 1000) (p, 0) $ \(p, n) -> do
p <- solve' p
traverse ((liftIO . putStrLn =<<) . liftIO . renderStr . (\Progress{maze} -> maze)) p
fmap (, n + 1) <$> traverse (renderImage' ("solution-" ++ show n)) p
error "die"
-- AND comment out the following line:
solve' p@Progress{depth, maze=MMaze{size}} | depth == size = pure (Just p) -- remove this to compute all solutions
--
get more samples
% (set -x; for i in {1..50}; do suffix=-$i ./samples/get 4 &; done; wait < <(jobs -p))
get 50 samples per level
% (set -x; for level in {1..6}; do for i in {01..50}; do format="trash/samples/%i-$i" ./samples/get $level &; done; done; wait < <(jobs -p))
--
┏╸╺┓┏━╸╻┏━━╸╺┳╸╻╻╻╻╺┳╸┏━┓
┗┳┳┻┻╸╻┣╋╸╻╻╺┫┏┫┃┣┫╻┗┳┻┓╹
┏┛┗━━┓┗┫╹╺┫┗┳┛╹┣┛╹┗╋╸┃╻┗╸
┣━┳━╸┗┳╋━┓┣━╋╸╺╋╸╺┓┗┓┃┃┏┓
╹┏┻┓┏┓┃┣┓┃┃╺┫╺┳┫╺┓┃┏┻┫┣┛╹
╻┣╸╹╹┗┫┃╹┃┗╸┣━┛╹╻┣┫┃╺┻╋┓╻
┗┻╸╻┏┓╹╹╻┗┓╺┻┳━╸╹┣╋┻┓╻╹╹┃
╺┓┏┛┃┣┓╻┗┳┻┓┏┛╻┏━┫┗╸┗┛┏━┛
╻┗┫╺┛╹┗┻━┫╺┫┣━┻┻┓┗╸╺┓╺╋━╸
┃╻┣━━━┓╺━┫╻┗┛┏┳╸┣╸┏━┫┏╋┓╻
┃┃┃╺┓╻┃┏┳┛┗┳━┛┃╺┫╺┫╻┗┛╹┗┫
┣┻┛╺╋┻┛╹┃╺┓┣━╸╹╺╋━╋┻╸╻╻┏┫
╹┏┳━╋┳╸┏┻┓┣┛╺┳┓┏╋╸╹┏┳╋┻┫╹
╻┃┗╸┃┗┳┛╺╋┛╻╻╹┃┃╹╺┓╹┃┣╸┗╸
┣╋━╸╹┏╋━╸┗━┛┣╸┣┻━┳┫╻╹┃╻┏╸
┃┣╸╻╻╹┃╻╺━┓┏┛╺┻┳╸╹┃┣╸┃┃┣╸
╹╹╻┗╋━┻┛╺┳┛┗━┓╻┗╸╺┻┻┓┃┃┣┓
╻╻┣┳┻┳━╸┏┻━┳┓┣┻━━┳━┳┛┣┻┛┃
┣┻┫┃╻┗┳╸┣┓╺┫┣╋╸╺━┛┏┛╻┃╻╺┫
╹╺┛╹┗━┛╺┛╹╺┛╹┗━━╸╺┻╸┗┻┻╸╹