Re: AisleRiot: two new games



Callum McKenzie wrote:

Unfortunately one bug I haven't been able to shake out of this is that undo/redo don't seem to correctly save the "rows" vector, which keeps track of which cards aren't in sequence, which can lead to out-of-sequence cards getting stuck if you fiddle with undo. I did use the def-save-var macro, but I'm not sure what else to try.

The def-save-var macro should work. If it doesn't then the bug is in the
macro and not your code. As far as I can tell the only thing unusual is
that you try saving a list - which is an untested case. I'll look into
it.


I've been playing around with this and noticed something odd. I altered (record-move) in sol.scm as follows:

(define (record-move slot-id old-cards)
  (set! MOVE (list undo-func
                   (list (get-score) FLIP-COUNTER
                         (save-variables variable-list))
                   (snapshot-board 0 slot-id old-cards)))
  (display HISTORY)
  (newline)
  (newline)
)

and fired up Gaps and hit "New game" a few times until I got one with an open first column gap (slot 0). I then made two moves before filling that gap, and got this (my apologies for the length:)

()

((#<procedure undo-func (data)> (0 0 (#((0 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)))) (() ((8 3 #t)) ((2 2 #t)) ((8 1 #t)) ((3 1 #t)) ((5 1 #t)) ((6 1 #t)) ((2 0 #t)) () ((10 0 #t)) ((12 1 #t)) ((9 0 #t)) ((12 0 #t)) ((13 0 #t)) ((10 3 #t)) ((10 2 #t)) ((4 2 #t)) ((11 1 #t)) ((6 2 #t)) ((8 0 #t)) ((6 3 #t)) ((9 3 #t)) () ((13 1 #t)) ((9 1 #t)) ((2 3 #t)) ((11 3 #t)) ((4 0 #t)) ((2 1 #t)) ((4 1 #t)) ((3 2 #t)) ((13 2 #t)) ((8 2 #t)) ((12 3 #t)) ((10 1 #t)) ((9 2 #t)) ((7 0 #t)) ((11 0 #t)) ((7 2 #t)) ((5 0 #t)) ((6 0 #t)) ((4 3 #t)) ((5 2 #t)) ((12 2 #t)) ((7 3 #t)) ((7 1 #t)) ((5 3 #t)) ((3 0 #t)) ((13 3 #t)) ((3 3 #t)) ((11 2 #t)) ())))

((#<procedure undo-func (data)> (0 0 (#((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)))) (() ((8 3 #t)) ((2 2 #t)) ((8 1 #t)) ((3 1 #t)) ((5 1 #t)) ((6 1 #t)) ((2 0 #t)) () ((10 0 #t)) ((12 1 #t)) ((9 0 #t)) ((12 0 #t)) ((13 0 #t)) () ((10 2 #t)) ((4 2 #t)) ((11 1 #t)) ((6 2 #t)) ((8 0 #t)) ((6 3 #t)) ((9 3 #t)) ((10 3 #t)) ((13 1 #t)) ((9 1 #t)) ((2 3 #t)) ((11 3 #t)) ((4 0 #t)) ((2 1 #t)) ((4 1 #t)) ((3 2 #t)) ((13 2 #t)) ((8 2 #t)) ((12 3 #t)) ((10 1 #t)) ((9 2 #t)) ((7 0 #t)) ((11 0 #t)) ((7 2 #t)) ((5 0 #t)) ((6 0 #t)) ((4 3 #t)) ((5 2 #t)) ((12 2 #t)) ((7 3 #t)) ((7 1 #t)) ((5 3 #t)) ((3 0 #t)) ((13 3 #t)) ((3 3 #t)) ((11 2 #t)) ())) (#<procedure undo-func (data)> (0 0 (#((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)))) (() ((8 3 #t)) ((2 2 #t)) ((8 1 #t)) ((3 1 #t)) ((5 1 #t)) ((6 1 #t)) ((2 0 #t)) () ((10 0 #t)) ((12 1 #t)) ((9 0 #t)) ((12 0 #t)) ((13 0 #t)) ((10 3 #t)) ((10 2 #t)) ((4 2 #t)) ((11 1 #t)) ((6 2 #t)) ((8 0 #t)) ((6 3 #t)) ((9 3 #t)) () ((13 1 #t)) ((9 1 #t)) ((2 3 #t)) ((11 3 #t)) ((4 0 #t)) ((2 1 #t)) ((4 1 #t)) ((3 2 #t)) ((13 2 #t)) ((8 2 #t)) ((12 3 #t)) ((10 1 #t)) ((9 2 #t)) ((7 0 #t)) ((11 0 #t)) ((7 2 #t)) ((5 0 #t)) ((6 0 #t)) ((4 3 #t)) ((5 2 #t)) ((12 2 #t)) ((7 3 #t)) ((7 1 #t)) ((5 3 #t)) ((3 0 #t)) ((13 3 #t)) ((3 3 #t)) ((11 2 #t)) ())))

Notice the removal of slot 0 from the vector seems to have been retroactively applied to every entry in the history. If this were in C I'd say a pointer to that array was getting stored in the history instead of a copy of its value at the time...

--
Zach Keene




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]