 |
|  |
 |
|
player1
|
 |
Belgrade, YU
Sep 2001 time: 06:15
|
|
Has anyone tried to make code like this?
PHP:
HandleEvent(NextStrategicState) 'StrategiesSpecial' pre {
int_t my_cities;
int_t strat_rnd;
player[0] = g.player;
my_cities = player[0].cities;
strat_rnd = random(100);
if (strat_rnd <= 50) {
if (HasAdvance(player[0], ID_ADVANCE_AERODYNAMICS)
|| HasAdvance(player[0], ID_ADVANCE_SUPERSONIC_FLIGHT)
|| HasAdvance(player[0], ID_ADVANCE_ADVANCED_COMPOSITES)) {
ConsiderStrategicState(player[0], 9800, StrategyDB(STRATEGY_AIR_SPECIAL));
}
}
strat_rnd = random(100);
if (strat_rnd <= 33) {
if (HasAdvance(player[0], ID_ADVANCE_GUIDED_WEAPON_SYSTEMS)) {
ConsiderStrategicState(player[0], 9900, StrategyDB(STRATEGY_MISSILE_SPECIAL));
}
}
strat_rnd = random(100);
if (strat_rnd <= 50) {
if (HasAdvance(player[0], ID_ADVANCE_NATIONALISM)
|| HasAdvance(player[0], ID_ADVANCE_NEURAL_INTERFACE)) {
ConsiderStrategicState(player[0], 9800, StrategyDB(STRATEGY_SPECIAL_SPY));
}
}
strat_rnd = random(100);
if (strat_rnd <= 33) {
if (HasAdvance(player[0], ID_ADVANCE_NUCLEAR_POWER)
&& WonderOwner(WonderDB(WONDER_NANITE_DEFUSER)) < 0) {
if (my_cities > 35) {
ConsiderStrategicState(player[0], 9900, StrategyDB(STRATEGY_THE_MAXIMUM_NUKES));
}
if (my_cities <= 35 && my_cities > 20) {
ConsiderStrategicState(player[0], 9900, StrategyDB(STRATEGY_THE_AVERAGE_NUKES));
}
if (my_cities <= 20 && my_cities > 6) {
ConsiderStrategicState(player[0], 9900, StrategyDB(STRATEGY_THE_MINIMAL_NUKES));
}
if (my_cities <= 6) {
ConsiderStrategicState(player[0], 9900, StrategyDB(STRATEGY_A_PAIR_OF_NUKES));
}
}
}
if (my_cities < 4 && g.year > 75 && player[0] != 0) {
ConsiderStrategicState(player[0], 9999, StrategyDB(STRATEGY_SMALL_EMPIRE));
}
}
Basicly it chages some strategies depending of some conditions & randomness.
P.S.
I put this in General Forum several days ago, but nobody replied.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:15
|
|
I used this sort of stuff in my modified WW2 scenario beta. I added two new strategies: WW2_GERMAN_LAND_GOALS (which sends the Panzer divisions to capture cities) and WW2_GERMAN_AIR_GOALS (which sends the Luftwaffe to bomb the hell out of anything nearby). To get the AI to use them:
code:
if (tmpPlayer == 1) { // If current player is German
ConsiderStrategicState(tmpPlayer, 9900, StrategyDB(STRATEGY_WW2_GERMAN),-1,-1,-1);
tacticalGoals=Random(100);
if (tacticalGoals<66) {
ConsiderStrategicState(tmpPlayer, 9999, StrategyDB(STRATEGY_WW2_GERMAN_LAND_GOALS),-1,-1,-1);
}
else{
ConsiderStrategicState(tmpPlayer, 9999, StrategyDB(STRATEGY_WW2_GERMAN_AIR_GOALS),-1,-1,-1);
SendTroopsToTheater(); //Blitzkrieg land tactics
}
"SendTroopsToTheater()" is a function that picks up any spare German troops and sends them to where the action is. So on any given German turn there's a one in three chance that the Luftwaffe will go for you, otherwise the Panzer divisions will.
I was also working on a single player Bloodlust version of the game where I was trying to incorporate a radically different approach to the way the AI uses it's strategies, but I doubt that it's ever going to get finished now.
I think the AI is what is technically called a Finite State Machine. If you look at all the strategies in strategies.txt and think about the number of possible combinations, it's pretty damn finite. Again I think, this makes for faster execution: AI geeks are reputed to be obsessed with trimning milliseconds. But in a Turn Based Strategy game, I'm not sure it's all that important.
Defining new strategies, and using the ConsiderStrategicState function to get the AI to use them increases the number of states that the Finite State Machine can be in. The cost is that you can slow the game down, but the benefit is that if you can identify a game situation that calls for a switch in strategies, you get a better AI.
Writing code like you did above is exactly what MrOgre and Azmel2 wanted us to do, it's how they really meant for us to modify the AI:
quote:
You could also swap in a strategy specifically that enables this
goal only when the AI has military superiority. ...
If you add a new strategic state that is triggered
every turn (with a priority > 1000 or so) which redefines the garrison
counts, then you can use your own system. ...
I look forward to seeing what new and improved AI
strategies you and others will create!
-- Richard
|
Changing the AI's data, like Wes and Hexagonian did, only gets you so far: the AI is still using the same program that shipped with the game, it's just operating on different data. There were, IMHO, at least two reasons why things didn't develop as the programming team intended. One is that the 'AI Customization via SLIC' document (in fact all of the SLIC documentation) is just not written for beginners. I don't know how many times I read that document before it began to make sense. The other problem was that the only example MrOgre gave us of a customized AI, namely the 'PW Mod', was so uninteresting that nobody paid any attention to it and hence didn't even realize what it was supposed to be an example of. It's just an example of how to add a new strategy and use the ConsiderStrategicState function to implement it.
|
|
|  |
 |
|  |
 |
|  |
All times are GMT. The time now is 05:15. Apolyton Time is 00:15. |
top of page
|
| archivepost |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|