Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Miscellaneous > Archive > CtP2-Creation/AI/Mods/Scenarios-Archive > Strategic CODE
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
player1 is offline player1
King
Belgrade, YU
Sep 2001
time: 06:15
  Old Post 24-10-2001 10:51
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Strategic CODE Support Apolyton buy from Amazon

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 is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:15
  Old Post 26-10-2001 20:00
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

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.

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:15
  Old Post 27-10-2001 01:58 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Inflate your Upload Space

Time to get moving and make strategies and recognisable situations for every conceivable scenario, and make the AI great. (easier said than done eh?)

player1 is offline player1
King
Belgrade, YU
Sep 2001
time: 06:15
  Old Post 27-10-2001 12:46
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton buy from Amazon

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

player1 is offline player1
King
Belgrade, YU
Sep 2001
time: 06:15
  Old Post 27-10-2001 12:49
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Increase the size of your Attachments

Hey, that PHP button is better than a CODE button when displaying SLICs!
It is all colored.

Locutus is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:15
  Old Post 27-10-2001 19:20 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton or Terrorists Win

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.

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:15
  Old Post 27-10-2001 19:57 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Support Apolyton, buy Call to Power 2

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.

player1 is offline player1
King
Belgrade, YU
Sep 2001
time: 06:15
  Old Post 28-10-2001 01:52
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Increase Your PM Length

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):

Attachment: strategies.txt
This has been downloaded 11 time(s).

player1 is offline player1
King
Belgrade, YU
Sep 2001
time: 06:15
  Old Post 28-10-2001 01:53
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Support Apolyton buy from Amazon

---

Attachment: unitbuildlists.txt
This has been downloaded 12 time(s).

player1 is offline player1
King
Belgrade, YU
Sep 2001
time: 06:15
  Old Post 28-10-2001 01:56
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Browse Apolyton AD-FREE

Anyway Loctus, have you solved that bug of Alexander the Great scenraio?
I think that same probledm hampers a noraml game in Renessanse+ ages.

Locutus is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:15
  Old Post 30-10-2001 14:54 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

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).

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:15
Post  Old Post 30-10-2001 22:06 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Tired of ads?

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

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:15
Post  Old Post 03-11-2001 23:43 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Support Apolyton, buy Civilization 2

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:

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

Attachment: 11-3-2001newai.zip
This has been downloaded 6 time(s).

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:15.
Apolyton Time is 00:15.
    top of page
Rate This Thread:
archivepost
Forum Jump:
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
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0490 seconds (93.05% PHP - 6.95% MySQL) with 31 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net