Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, TipmyPip, tomaslolo), 788 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[AI] message handling system #119388
03/25/07 21:14
03/25/07 21:14
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi,

I am trying to implement a message system for communication between teams and players.

Code:


function messageHandler(Sender, Receiver, Message)
{
messageSender = sender;
messageReceiver = receiver;
messageCmd = message;
messageReceiver._ds_messageCommand = ds_messageCmd;
//ds_mgsDelete();
}




I have a team state machine and imagine the team in STATE1 sends a message to respective players:

Code:

msgGoHome(my, player1, MCgoHome);
msgGoHome(my, player2, MCgoHome);
msgGoHome(my, player3, MCgoHome);
...




And now in the player state machine - State goHome

Code:
 
if(my._messageCommand == MCgoHome)
{
selectPlayerState(my, stateGoHome);
}




The problem is: i need to find a good way to delete the message, because if the team stays in STATE1 (loop) it will send always that message and i cant change the player state to another one.

So, ideas about this?
Thanks in advance.

Re: [AI] message handling system [Re: demiGod] #119389
03/26/07 08:13
03/26/07 08:13
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Hey Demigod,

If you've designed your team FSM properly, then your STATE1 should have 3 parts, Entry, Update, and Exit. So instead of sending your message constantly, only do it once when your FSM enters the STATE1 state


Code:

function State_STATE1()
{
//On Entry
msgGoHome(my, player1, MCgoHome);
msgGoHome(my, player2, MCgoHome);
msgGoHome(my, player3, MCgoHome);
...


while (...) //enter your transition logic here, or in a break; statement
{
//On Update
...

wait(1);
}


//On Exit
...
}




And i guess you'll want to destroy the message after it has been received too..

Code:

if(my._messageCommand == MCgoHome)
{
selectPlayerState(my, stateGoHome);
my._messageCommand=0;
}





Cheers,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: [AI] message handling system [Re: LarryLaffer] #119390
03/26/07 08:49
03/26/07 08:49
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi Larry,

Yes, the team and player FSMs have three methods / parts (enter, update and exit) and only the update part its a loop, its funny but i tried to call the messages in the enter part and it wont work too.. and apparently theres no reason for that, i will need to find where is the problem..

BTW Larry, as an expert on AI, do you thing this is a good and modular approach to implement a messaging system or do you have a better advice on that matter?

And what about a time stamp? How can i implement that?
Thanks, i really apreciate your help.

Re: [AI] message handling system [Re: demiGod] #119391
03/26/07 11:31
03/26/07 11:31
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Hey demigod,

I think you're doing the right thing by doing all the homework before tackling something as complex as Team AI. I've seen you're using code by Steve Rabin and Matt Buckland, so honestly, my advice is worth nothing against these guys.. I mean, if I, Steve and Matt would be working together, i'd be the guy bringing them coffee if you know what I mean..


Anyhow, although your system will work fine, I think i'd take a different approach. I don't really like how you use a Team state machine to control your agents. You are building a simulation title, so wouldn't you want to program everything like it actually happens in real life? In teams, there's no god figure directing every player what to do at any given time. Each player has his own mind and makes decisions on his own... maybe using the same strategy that their coach have tought them, but he's still responsible for his own actions..

So instead I'd use polling. I trust that you know what this term means by now. It's very very easy in theory, and gives extremely life-like results.. It goes like this:

Every player has his own mind. All players have a fixed set of goals that they evaluate every few seconds. If it's, say, a soccer game, the goals could be: attemptToScore, passTo(teamMate), stealBallFrom(player), GoToFormation(formation), etc.. Every few seconds, they poll the world in order to get information about the current state of the whole game.. where his teammates are, where the opponent players are, who has the ball, time remaining for match, currect score... everything... From the information they polled, they evaluate each and every one of their goals... So in a scenario that a player whose team is winning the match 3-2, there are only 5 mins left on the clock, he is an attacker, and the opponent have the ball, he'll evaluate all of his goals.. (f.e. the goal attemptToScore would have a fitness rating of 0, given the fact that he doesn't even have the ball), and the goal GoToFormation(defendingFormation) would score high.. so that's what he'd do.

This is the best modular solution I can think of, since you can just keep adding-removing goals in order to keep the same AI architecture working for an arbitary number of games. The other advantage of this method is that users won't be able to "solve" the AI as easily as they can with an FSM.


For a messaging system, you may want to consider making a Blackboard system instead. You can learn about blackboards from anywhere on the net. Your system will work fine, but I see that you're concerned about modularity and clean code and all that, so you will be able to see the advantages over the messaging system you're using. In your current example, you'll need to have your team FSM message each and every one of the players individually. Then, if someone has the ball, i'm guessing you'd want to have that player message the team back saying he has the ball, and the team then messages all other players about what to do next, resulting in a bit of spaghetti logic. Using a blackboard, every player can write stuff in it, like "I(player3) have the ball!", or "I(player8) will attempt to steal the ball from opponent player5". In your example, you can use a blackboard to have the team FSM write in the blackboard: "Everyone Go Home". Then, every player will poll the Blackboard as a transition statement in their own FSM, saying: "If blackboard query: "Everyone Go Home" is true, then selectPlayerState(my, stateGoHome);.


For a time stamp, i take it you want to schedule messages... you can do this for your current system like this..


Code:

function messageScheduler(Sender, Receiver, Message, DelayInSecs)
{
wait(-DelayInSecs);
messageHandler(Sender, Receiver, Message);
}





You're doing good by researching everything closely before actually going into coding, and at the very least you'll learn a lot from it. There's never one way to do things, so if you find something that works for you, then you're good.. If it works, don't break it As you read about more and more AI concepts, you'll eventually develop an instinct to judge for yourself what will work best for your current needs.


Cheers!
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: [AI] message handling system [Re: LarryLaffer] #119392
03/26/07 22:44
03/26/07 22:44
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline OP
User
demiGod  Offline OP
User

Joined: Mar 2006
Posts: 752
Portugal
Hi Larry !

Thank you for the great considerations and advices you gave.

You are right, i am studing Matt Bucklandīs stuff but also other things like autonomous agents and Multi Agents Systems trying to understand which can be one of the better ways to do what i want. MAS are a hard task to implement so i collect ideas and ways to solve the problems.

Btw, as you mentioned the agents should have its own mind and goals / roles to anchieve, but i am messing up for some time ago with a confused concept (confused for me yet..) which is a MASTER MIND that will govern and command the teams strategy and tactics, like a high-level decision module that will say in such a game situations (world status model), which will be the strategy that each team should follow..

On the other hand, i think it will be necessary an action selection system at agent level too, well i think i need to study a little more the situation, and the big problem i think will be the strategic positioning of the agents in the field.. too much math for me..

I will test the polling and message blackboard systems you mentioned and decide if it will fit my needs or not.

Thanks again Larry.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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