Fixed rolling stone overanxious transpose bug.
Šī revīzija ir iekļauta:
		@@ -90,7 +90,7 @@ class Level3(level.Level):
 | 
			
		||||
 | 
			
		||||
        pos_colour = {}
 | 
			
		||||
        for box, (x, y) in zip(boxes, itertools.product(range(3, 6), range(3, 6))):
 | 
			
		||||
            self.tiles.append(tile.Tile(self, x * 64, (y + 1) * 48, self.imgs['ground1']))
 | 
			
		||||
            self.tiles.append(tile.Tile(self, x * 64, y * 48, self.imgs['ground1']))
 | 
			
		||||
            pos_colour[(x, y)] = box
 | 
			
		||||
 | 
			
		||||
        blocks = [ActionBlock(self, 64 * i, 0, action=None, movable=True)
 | 
			
		||||
 
 | 
			
		||||
@@ -100,6 +100,7 @@ def generate_simple_playfield(width, height, nturns, nstones,
 | 
			
		||||
        do_transpose = random.choice((True, False))
 | 
			
		||||
    if do_transpose:
 | 
			
		||||
        width, height = height, width
 | 
			
		||||
        min_width, min_height = min_height, min_width
 | 
			
		||||
 | 
			
		||||
    turns = [((0, 0), None)]
 | 
			
		||||
    stones = []
 | 
			
		||||
@@ -142,6 +143,8 @@ def generate_simple_playfield(width, height, nturns, nstones,
 | 
			
		||||
                    Right: Down,
 | 
			
		||||
                    Up:    Left,
 | 
			
		||||
                    }.get(d)) for ((x, y), d) in turns]
 | 
			
		||||
        width, height = height, width
 | 
			
		||||
        min_width, min_height = min_height, min_width
 | 
			
		||||
 | 
			
		||||
    used_fields = _fields_from_turns(turns)
 | 
			
		||||
    playfield = {}
 | 
			
		||||
@@ -158,12 +161,12 @@ def generate_simple_playfield(width, height, nturns, nstones,
 | 
			
		||||
        playfield[pos] = Blocker
 | 
			
		||||
    return playfield, len(used_fields) - 1
 | 
			
		||||
 | 
			
		||||
def generate_simple_unsolved_solvable_playfield(width, height, nturns, nstones):
 | 
			
		||||
def generate_simple_unsolved_solvable_playfield(*args, **kwds):
 | 
			
		||||
    """
 | 
			
		||||
    Return a tuple of a playfield without direction objects, its number of
 | 
			
		||||
    steps, and a list of the direction objects.
 | 
			
		||||
    """
 | 
			
		||||
    playfield, steps = generate_simple_playfield(width, height, nturns, nstones)
 | 
			
		||||
    playfield, steps = generate_simple_playfield(*args, **kwds)
 | 
			
		||||
    new_playfield, directions = {}, []
 | 
			
		||||
    for pos, val in playfield.items():
 | 
			
		||||
        if val is Blocker:
 | 
			
		||||
@@ -172,16 +175,17 @@ def generate_simple_unsolved_solvable_playfield(width, height, nturns, nstones):
 | 
			
		||||
            directions.append(val)
 | 
			
		||||
    return new_playfield, steps, directions
 | 
			
		||||
 | 
			
		||||
def generate_simple_unsolved_solvable_extra(width, height, nturns, nstones):
 | 
			
		||||
def generate_simple_unsolved_solvable_extra(*args, **kwds):
 | 
			
		||||
    """
 | 
			
		||||
    Do the same as generate_simple_unsolved_solvable, but throw in some copies
 | 
			
		||||
    of the direction object not returned by that function. You probably want to
 | 
			
		||||
    use this in your game.
 | 
			
		||||
    """
 | 
			
		||||
    playfield, steps, directions = generate_simple_unsolved_solvable_playfield(
 | 
			
		||||
        width, height, nturns, nstones)
 | 
			
		||||
        *args, **kwds)
 | 
			
		||||
    missing_dir = list(set(all_directions) - set(directions))[0]
 | 
			
		||||
    return playfield, steps, directions + [missing_dir] * (len(directions) / 3)
 | 
			
		||||
    return playfield, steps, directions + \
 | 
			
		||||
        [missing_dir] * (len(directions) / 3) + [Right]
 | 
			
		||||
 | 
			
		||||
def print_playfield(playfield, width, height, hide_directions):
 | 
			
		||||
    text = [['·' for _ in range(width)] for _ in range(height)]
 | 
			
		||||
 
 | 
			
		||||
@@ -36,10 +36,10 @@ class RollingStoneTest(unittest.TestCase):
 | 
			
		||||
            reaches_goal(playfield, 10, 10, steps, (0, 0), (9, 9)))
 | 
			
		||||
 | 
			
		||||
        print()
 | 
			
		||||
        playfield, steps = generate_simple_playfield(10, 10, 4, 11)
 | 
			
		||||
        print_playfield(playfield, 10, 10, True)
 | 
			
		||||
        playfield, steps = generate_simple_playfield(10, 15, 4, 150)
 | 
			
		||||
        print_playfield(playfield, 10, 15, False)
 | 
			
		||||
        self.assertTrue(
 | 
			
		||||
            reaches_goal(playfield, 10, 10, steps, (0, 0), (9, 9)))
 | 
			
		||||
            reaches_goal(playfield, 10, 15, steps, (0, 0), (9, 14)))
 | 
			
		||||
        
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    unittest.main()
 | 
			
		||||
 
 | 
			
		||||
		Atsaukties uz šo jaunā problēmā
	
	Block a user