Welcome to GameHourz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Delayed effects

 
   Game Forums (Home) -> Roguelike -> Development RSS
Next:  Merlin Weldments  
Author Message
ds_creamer

External


Since: Mar 09, 2006
Posts: 36



(Msg. 1) Posted: Thu Mar 23, 2006 4:43 pm
Post subject: Delayed effects
Archived from groups: rec>games>roguelike>development (more info?)

I had a few ideas for the implementation of delayed effects in a
roguelike, and I'd appreciate some feedback.

(1) The actor/mob/monster/whatever class gets a counter for poison,
one for confusion, one for a delayed effect. These are checked when
appropriate, and decremented(to a minimum of 0) every time the thing
moves. This means that I need a counter for every possible delayed or
lasting effect.

(2) The next idea I had was some sort of event queue. I then
researched the idea and discovered that queues probably aren't for me
or my roguelike.

The first idea seems promising; it allows delayed effects(counter==0)
to work just like lasting effects(counter>0). However, it doesn't allow
me to set delayed effects on items or on the map, and requires each
possible effect to be programmed individually.

How are you making this work? Thanks!

 >> Stay informed about: Delayed effects 
Back to top
Login to vote
gatti

External


Since: Mar 10, 2005
Posts: 97



(Msg. 2) Posted: Fri Mar 24, 2006 2:15 am
Post subject: Re: Delayed effects [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

ds_creamer wrote:
> I had a few ideas for the implementation of delayed effects in a
> roguelike, and I'd appreciate some feedback.
>
> (1) The actor/mob/monster/whatever class gets a counter for poison,
> one for confusion, one for a delayed effect. These are checked when
> appropriate, and decremented(to a minimum of 0) every time the thing
> moves. This means that I need a counter for every possible delayed or
> lasting effect.

> (2) The next idea I had was some sort of event queue. I then
> researched the idea and discovered that queues probably aren't for me
> or my roguelike.

If you explain your perplexities you'll get a lot of help about
priority queues.

> The first idea seems promising; it allows delayed effects(counter==0)
> to work just like lasting effects(counter>0). However, it doesn't allow
> me to set delayed effects on items or on the map, and requires each
> possible effect to be programmed individually.

A priority queue has the advantage that it represents one delayed
effect with one object, a "X happens to Y at time T" command, and it
processes it once at time T.
With counters, you process every effect type for every object at every
time step, wasting time and space on things that aren't happening and
duplicating counter logic for different effects and different affected
objects.
Moreover, the functionality is more limited: an event queue can contain
multiple delayed effects of the same type for the same creature (e.g.
the next falling asleep test from a lingering spell and from fatigue),
a counter only has one value.

Lorenzo Gatti

 >> Stay informed about: Delayed effects 
Back to top
Login to vote
ds_creamer

External


Since: Mar 09, 2006
Posts: 36



(Msg. 3) Posted: Fri Mar 24, 2006 5:57 am
Post subject: Re: Delayed effects [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks for the response, Lorenzo. After I posted, I searched this group
for older posts on the same topic, and found some great descriptions of
how a priority queue works. I had the wrong idea of what a queue like
this actually was--it's perfect! The best I found is:
Find the lowest 'energy' in the queue(or have previously sorted it)->
Subtract that value from all in the queue->
Give that actor/event its turn(because its 'energy' is now 0)->
Repeat. Right now, I'm learning what I need to do to:
1. Make the queue. I could use a list as my queue, right? Do I want
to?(i.e. is it efficient?)
2. Either (a) have the queue accept normal actors AND events, giving
actors their normal turn when their time comes, or (b) have the queue
accept only events, and simply make one event 'this actor gets a turn'.
I thought of (b) as I was typing, so I guess I'll use that one. =d
I think this looks promising. Any opinions?
 >> Stay informed about: Delayed effects 
Back to top
Login to vote
Ray Dillinger

External


Since: Jun 01, 2004
Posts: 260



(Msg. 4) Posted: Fri Mar 24, 2006 9:44 am
Post subject: Re: Delayed effects [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

ds_creamer wrote:
> Thanks for the response, Lorenzo. After I posted, I searched this group
> for older posts on the same topic, and found some great descriptions of
> how a priority queue works. I had the wrong idea of what a queue like
> this actually was--it's perfect! The best I found is:
> Find the lowest 'energy' in the queue(or have previously sorted it)->
> Subtract that value from all in the queue->
> Give that actor/event its turn(because its 'energy' is now 0)->
> Repeat.


Or equivalently in logic but at lower CPU costs:
Find the thing that has the lowest "next action" time.
Update the system time to match its "next action" time.
Let it perform its action.
Update its "next action" time by adding the amount of time
its action takes.
Repeat.

If you are clever you can code this to take sublinear
time w/r/t the number of things that act. If you don't
feel clever, you can code it in linear time and then
replace it later if it becomes a performance bottleneck.

Bear
 >> Stay informed about: Delayed effects 
Back to top
Login to vote
Tomas Andersson

External


Since: Mar 24, 2006
Posts: 1



(Msg. 5) Posted: Fri Mar 24, 2006 9:55 am
Post subject: Re: Delayed effects [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Fri, 24 Mar 2006 14:57:55 +0100, ds_creamer
<dcreamer0001.RemoveThis@email.vccs.edu> wrote:

> Thanks for the response, Lorenzo. After I posted, I searched this group
> for older posts on the same topic, and found some great descriptions of
> how a priority queue works. I had the wrong idea of what a queue like
> this actually was--it's perfect! The best I found is:
> Find the lowest 'energy' in the queue(or have previously sorted it)->
> Subtract that value from all in the queue->

As long as there aren't too many things in the queue I guess that's ok.
In my RL I have a time variable that stores the current time and when I
add an Item that should happen after 100 ticks I add it with (time + 100)
as the key, that way I don't have to update the entire queue every time.

> Give that actor/event its turn(because its 'energy' is now 0)->
> Repeat. Right now, I'm learning what I need to do to:
> 1. Make the queue. I could use a list as my queue, right? Do I want
> to?(i.e. is it efficient?)
Depending on which programming language there might be something even
better included, Java has the PriorityQueue class and I'm pretty sure
there is something similar in c++'s STL.

> 2. Either (a) have the queue accept normal actors AND events, giving
> actors their normal turn when their time comes, or (b) have the queue
> accept only events, and simply make one event 'this actor gets a turn'.
> I thought of (b) as I was typing, so I guess I'll use that one. =d
> I think this looks promising. Any opinions?
>

(b) sounds like pretty much exactly what I have in my project. I have a
abstract class Event with a method called execute() that is called when
it's that events to happen, then I extend that class for every type of
event. Some events I have now are PlayerMoveEvent MonsterMoveEvent
FireSpreadEvent, TimedExplosiveEvent (that one is fun. Smile),
PlayerRegenHealthEvent and so on.
 >> Stay informed about: Delayed effects 
Back to top
Login to vote
Ray Dillinger

External


Since: Jun 01, 2004
Posts: 260



(Msg. 6) Posted: Sat Mar 25, 2006 10:29 am
Post subject: Re: Delayed effects [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Colin MacIntyre wrote:
> "Ray Dillinger" <bear.TakeThisOut@sonic.net> wrote in message
> news:44242f4c$0$58064$742ec2ed@news.sonic.net...


>>If you are clever you can code this to take sublinear
>>time w/r/t the number of things that act. If you don't
>>feel clever, you can code it in linear time and then
>>replace it later if it becomes a performance bottleneck.
>
>
> Sorry, what is w/r/t?

With respect to. I mean to say that you can make the
process take time less than proportional to the number
of things that have a "next action" coming up.

The implementation ds_creamer mentioned would take
linear time. That is, there's an element where you
update everybody's "time left" that takes twice as
long if you have twice as many actors, and there's
nothing that grows with number of actors at a rate
worse than that.

A "classic algorithms" priority queue can take
logarithmic time -- that is, there's an element
that grows such that with twice as many actors it
would take one step longer.

But with dungeon movement in particular there are
regularities about the problem that allow you, for
very few restrictions, to code something that's
*not* a classic priority queue and lets you do things
in constant time or very close to it.

Bear
 >> Stay informed about: Delayed effects 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
7DRL: Invader - Well, I've talked myself into attempting a game for the 7DRL challenge. :-) Invader will be a sci-fi RL where the player is the planet's only hope of stopping a dread alien invasion ship. The character's base of operations will be their docked ship. ....

7DRL: TBA! :P - I'm going to throw my hat into the 7drl arena by taking on a project I've wanted to do for ages. I think it will get me past the mental block of actually getting started. My concept is based around the remains of a post apocalyptic world with gang..

7DRL : Commander - It is 13.40 in my time zone (GMT +100). Time to start my 7DRL project: Commander. I will do it in Free Pascal. Plans are quite big so there is real danger of failure. Good luck to all participants of 7DRL contest. -- Michal ''Ancient'' Bielinski

7DRL : Valley of Ge-Hinnom - Info : @ goes chase to Moloch, java, using my library, so if I fail at least I can post an updated library. T.

7DRL - Deserted... - Okay, Here's to learning new things :) I am beginning work on my 7DRL, Deserted. Everybody loves waking up on a desert island, right? C++, dev-cpp, minGW... no curses.. I'm just beginning to dip into that. So, everyone get ready for a monochromatic..
   Game Forums (Home) -> Roguelike -> Development All times are: Ekaterinburg, Islamabad, Karachi, Tashkent (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]