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