-
Notifications
You must be signed in to change notification settings - Fork 0
/
day13-gamegrid.el
60 lines (49 loc) · 1.2 KB
/
day13-gamegrid.el
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
(setq min-x 1000)
(setq max-x -1)
(setq min-y 1000)
(setq max-y -1)
(maphash (lambda (key value)
(setq min-x (min min-x (car key)))
(setq max-x (max max-x (car key)))
(setq min-y (min min-y (cdr key)))
(setq max-y (max max-y (cdr key)))
)
(gethash 'tiles bot))
nil
min-x
;; => 0
max-x
;; => 37
min-y
;; => 0
max-y
19
;; => 19
(require 'gamegrid)
(require 'tetris)
(setq program (make-program problem1))
(setq amp (make-amp program))
(puthash 0 2 program)
(defun day13-start ()
(interactive)
(switch-to-buffer "*TILES*")
(gamegrid-init (tetris-display-options))
(gamegrid-init-buffer 40 21 9)
(let* ((program (make-program problem1))
(amp (make-amp program)))
(run-amplifier amp)))
(day13-start)
(defun bot-get (bot)
1)
(setq score-x 0)
(setq score-y 20)
(defun show-tiles (tiles)
(maphash (lambda (key value)
(gamegrid-set-cell
(car key) (cdr key) value))
(gethash 'tiles bot)))
(defun show-score (score)
(let ((score-string (format "Score: %05d" score)))
(dotimes (x (length score-string))
(gamegrid-set-cell (+ x score-x) score-y (aref score-string x)))))
(show-score 100)