--- Begin Message ---
Package: freealchemist
Version: 0.4-3
Severity: normal
Tag: patch
There are some bugs in the explosion handling. Explosions on the far
left side can include tiles from the far right side. Sometimes tiles
help to start an explosion, but they don't explode. It all happens
becuase of incorrect bounds in loops and checks.
I've attached a patch which fixes this. Because it fixes the problem,
I've also removed the workaround for negative coordinates (which was
buggy anyway).
Finally, I didn't do anything about it, but find it highly confusing
that the vertical coordinate is called "x" and the horizontal coordinate
is called "y"...
Thanks,
Bas
diff -urp freealchemist-0.4.orig/debian/patches/02_extend_explode.patch freealchemist-0.4/debian/patches/02_extend_explode.patch
--- freealchemist-0.4.orig/debian/patches/02_extend_explode.patch 2010-09-19 13:33:33.000000000 +0200
+++ freealchemist-0.4/debian/patches/02_extend_explode.patch 2010-09-19 13:32:06.000000000 +0200
@@ -1,7 +1,7 @@
-diff -Nurp freealchemist-0.4.orig/freealchemist.py freealchemist-0.4/freealchemist.py
---- freealchemist-0.4.orig/freealchemist.py 2009-02-15 13:52:52.000000000 +0100
-+++ freealchemist-0.4/freealchemist.py 2009-02-15 13:53:04.000000000 +0100
-@@ -33,6 +33,8 @@ import sys
+diff -Nur -x '*.orig' -x '*~' freealchemist-0.4/freealchemist.py freealchemist-0.4.new/freealchemist.py
+--- freealchemist-0.4/freealchemist.py 2010-09-19 12:30:52.000000000 +0200
++++ freealchemist-0.4.new/freealchemist.py 2010-09-19 13:27:45.000000000 +0200
+@@ -33,6 +33,8 @@
import random
width = 6
@@ -10,7 +10,7 @@ diff -Nurp freealchemist-0.4.orig/freeal
class freealchemist:
def __init__(self):
-@@ -95,9 +97,9 @@ class freealchemist:
+@@ -95,9 +97,9 @@
# Riempie la griglia
self.grid = []
@@ -22,7 +22,7 @@ diff -Nurp freealchemist-0.4.orig/freeal
line.append(0)
self.grid.append(line)
-@@ -118,7 +120,7 @@ class freealchemist:
+@@ -118,15 +120,19 @@
if random.randint(1,30) == 25:
self.nextblock = [[random.randint(14,16),random.randint(1,self.lim)],[0,0]]
@@ -30,13 +30,39 @@ diff -Nurp freealchemist-0.4.orig/freeal
+ else:
self.nextblock = [[random.randint(1,self.lim),random.randint(1,self.lim)],[0,0]]
-
-@@ -182,12 +184,12 @@ class freealchemist:
+-
++ def onBoard(self, x, y):
++ return x >= 0 and x < len(self.grid) and y >= 0 and y < len(self.grid[0])
++
++ def test(self, x, y, dx1, dy1, dx2, dy2, t):
++ return self.onBoard(x+dx1,y+dy1) and self.onBoard(x+dx2,y+dy2) and self.grid[x+dx1][y+dy1] == t and self.grid[x+dx2][y+dy2] == t
+
+ def updateGame(self):
+ # Controlla se ci son spazi vuoti da riempire
+ md = False
+- for x in xrange(len(self.grid)-1,0,-1):
++ for x in xrange(len(self.grid)-1,-1,-1):
+ for y in xrange(0, len(self.grid[0])):
+ s = 0
+ for a in xrange(len(self.grid)): s += self.grid[a][y]
+@@ -141,8 +147,8 @@
+
+ # Controlliamo se possiamo far esplodere qualcosa :P
+ if not self.mov:
+- for x in xrange(-1,len(self.grid)-1):
+- for y in xrange(-1,len(self.grid[0])-1):
++ for x in xrange(0,len(self.grid)):
++ for y in xrange(0,len(self.grid[0])):
+ # La pressa
+ if self.grid[x][y] == 15 and x == len(self.grid)-2:
+ self.grid[len(self.grid)-2][y] = 0
+@@ -181,13 +187,12 @@
+ # Normale
elif self.grid[x][y] != 0 and self.grid[x][y] < 13:
t = self.grid[x][y]
- if (self.grid[x][y+1] == t and self.grid[x][y-1] == t) or (self.grid[x+1][y] == t and self.grid[x-1][y] == t) or (self.grid[x+1][y] == t and self.grid[x][y+1] == t) or (self.grid[x-1][y] == t and self.grid[x][y-1] == t) or (self.grid[x-1][y] == t and self.grid[x][y+1] == t) or (self.grid[x+1][y] == t and self.grid[x][y-1] == t):
+- if (self.grid[x][y+1] == t and self.grid[x][y-1] == t) or (self.grid[x+1][y] == t and self.grid[x-1][y] == t) or (self.grid[x+1][y] == t and self.grid[x][y+1] == t) or (self.grid[x-1][y] == t and self.grid[x][y-1] == t) or (self.grid[x-1][y] == t and self.grid[x][y+1] == t) or (self.grid[x+1][y] == t and self.grid[x][y-1] == t):
- if self.grid[x][y] < 12: self.grid[x][y] += 1
-+
++ if self.test (x, y, 0, 1, 0, -1, t) or self.test (x, y, 1, 0, -1, 0, t) or self.test (x, y, 1, 0, 0, 1, t) or self.test (x, y, -1, 0, 0, -1, t) or self.test (x, y, -1, 0, 0, 1, t) or self.test (x, y, 1, 0, 0, -1, t):
+ #upgrade our center piece
+ if t < 12: self.grid[x][y] += 1
else: self.grid[x][y] = 0
@@ -49,7 +75,7 @@ diff -Nurp freealchemist-0.4.orig/freeal
self.points += (t*10)+t*t
if t-1 > self.lim and t-1 < 13: self.lim += 1
-@@ -204,7 +206,28 @@ class freealchemist:
+@@ -204,7 +209,23 @@
elif sum(self.grid[1]) > 0: self.fail += 1
else: self.fail = 0
if self.fail > 2: self.over = True
@@ -58,20 +84,15 @@ diff -Nurp freealchemist-0.4.orig/freeal
+
+ #Explode the piece at position x,y if type == t
+ #and also explode all touching pieces of the same type.
-+ def explode(self,xx,y,t) :
-+ #sometimes xx is -1. It's a bug we workaround here
-+ if xx == -1 :
-+ x = size_x - 1
-+ else :
-+ x = xx
++ def explode(self,x,y,t) :
+ if self.grid[x][y] == t :
+ self.grid[x][y] = 0
+ #recursively explode touching pieces of the same type
-+ if (y >= 0) :
++ if (y > 0) :
+ if self.grid[x][y-1] == t: self.explode(x,y-1,t)
+ if (y < len(self.grid[0])-1) :
+ if self.grid[x][y+1] == t: self.explode(x,y+1,t)
-+ if (x >= 0) :
++ if (x > 0) :
+ if self.grid[x-1][y] == t: self.explode(x-1,y,t)
+ if (x < len(self.grid)-1) :
+ if self.grid[x+1][y] == t: self.explode(x+1,y,t)
signature.asc
Description: OpenPGP digital signature
--- End Message ---