Re: Data compression in roguelikes
- From: Gerry Quinn <gerryq@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 9 Jul 2006 11:29:49 +0100
In article <slrneb04l1.dbr.news@xxxxxxxxxxxxxxxxxxxx>,
news@xxxxxxxxxxxx says...
At Sat, 8 Jul 2006 20:58:08 +0100,
Gerry Quinn wrote:
In article <slrneb0221.96f.news@xxxxxxxxxxxxxxxxxxxx>,
news@xxxxxxxxxxxx says...
At Sat, 8 Jul 2006 20:06:04 +0100,
Gerry Quinn wrote:
Most people use both! When a fireball explodes at a position, don't
you want to find the nearby monsters?
Sure I do. I check all the creatures nearby (from a list) and see how
far they are from the explosion. Much faster than drawing the disc on
the map and scanning through it. And also much simplier (I know, you
think Breshenham circle drawing algorithm is simple too).
Bresenham? Circle? No need for either - fireball affects a disc. You
scan the enclosing square.
CRect rect( position, CSize( 1, 1 ) );
rect.InflateRect( spellRadius, spellRadius );
rect &= GetMapRect();
That should do it. Just check each square for distance.
Right. It's the same, only you also check the empty squares.
21% of the squares are outside the disc. What percentage of the
monsters are?
Btw, you can do better:
rsquare = radius*radius
for y in range(-radius, radius):
width = (y*y-rsquare)**0.5 # <-- this can be optimized further
for x in range(-width, width)
map[x,y].do_damage()
I don't see how that's better. And is there a built-in check in
whatever language that is that you don't go outside the map array, if
your fireball happens to be near the edge? I don't see any in the
code.
[Obviously you don't need to take square roots anywhere - you can
compare squared distances.]
I'm really not sure what your getting here. And computation is so
cheap nowadays...
I only want to note that as the projects become more complicated,
more advanced algorithm are used and the whole thing becomes more
similar to the MVC model (dos rogue storing its map directly in
the graphics memory, come on), the 2d array model becomes more and
more inapropriate.
I disagree. Roguelike combat takes place in a granular space that maps
perfectly onto a 2D array. This is the fundamental spatial matrix of
the roguelike universe! How can it be inappropriate?
This kind of thinking was popular in medieval ages among the
doctors. They said: look, this root looks perfectly like an ear!
It must be appropriate for healing deafness!
What I'm saying is that the array data structure reflects a fundamental
feature of the world model of a typical roguelike. Sure, it does some
things less well than alternatives, but it does other things better.
And it can live perfectly well along with other data structures.
Since when you can measure game quality and tlak about it in percentiles?
Besides, I'm talking program quality here, not the playing experience.
This includes maintanability of code and ease with which you can add
features to it. And find bugs.
Well, yes. You haven't shown how using an array affects either.
Not to mention certain elegance, which, being programmers, we should
admire. If you write a game for fun, you can as well write it nicely.
There is nothing inelegant about arrays. They are a fundamental data
structure, good for modelling all sorts of things, and easy to
understand and use.
- Gerry Quinn
.
- Follow-Ups:
- Re: Data compression in roguelikes
- From: Radomir 'The Sheep' Dopieralski
- Re: Data compression in roguelikes
- References:
- Data compression in roguelikes
- From: darkstar949
- Re: Data compression in roguelikes
- From: Crypt
- Re: Data compression in roguelikes
- From: gf
- Re: Data compression in roguelikes
- From: Radomir 'The Sheep' Dopieralski
- Re: Data compression in roguelikes
- From: Gerry Quinn
- Re: Data compression in roguelikes
- From: Radomir 'The Sheep' Dopieralski
- Re: Data compression in roguelikes
- From: Gerry Quinn
- Re: Data compression in roguelikes
- From: Radomir 'The Sheep' Dopieralski
- Re: Data compression in roguelikes
- From: copx
- Re: Data compression in roguelikes
- From: Radomir 'The Sheep' Dopieralski
- Re: Data compression in roguelikes
- From: Gerry Quinn
- Re: Data compression in roguelikes
- From: Radomir 'The Sheep' Dopieralski
- Re: Data compression in roguelikes
- From: Gerry Quinn
- Re: Data compression in roguelikes
- From: Radomir 'The Sheep' Dopieralski
- Data compression in roguelikes
- Prev by Date: Re: Roguelike names
- Next by Date: Re: The Best Way (TM) to Implement Objects
- Previous by thread: Re: Data compression in roguelikes
- Next by thread: Re: Data compression in roguelikes
- Index(es):
Relevant Pages
|