October 24, 2001, 01:51
|
#1
|
Emperor
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
|
Strategic CODE
Has anyone tried to make code like this?
PHP Code:
|
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.
|
|
|
|
October 26, 2001, 11:00
|
#2
|
King
Local Time: 15:05
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
|
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.
|
|
|
|
October 26, 2001, 16:58
|
#3
|
Prince
Local Time: 16:05
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
Time to get moving and make strategies and recognisable situations for every conceivable scenario, and make the AI great. (easier said than done eh?)
|
|
|
|
October 27, 2001, 03:46
|
#4
|
Emperor
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
|
I thnik the main problem is that we don't have THAT ORIGINAL PORIGAM
ready for MODification.
That is drawback form CTP1, there you had a *.fli files wich where just
that progam, while *.aip file where a copmuter startegies.
So you don't know:
-are your priorities higher than for some predefined strategy
-when are predefined strategies loaded (while testing I noticed that while AI is in war it uses only SEGIE of war strategies (or none), never ATTACK, or DEFEND startegies, you can test that playing MedeMod)
-the same thing matters for diplomatic strategies, but there is a that interactions.txt which gives a little information abaut a code
|
|
|
|
October 27, 2001, 03:49
|
#5
|
Emperor
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
|
Hey, that PHP button is better than a CODE button when displaying SLICs!
It is all colored.
|
|
|
|
October 27, 2001, 10:20
|
#6
|
Deity
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
Some good points are being made in this thread. I agree with Peter that CtP2's AI is most likely a simple Finite State Machine. I figured this out fairly soon once I got into AI editing (player1 recently bumped the thread which got me into it) and I tried to explain to Wes (I'm not sure if this was in the forums, through email, icq, chat, whatever) how important functions like ChangeStrategicState could be. I don't think Wes ever got the point I was trying to make though, mainly because I didn't explain it well. I never really delved into AI editing more deeply because there was (and is) so much other stuff that also needs to be done with SLIC, stuff that Wes and Harlan wanted me to focus on (right now real-life and to a lesser extend Civ3 take up most of my time).
I think you can significantly improve the AI by completely redesigning it. I never actually tried it but I think you can completely clear the existing strategies by removing all data ('STRATEGY_DEFAULT {}'). Then you can rely entirely on SLIC and newly defined strategic states to control the AI State Machine, without any interference from built-in mechanisms. The only problem is that completely redesigning the AI from scratch is a huge undertaking and I don't think we have enough manpower to do it within a reasonable amount of time.
|
|
|
|
October 27, 2001, 10:57
|
#7
|
Prince
Local Time: 16:05
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
|
Quote:
|
Originally posted by Locutus
I think you can significantly improve the AI by completely redesigning it. I never actually tried it but I think you can completely clear the existing strategies by removing all data ('STRATEGY_DEFAULT {}'). Then you can rely entirely on SLIC and newly defined strategic states to control the AI State Machine, without any interference from built-in mechanisms. The only problem is that completely redesigning the AI from scratch is a huge undertaking and I don't think we have enough manpower to do it within a reasonable amount of time.
|
Ouch! That would be sooo much fun if it could be done. Unfortunately, everyone is busy, or off to Civ3, and there really isn't much point unless we can figure out how (at least in theory) its going to work really really well.
I was thinking earlier, about a whole SLIC-based subsidiary system for the AI with regards trading strategic goods like in Civ3.
*lets cat out of abandoned basket* Even that would take some doing, but a complete revamp would be awesome.
|
|
|
|
October 27, 2001, 16:52
|
#8
|
Emperor
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
|
Loctus, that was something I was doing in startegies.txt for my example.
My example gives sometimes AI to use THE_MINIMAL_NUKES startegy I made, and since I don't want AIs to use their original MINIMAL_NUKES_STARTEGY (without THE_), I deleted all entires in it and placed mt new startegy at the bottom of the file.
Here are my startegies.txt & UnitBuildList.txt (which complement
example I posted):
|
|
|
|
October 27, 2001, 16:53
|
#9
|
Emperor
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
|
---
|
|
|
|
October 27, 2001, 16:56
|
#10
|
Emperor
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
|
Anyway Loctus, have you solved that bug of Alexander the Great scenraio?
I think that same probledm hampers a noraml game in Renessanse+ ages.
|
|
|
|
October 30, 2001, 05:54
|
#11
|
Deity
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
IW,
Yeah, it would be great fun to do but with only 2 or 3 people working on it, it would take forever...
Player1,
That looks interesting, I wonder if the same can be done with default and personality strategies...
Damn, that Alexander bug. I was working on something (pretty scenario specific, don't know how it would work on a regular map) but I ran into a bug with the ClearTileImprovement event (if that's its name). I wanted to post about it a while ago but I forgot. Will see if I can do so tonight or so (don't have the files here).
|
|
|
|
October 30, 2001, 13:06
|
#12
|
Super Moderator
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
Quote:
|
Originally posted by Locutus
but I ran into a bug with the ClearTileImprovement event (if that's its name).
|
I guess you mean the CutImprovements event. You are right it is buggy: If you try to pillage a tile improvement without an owner regardless of the fact if you try it with a unit or via slic, CTP2 will crash. The only way to remove such a neutral tile improvement from the map is giving it back an owner by contructing a fort like tileimp in its neighbourhood.
Here is the code that I use in GoodMod to prevent the human player to pillage a neutral tile improvment:
Code:
|
HandleEvent(CutImprovements)'MG_PillageImprovement' pre {
if (CellOwner(location[0])==-1) {
return STOP;
}
} |
-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
November 3, 2001, 14:43
|
#13
|
Super Moderator
Local Time: 17:05
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
I started to add to player1 strategies.txt a lot of strategies, that only controll one point of the AI for example a strategy like:
PHP Code:
|
STRATEGY_SLIDER_FOOD_PLUS_THREE {
SliderElement { Delta 3 Food }
}
|
The result is a great deal of new strategies. I didn't started the slic about it and I didn't added all the strategies that could be added and all combinations that could be created of strategies. But the main concept is to cut the strategies into thousands of tiny pieces. And reassemble them into I don't know how many possibilities.
So her is the start for everyone who is willing and has the time to go on. I added to the *.zip file the unitbuildlists.txt, buildlistsequences.txt and the slic code above including Mr Orge's PW mod. So far I only added the new strategies to the strategies.txt, no slic that implements them and no removed strategy yet.
-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
Posting 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
|
|
|
All times are GMT -4. The time now is 11:05.
|
|