Game - Map data structures
Dan Bishop
danb_83 at yahoo.com
Sat Jun 19 02:08:27 EDT 2004
More information about the Python-list mailing list
Sat Jun 19 02:08:27 EDT 2004
- Previous message (by thread): Remove spaces and line wraps from html?
- Next message (by thread): Game - Map data structures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Innocence <innocence(a)klog(dot)dk> wrote in message news:<lts5d0pi0nhk02ri15pofo6k7b52n1fi3r at 4ax.com>... > Hi > > I've been considering how to optimize map data structures for a tile > based Python game. However, since I'm a Python newbie I lack > experience with Pythons 'exotic' data types like lists and tuples, and > thus I'm unsure whether such types could solve my problem. > > My basic thought is this: If my world map consists of 80% water and > 20% land, then why reserve full data-structures for all the water > tiles? > > I'm looking for a way to do the following: > > My World Map object should likely be a standard (x,y) array of Tiles > (unless there's a better way?) > Each Tile has a boolean/one-bit value: 0 or False for Water, 1 or True > for Land. A better way is to have the class hierarchy like class Tile(object): def __init__(self, ...): # data that any Tile can contain self.armies = ... ... class WaterTile(Tile): pass class LandTile(Tile): def __init__(self, ...): Tile.__init__(self, ...) # data specific to land tiles self.building = ...
- Previous message (by thread): Remove spaces and line wraps from html?
- Next message (by thread): Game - Map data structures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list