[Tutor] Improving My Simple Game Code for Speed, Memory and Learning
wolfrage8765 at gmail.com
Sat Jan 3 16:54:33 CET 2015
On 01/03/2015 06:58 AM, Dave Angel wrote:
> My error. Since nodes are GameTile objects, not values, converting to a
> tuple is a little trickier:
> values = tuple( [node.value for node in nodes] )
> if values in table:
I will try an implement this after I see what values winds up yielding.
> For example, print_by_col would look just like print_by_row, except that
> it would start with self.transposed_grid
> The only real assumption needed for this simplification is that once the
> grid is set up, you never create any more GameTile objects, just
> manipulate the existing rectangle of objects.
> To transpose a grid, you want to use the zip() function.
> self.transposed_grid = zip(*self.grid)
Thanks for the example of making the transposed_grid. I will implement this.
Also your assumption is correct, once the grid is created it never gets
changed as far as it's structure, only the game tiles with in are
manipulated, and at that we just change there appearance and value.
More information about the Tutor