Re: Coding monsters and items



At 15 May 2006 07:38:13 -0700,
Jeff Lait wrote:

Radomir 'The Sheep' Dopieralski wrote:
I'll point out that I disagree with your claim that having a flag that
is only set for one monster or only set for one object is "expensive".
It isn't.

Well, they are not necessarily expensive in terms of complexity of the
data files and their parser. But what they inevitably complicate is the
space of all possible monsters/items.

With a special case, you only have one special monster. With a flag, you
suddendly have 2*(number of flags so far) new potential monsters. And
even when you don't really use any of them, you usually take some care
to ensure that any combination of the flags at least doesn't crash your
program (and at most, that every combination is sane).

Besides, I had to think up some disadvantages of the approach -- for
balance ;)

It also forms my
counter argument to the complaint that special cased code is impossible
to follow the logic of. By requiring all the special cases related to
a behaviour exist in a single place, you can get a birds eye view of
their interaction.

Not impossible, but requires discipline and caution to maintain. And
that's additional work. Also note that the special case code usually
describes interactions, and thus can belong into several different
places. By putting all the special case code into one of the places,
you make it easier to analyze -- but at the same time you make all
the other places harder to analyze.

Every time you have to think of what you need to analyze and where
you want it to be easy for your convenience. This inevitably involves
decissions, and decissions are hard and often make you err. Of course,
programming is all about making those decissions -- but still you
can choose the easier path... ;)


--
Radomir `The Sheep' Dopieralski
.



Relevant Pages

  • [Announcement] FuryBand 3.0.0 Released
    ... Added in New Flag, SENS_ACID. ... Added in New Flag, KIN_PROTECT, when the monster with this flag is killed, it ... New Attack Effect: CHAOS ... Added in Throwing Weapons, with a throwing skill. ...
    (rec.games.roguelike.angband)
  • [ann, t-engine] T-Engine/ToME/ODE 300alpha17 aka "Triumph or Agony" released
    ... doors and chests, and BASH_DOOR if you want the player to be able to ... To make a player incapable of moving, use the flag CANNOT_MOVE. ... - Searching has been made into a loadable lua subsystem. ... Improved the monster escort system. ...
    (rec.games.roguelike.announce)
  • Re: Moving large numbers of monsters in close formation
    ... Add a "no-push" flag to each monster. ... set its no-push flag again. ... creatures to the front when the player is engaged in meelee ...
    (rec.games.roguelike.development)
  • Re: XBand and sCthangband - activity?
    ... If the monster having this flag gets hurt, and the player ... (most likely abusing LOS), Flying Skulls of Retribution will be ...
    (rec.games.roguelike.angband)
  • Re: Application hangs for several seconds on idle CPU
    ... Found the cause of the problem: I was calling SetWindowPos to a window ... the SWP_ASYNCWINDOWPOS flag), the application no longer freezes. ... I am trying to analyze a problem where my application will - for no ...
    (microsoft.public.windowsxp.perform_maintain)