examples/2048: Refactoring

This commit is contained in:
Hajime Hoshi 2016-07-28 22:34:20 +09:00
parent 30a16cbcbe
commit 0a04ed1c22

View File

@ -110,14 +110,16 @@ func (b *Board) Move(dir Dir) {
if ni < 0 || ni >= b.size || nj < 0 || nj >= b.size {
break
}
tt := b.tileAt(ni, nj)
tt := tileAt(nextTiles, ni, nj)
if tt == nil {
ii = ni
jj = nj
continue
}
nt := tileAt(nextTiles, ni, nj)
if t.value == tt.value && (nt == nil || !merged[nt]) {
if t.value != tt.value {
break
}
if !merged[tt] {
ii = ni
jj = nj
}