Game - Map data structures

Innocence (a dot) innocenceklogdk
Fri Jun 18 15:58:36 CEST 2004

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
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.
Each Tile has an object (class), but the type of object depends on
whether it's a Water or Land Tile:
- A Land object needs data structures for each of the six hex corners
(ie. does a given hex-side contain a Coastline, a Mountain, a Bridge
etc.) + data for buildings (Castle, Harbour etc.). Finally it needs
links to which armies reside on the Tile.
- A Water object need only links to which armies reside on the Tile
(ie. sailing armies/fleets).
So it seems to me I could save not only a fair deal of memory but also
processor power on 80% of the Tiles drawn: With each Land Tile I have
to check Hex Side values and building lists to draw special features.
All this is totally unnecessary with Water Tiles.
If anyone here could tell me how to make such a data-set, where each
Tile/element might be one of two object types, I'd really appreciate
it :)
0:) Innocence

More information about the Python-list mailing list