Re: Modeling events that occur in a game world



On Apr 23, 5:20 am, "Dmitry A. Kazakov" <mail...@xxxxxxxxxxxxxxxxx>
wrote:
This is why the event abstraction is not that good for more or less
elaborated physics. It would make the design of objects way too complex.
When an object is thrown, it is not a collaboration between it and the
thrower. It just flies, it need not to know what has thrown it.

Yes, the actual motion of a thrown creature needs no collaboration
with the
thrower or anything like that. But what about the AI controlling the
creature?
To be an effective AI, it needs to
1) Tell that the creature was thrown in the first place.
2) Tell who the thrower was, so that it knows who to retaliate
against.

Basically, I don't need events for the creatures or other game objects
themselves,
but for the AIs controlling them. I need the AIs be able to know when
things in
the world happen. This has little to do with the actual physics of
how the events
take place and more to do with capturing the semantic information of
what caused
something to happen and who were involved. Two Creatures attacking
each other is
fairly straightforward. Allowing the AI controlling Creature X be
able to tell that
Creature Y has attacked its friend Creature Z which should make the AI
tell X to
attack Y is what I'm having trouble with.

This discussion is turning a little too abstract for my taste, so
here's some
pseudo-code. This will ignore the player and graphics system.

Maps are a set of locations (Loc objects), where one Creature may be
at any
location. It knows what Creatures are at what locations on it, and
Creatures may be
placed at or removed from certain locations.

class Map:
list<Creature> getAllCreatures()
Creature getCreature(Loc loc)
void removeCreature(Loc loc)
void addCreature(Creature cr, Loc loc)

Creatures are things that exist on a Map, have statistics (health,
attack, etc.)
and interact with each other. It also knows where it is in the world
for the
benefit of its AI (though I haven't finalized how this relationship
will work
yet, so the movement code here may not be the best design).

class Creature:
private int health, attack

public Loc getLoc()
public Map getMap()

public void takeDamage(int atck):
this.health -= atck
if this.health <= 0:
getMap().removeCreature(getLoc())

public void attack(Creature target):
target.takeDamage(attack)

public void move(Map m, Loc loc):
getMap().removeCreature(getLoc())
// Set the Creature's Map and Loc to m and loc somehow.
m.addCreature(this, loc)

AIs encapsulate all the decision-making behavior for a Creature. They
look at the
map their "body" is on and choose an action for it.

class AI:
private Creature body

public void takeAction():
if toManyEnemies( body.getMap() ):

body.move( aPlaceThatIsFarAwayFromTheNasties( body.getMap() ) )
else if somethingHereToHunt( body.getMap() ):
body.attack( aGoodTarget( body.getMap() ) )

private bool toManyEnemies(Map map)
private Loc aPlaceThatIsFarAwayFromTheNasties(Map map)
private bool somethingHereToHunt(Map map)
private Creature aGoodTarget(Map map)

Game is a container for all the Maps (which have Creatures), and AIs,
and controls
in what order the AIs act (the main loop).

class Game:
private list<Map> allMaps
private list<AI> allAIs

public void loop():
while gameNotOver():
for a in allAIs:
a.takeAction()

private bool gameNotOver()

The missing link has to do with AIs knowing things that have happened
to their own
Creatures or to any other Creatures they'd be interested in. This
information does
not have to do with Creature actions like attacks themselves, but with
AIs being
able to infer what has happened and who were involved so that they
know who to
blame.

Sorry if I sound a bit dense, but I'm really trying to understand what
you people
are saying, and I would really like to solve this problem. Thanks for
bearing
with me.

On Apr 24, 12:12 am, Alvin Ryder <alvin...@xxxxxxxxxxx> wrote:
You're using Python, is that with some OpenGL or Direct/X wrapper or
something? Maybe Python can act as your scripting language around an
engine with speed in all the right places (usually C/C++/assembler
based). I know one really good engine that uses a dialect of LISP as
its outer layer ... so why not Python, it might be really cool.

I'm actually writing the whole thing in Python, using Pygame (a
wrapper for SDL)
for graphics and input.

.



Relevant Pages

  • Re: Modeling events that occur in a game world
    ... the actual motion of a thrown creature needs no collaboration ... Maps are a set of locations, ... Creatures are things that exist on a Map, have statistics (health, ... private int health, attack ...
    (comp.object)
  • Re: Modeling events that occur in a game world
    ... the actual motion of a thrown creature needs no collaboration ... Maps are a set of locations, ... Creatures are things that exist on a Map, have statistics (health, ... private int health, attack ...
    (comp.object)
  • Re: Tile entity stacks c++ question
    ... the Tile class from elsewhere in my progam when I need it. ... program you want to get a creature. ... Monsters are, IMHO, logically held by the *map*. ... less than the number of map cells. ...
    (rec.games.roguelike.development)
  • Re: What information is needed for AI?
    ... My initial idea was to just pass a copy of the map to the AI routine so it could make decisions. ... For the pathfinding routine, I'd just go ahead and pass it the whole map, not just what the creature can see, because A) it's easier to do, and B) the monster probably has pretty familiar knowledge of the dungeon, after living in it. ... Next, consider implementing a simplistic finite state machine, that causes the monster to chase when health is high enough, and retreat when heavily wounded. ...
    (rec.games.roguelike.development)