View difference between Paste ID: vGzBAE63 and dwsJviPW
SHOW: | | - or go back to the newest paste.
1-
Lbl Down
1+
Lbl Up
2
.r₁=row scan offset
3
.r₂=column scan index
4
.r₃=column dest index
5
.r₄=last value slid
6-
 3
6+
 0
7
.For each row
8
 For(4)
9
  →r₁
10-
  0→r₄
10+
  0→r₄→r₃
11-
  12→r₃
11+
12
  For(4)
13
   →r₂
14
   .If occupied by a tile
15
   If {+r₁+L₁}
16
    .Remove original tile
17
    Select(→r₅,0→{r₁+r₂+L₁})
18
    .If equal to the last slid tile
19
    !If -r₄
20
     .Increment merged tile value
21
     {r₁+r₃-4+L₁}++
22-
     {r₁+r₃+4+L₁}++
22+
23
    Else
24
     .Store tile to destination and decrement destination index
25
     Select(r₅,→{r₃+4→r₃+r₁-4+L₁})
26-
     Select(r₅,→{r₃-4→r₃+r₁+4+L₁})
26+
27
    .Store value last slid (or garbage if a merge occured)
28
    →r₄
29
   End
30
   r₂+4
31-
   r₂-4
31+
32
  r₁+1
33-
  r₁-1
33+
34
Return