Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, AndrewAMD), 911 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Other than state machines #184403
02/17/08 02:55
02/17/08 02:55
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Not sure how to form this question, but Im going to try and explain whatever Im thinking right now.

ATM I am working on a State Machine AI, so far its reletively easy to implement, but exhaustive. So far I have many different states, some using the same pathfinding functions, which means alot of states might seem redundant. However I do understand that it could be made more modular, such as giving the entity only 1 pathfinding state, but changing the target node variable within that state. But this is the first AI state machine Ive made that works pretty well, so its a learning experience.

So far the problems I have is transitioning from state to state without noticable pauses. The state switching is more apparent when the AI is playing an animation and switching to a different state.

Another apparent sign of a state machine is when the AI state must perform a critical function that requires the AI to wait on other entities to send information back to the AI. This usually means a wait(); must be excecuted until relevent information the AI needs is received. This single wait may seem harmless, but is jarringly noticable for a moving, shooting, thinking AI. An example of this is finding the closest node to the AI, finding the closest enemy to the AI, scanning for enemies, cycling through a huge list or etc.

The only alternative I thought of was splitting the entity into 2 or more entities, each doing their part, even if some are still. I will continue using the single entity state machine for my current game, but would like to split it up for my next game.

My idea was to have the pathfinding function of a soldier be handled by a seperate pathfinding entity, while the animation and "tactical" thinking would be handled by the "model" entity. This way, when my soldier entity has to freeze for a single frame to calculate the A* path, his animation and AI thinking would continue to run, in attempts to help smooth over any stops in movement.

I would like to know if anyone has done a mix of state machines and fussy state machines, and how they went about their AI. Im not asking for code, just experience from people implementing this using 3dgs if possible.

Re: Other than state machines [Re: jumpman] #184404
02/17/08 19:22
02/17/08 19:22
Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
C
Christian__A Offline
User
Christian__A  Offline
User
C

Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
I don't understand why you want to use 2 entities for your ai-functions? You can also split up your ai into many functions.

An simple example:
Code:

function ai_loop
{
while (1)
{
ai_think(); //This function retrieves information about the entities environment
ai_act(); //Here the entity realy moves, shoots...
wait(1);
}
}



ai_think sets variables like what_to_do_next... as soon as ai_act is ready with its current action (like shooting), it starts with the work specified in what_to_do_next...


MfG, Christian__A. Visit my Site: www.chris-a.de


Re: Other than state machines [Re: Christian__A] #184405
02/18/08 02:59
02/18/08 02:59
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
You could even play some animation like "standing" "seaching" while it is doing some extensive AI calculations.


I like good 'views' because they have no 'strings' attached..
Re: Other than state machines [Re: zazang] #184406
02/18/08 16:48
02/18/08 16:48
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Yeah, you should split up the functions and keep them as short as possible. Obviously pathfinding and so on will require some larger functions, but you can camouflage quite a bit with animations and so on,

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Other than state machines [Re: PHeMoX] #184407
02/18/08 17:58
02/18/08 17:58
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline
Expert
A.Russell  Offline
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Pathfinding can very processor intensive and is best threaded out, or at least limitted by how many nodes/arcs are processed at one time.

Pathfinding is not really a good state to use. States could be, waiting, walking, fighting... an enity might change state from waiting to walking because of a result from the pathfinding algorithm, for example.

Which still leaves you with the problem of what if an entity changes state while it is still searching for a path (or other critical function)? When the pathfinding (or other critcal function) completes, it sends a message to the affected/ calling entity and the entity then decides what to do with it depending on the state it is in at that time. If changing state means that the pathfinding is no longer relevant, a request to stop searching can be sent. By sending messages between objects, everything can run autonomously. For your animation problem, you don't neccessarily have to stay in the same state because an animation is playing. If you are halfway through a run animation and your player switches to walk, have the walk state begin the walk animation from when the run animation reaches its keyframe.

Fuzzy logic is good if you want it possible for your entity to be in more than one state at any time. For example, in a state of GoingForPowerUp while ShootingTheCrapOutOfEverythingInSight.

Re: Other than state machines [Re: A.Russell] #184408
02/19/08 08:24
02/19/08 08:24
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline
Senior Member
msl_manni  Offline
Senior Member
M

Joined: Dec 2005
Posts: 478
India
The problem that Jumpman is having is the way he is coding. He is using wait(); everywhere so the function associated with the ai would pause in that particular frame. I would suggest that you should not use wait unless it is very necessary. Try to multitask your functions. Avoid waits() as these leads to poor programming. There are ways to circumvent it and then you can implement many behavioural types like suggested by others, brain searching for targets, for camouflage, managing health, talking to buddies, etc. Try to think all the tasks a human can handle simaltaneously, yet we have only two parts of brain, one concious, and second sub-concious.


My Specialities Limited.
Re: Other than state machines [Re: msl_manni] #184409
02/22/08 18:39
02/22/08 18:39
Joined: Aug 2002
Posts: 572
Toronto
MadMark Offline
User
MadMark  Offline
User

Joined: Aug 2002
Posts: 572
Toronto
Hmm, seems the manual and advice in this forum is to use wait() in order to synchronize frames, allow functions to complete, and reduce coding collisions. You have some magic method that eliminates the need for wait()?

Care to share, msl_manni? This old dog is not a great programmer, so I would love to learn new tricks.

Mark


People who live in glass houses shouldn't vacuum naked.
Re: Other than state machines [Re: MadMark] #184410
02/23/08 03:19
02/23/08 03:19
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline
Senior Member
msl_manni  Offline
Senior Member
M

Joined: Dec 2005
Posts: 478
India
Dont be sarcastic. I said that use wait only in situations only necessary. But my dear friend, you are abusing it by using it everywhere. If you post your code then I might show my magic. But for that you have to be polite.


My Specialities Limited.
Re: Other than state machines [Re: msl_manni] #184411
03/13/08 01:30
03/13/08 01:30
Joined: Aug 2002
Posts: 572
Toronto
MadMark Offline
User
MadMark  Offline
User

Joined: Aug 2002
Posts: 572
Toronto
LOL

No insult intended. Just curious what method you were using to overcome the need to "abuse" wait. Fair enough, no special methods. Of course eliminating unnecessary waits would optimize code. Sometimes you do have to just hurry up and politely wait(!).

Cheers!


People who live in glass houses shouldn't vacuum naked.
Re: Other than state machines [Re: MadMark] #201088
04/06/08 21:14
04/06/08 21:14
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
An example would be:
 Code:
Function DoThinking
{
	// Maybe search all ents for specific entity
	you = ent_next (NULL); // retrieve first entity
 	while (you != NULL) // repeat until there are no more entities
	{ 
		if(you == entIamlookingfor){dosomething...}
 		you = ent_next (you); // get next entity
 	}
}

Function Take Action
{
	turn to face entIamlookingfor... etc

}

Function AiBrain()
{

	While(me){
		DoThinking();
		TakeAction();
		wait(1);
}


In this example there is only one wait command, in the parent loop. The while loop within the DoThinking, does not wait, it searches ALL entities in 1 frame.

Hope that helps \:\)


The Art of Conversation is dead : Discuss
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1