Re: Data compression in roguelikes



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
.



Relevant Pages

  • Re: Data compression in roguelikes
    ... Gerry Quinn wrote: ... think Breshenham circle drawing algorithm is simple too). ... perfectly onto a 2D array. ... indistinguishable from the quality of a game that uses 5% of CPU. ...
    (rec.games.roguelike.development)
  • Re: help with creating an array
    ... > how to creat an array that draws a square ... An array does not do anything (like drawing a square), ...
    (comp.lang.java.help)
  • Re: Data compression in roguelikes
    ... Gerry Quinn wrote: ... think Breshenham circle drawing algorithm is simple too). ... perfectly onto a 2D array. ... It means that the quality of a game that uses 15% of CPU is almost ...
    (rec.games.roguelike.development)
  • Re: Chess boards & connections.
    ... and 16 for White to start, and since each pawn ... How many choices for a square do ... All I needed was the 2D Array ... complications when calculating possable moves. ...
    (sci.math)
  • Re: Segmentation Fault
    ... it still dumps core (but it takes a little longer to do ... gdb instantly shows me that it crashed on line 10. ... So you're trying to run i all the way up to INT_MAX, square it, and use ... that as an index into an array of INT_MAX elements. ...
    (comp.lang.c)