Author Topic: Need help/input for creating AI  (Read 4988 times)

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« on: November 21, 2004, 06:57:10 PM »
Hey there gamers & coders;

i've come a long way in just a couple days, and i'm now ready to start building my first full mission DLL, BUT what i really need to know is what is the best order of research to be done by the AI.

Now, first of, appearently there are no exported functions to really create a research (thanx Hooman  :) ) but i can emulate this by creating a TimeTrigger and then simply MarkResearchComplete, followed by one or more addition(s) to the RecordBuilding-list.

Two things that i need to know: what is the best order (not for a human, but an AI-player) to research ?
and what should i do about the research-times ? convert "max number of scientists" linearly into a time-index, or make them all the same length or what ?
And of course, connected to this: what structures to build ?

What i have now is this little list:[ol type=\'I\'][li]university[/li][li]vehicle factory[/li][li]laser/microwave[/li][/ol]if any of you don't agree with this, and have a better (and pls more extensive) list, let me know here !!

Thanx guys.
« Last Edit: November 21, 2004, 07:11:39 PM by Eddy-B »
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Betaray

  • Administrator
  • Hero Member
  • *****
  • Posts: 2897
Need help/input for creating AI
« Reply #1 on: November 21, 2004, 09:12:00 PM »
well in op2 I do not beleave the AI did research, I notised that Eden would still make thors even if you destroyed their advanced lab early in the game (from ply star 2)

so I think (and I am no programmer, so I'm just going off what I saw) that the AI already has everything researched, and its just when it builds what that matters
I am the nincompoop, I eat atomic bombs for breakfest, fusion bombs for lunch, and anti-matter bombs for dinner

I just hope they don't explode

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« Reply #2 on: November 22, 2004, 05:50:58 AM »
Okay, i figured one important thing about the TimeTrigger: it's relative to the currect Tick, NOT absolute (what i believed it to be). So you don't need to worry to set a TimeTrigger that has been passed already...
Quote
well in op2 I do not beleave the AI did research, I notised that Eden would still make thors even if you destroyed their advanced lab early in the game
This is correct ! I've mentioned this in my earlier post { thanx to Hooman } - OP2 simply does not have any procedure to order a lab to research something.
There is 2 ways to go at it:[ol type=\'1\'][li]create a MarkResearchComplete everytime now and then; or[/li][li]simply set your AI techlevel to 12 (=full techtree) and start building kits of the 'completed' researches every now and then.[/li][/ol]Trick is to check if the labs are there, and not destroyed (for both methods mentioned above). Then if one of the 2 labs, or both are destroyed, they should be rebuild and "research" should be halted until the are.
As Hooman so eligantly told me "The AI in OP2 is faked so bad, it stinks" { not an exact qoute tho }

Now, i have one more question: is it possible to access the research times from MULTITEK.TXT or any other tektree, or should they simply be hardcoded into the dll ??  In the latter, changing the tek-research-times in the TXT won't have any effect on the AI, but it WILL on any human player !  Now, it would be nicer to get this info from the mentioned txt-files, so non-coders can still use reVOLver to change a little bit of the mission we 'coders' make { plus it eliminates me having to browse thru the files everytime i want to add an AI-research  :P hehe }

As for my AI research-line, i still have no input... All i found was the "i figured it out" post, which doesn't help much...



Common guys: INPUTTTT - you're the veteran players, not me - i can't even finish the 'hard' campaign or colony games.. :whistle:  
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline PlayingOutpost0-24

  • Hero Member
  • *****
  • Posts: 537
    • http://op3np.xfir.net
Need help/input for creating AI
« Reply #3 on: November 22, 2004, 09:48:49 AM »
Well yes... not exactly research time tho. It is research "length". (as EDEN_COST is 800 then the Edens have a bar of 800 when researching)...
4 example...
BEGIN_TECH "Focused Microwave Projection" 03408
    CATEGORY        7 <= don't rly remember i have written it down somewhere
    DESCRIPTION     "BLABLABLA"  <= nonsense
    TEASER          "BLABLABLA"  <= nonsense again
    EDEN_COST       1200   <= doesn't matter unless the game is alltech...
    PLYMOUTH_COST   1200  <= this is a plymouth research, reducing this WILL reduce Plymouth research time for this tech.
    MAX_SCIENTISTS  10  <= increasing this CAN reduce the time (depends on scientists)
    LAB             2  <= 2=Standard
Great news for OP2 fans... OP3 in progress.
Official Site
Outpost 3: A New Power progress
OP3:NP Discussion

Progress in OP3:NP[/size][/font]
PLANNING[|||||||||-]
GRAPHICS [||||------]
SOUNDS [|---------]
MAP DESIGNING [|||||-----]
CODING [----------]
Going slowly... Very slow.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Need help/input for creating AI
« Reply #4 on: November 22, 2004, 12:36:31 PM »
There is no exported function to find what you want. Best way for now would be either to hardcode values into the DLL, or read and parse the file yourself.

With that said, I have accessed this data from a DLL before without having to load the file myself, but the mathod lacks something to be desired. (Well, actually I was quite pleased with it, but I'm still a little hesitant to release something for that yet. Plus I'm busy on other projects currently.) But then, I should also mention that using slightly more advanced methods, I've also ordered a lab to research, but again, I'd rather not advocate such abuses of the exe for the time being.  :P  (Someday when I have time, I'll build a library for other people to use, but probably no source included).

Anyways, if you're reading the file, the important values would be the COST (or EDEN_COST/PLYMOUTH_COST in case the costs are different for each colony), MAX_SCIENTISTS, and of course, the techID (found at the end of the BEGIN_TECH line). Also, if you want to handle delays if labs are destroyed, you'll need the LAB value (1 = Basic Lab, 2 = Standard Lab, 3 = Advanced Lab).

I can give you most of the details on how to calculate research rates, but I don't have an easy way of describing how morale/efficiency concerns factor in very well. (Although I do have some idea how. If you want to read assembly you can take a look yourself (thumbsup) )

As for the research order, I don't really know and everyone seems to have a different idea but certainly the following are important (assuming Plymouth, I'm sure you can find the Eden equivalent, and these are in fairly random order).

Research Training Programs
Metallogeny
Offspring Enhancement
Focused Microwave Projection
Mobile Weapons Platform
Dissipitating Adhesives


But yeah, the really easy solution is to set the tech level and just know what to let the computer build.
 

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« Reply #5 on: November 22, 2004, 12:55:56 PM »
thanx guys (i've assume you're male..) but i gave up for today... going to play some now or watch a B5 episode or something... can't see a single c++ line anymore !

I did figure out about the research times. There is a multiplier value for this:
research COST times X divided by #of scientists. Now, to be fair, you have to know how many AI scientists you have to do research. For sure when you're using standard AND adv.lab at the same time. Then there is this thing about the university. I think this crude AI just uses SetScientists(...) instead of actually training them, but again, you should be fair. It's not difficult to create an unbeatable AI. The trick is to make one just difficult enough you need to really stretch to win !

And, hooman, keep working on those extra procedures - no matter you give the source or not - we need research/training/repair functions to be done
Also i could not find a property for Damage, only SETdamage().
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Need help/input for creating AI
« Reply #6 on: November 22, 2004, 03:48:23 PM »
Ahh, finally remembered where that post was...: http://forum.outpostuniverse.net/index.php?showtopic=119...indpost&p=26568

That gives some explaination as to how research is done internally (and give some reasons why that clicking cheat to speed things up is a load of crap). That should give all the details for an algorithm, minus a lookup table. But since I gave memory addresses, it'd be fairly easy to find that table in memory using your favourite debugger.

As for keeping track of available scientists, I can't think of any easy way to do that. I'm sure a nonstandard hack could get you the value easily though. Probably something I'll add to that library. I do plan to make it someday, but it'll probably be at least 2 weeks before I have time to go back to it.

Quote
I think this crude AI just uses SetScientists(...) instead of actually training them
Not even. The AI in Outpost2 just has 4096 workers/scientist (I think, it'd been a while since I checked the values). Just create a computer controlled AI in the game and use TethysGame::AddMessage() (and scr_snprintf()) to display the number of workers for that Player (_Player.Workers()/_Player.Scientists()). Which leads me to believe that food isn't a problem for the AI either.  <_<

Anyways, if you want your AI to actually have to worry about this, it has to be considered a human player. (Don't use _Player.GoAI()). The one I was working on a while ago played as a human player, so it had all the same sets of rules to abide by (mostly anyways, I've been thinking of tweaking it either way).

So yeah, like I said. They really faked the AI in Outpost2.

 

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Need help/input for creating AI
« Reply #7 on: November 22, 2004, 04:18:23 PM »
Quote
Now, i have one more question: is it possible to access the research times from MULTITEK.TXT or any other tektree, or should they simply be hardcoded into the dll ??  In the latter, changing the tek-research-times in the TXT won't have any effect on the AI, but it WILL on any human player !  Now, it would be nicer to get this info from the mentioned txt-files, so non-coders can still use reVOLver to change a little bit of the mission we 'coders' make { plus it eliminates me having to browse thru the files everytime i want to add an AI-research  :P hehe }
Well, first of all I would save it to a different file and make the dll use your custom tech tree. If you rename the TXT file, put it in the game dir, and change the DLL to use this TXT file, it will read from that file (and 'non coders' will be able to change it)

Furthermore, you can override the MULTITEK.TXT in the sheets.vol by putting a MULTITEK.TXT in the game dir. The game will read the first file found (it searches the game dirs first before the VOL files).

Like PlayingOutpost said, you could set the EDEN_COST and PLYMOUTH_COST separately.. however if a human player is either one of those the cost change will effect the human as well.

 

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Need help/input for creating AI
« Reply #8 on: November 23, 2004, 02:49:06 AM »
if the AI base starts with the following:
Agri, Std Lab, SF, Tok, 1 Smelter
then this should be the BO:
1. University
2. Vech. Fac.
3. Advanced Lab
4. Common Ore Smelter
5. Common Ore Smelter
6. Tokamok
7. Vech. Fac.
8. Robot Command Center
9. Common Ore Smelter (Out back)
10. Nursery
11. Rare Ore Smelter
12. Agridome
13. Common Ore Smelter
14. Vech. Fac
15. Tokamok

Researsh order something like this
1. Metalogeny (Standard Lab)
2. Hypnopedia (Standard Lab)
3. Focused Microwave Projection (Standard Lab)
4. Mobile Weapons Platform (Advanced Lab)
5. High Temperature Superconductivity (Advanced Lab) & Dissipating Adhesives (Standard Lab)
6. Scout-class Drive Train Refit (Standard Lab) & Independent Turret Power Systems (Advanced Lab)
7. Rare Ore Processing (Advanced Lab) & Advanced Vehicle Power Plant (Standard Lab)
8. Advanced Combat Chassis (Advanced Lab)
9. Electromagnetic Pulsing (Advanced Lab) & Multiple Mine Projectile System (Standard Lab)
10. Rocket Propulsion (Advanced Lab)
11. Long Range Projectile System (Advanced Lab)
12. Grenade Loading Mechanism (Advanced Lab)
13. Explosive Charges (Standard Lab)
14. High-Powered Explosives (Standard Lab)
 

Offline PlayingOutpost0-24

  • Hero Member
  • *****
  • Posts: 537
    • http://op3np.xfir.net
Need help/input for creating AI
« Reply #9 on: November 25, 2004, 10:17:44 AM »
eh, well, its a pie research order, isnt it?
*sigh* i dont think that Eddy-B is doing building order now...





btw,
Quote
(out back)
... lmao.




also do we need an AI as unbeatable as u?
« Last Edit: November 25, 2004, 10:18:27 AM by PlayingOutpost0-24 »
Great news for OP2 fans... OP3 in progress.
Official Site
Outpost 3: A New Power progress
OP3:NP Discussion

Progress in OP3:NP[/size][/font]
PLANNING[|||||||||-]
GRAPHICS [||||------]
SOUNDS [|---------]
MAP DESIGNING [|||||-----]
CODING [----------]
Going slowly... Very slow.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« Reply #10 on: November 25, 2004, 02:37:14 PM »
well, this so-called "AI" has been so demoralising, that i gave up (for now, or should i say day-before-yesterday) .. and yes,, the ai must be at least a little bit beatable, i've seen the video, i think you hardened op2 players can win from just about anybody { except yourselfs of course - but since one cannot play oneself, that won't be a problem }

As for the building order, well.. i'm still trying to have my vehicle factory create units, and have them attack human player.. that's basicly where i quit 2 days ago..  :(  i think making the AI look more human (and have him uhm.. IT play by our rules) is more than just a simple matter of programming, it needs a lot of hacking into OUTPOST.EXE which im not really waiting for or interrested in !

So, i guess it's all back to what Sierra calls "AI"  (HAHA.. better call it "AD" - D for Dumbness).  As for now, i'm just playing around these DLLs ; just to see what everything does, and if i can make it work. Then later on, i might actually start building a campaign-type game.
Talking about campaigns, the 3 extra scenario packs - the originals by Sierra - ... they don't install "The file OUTPOST2.EXE is not a valid previous version and could not be upgraded"  i think i lost the original somehow....
Does this happen with all of you ? or is it just me ?  :mellow:  
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Need help/input for creating AI
« Reply #11 on: November 25, 2004, 03:04:20 PM »
The downloaded copy of Outpost2 already has those 3 scenario packs installed.

As for DLL programming. Writing a level without an AI would still be useful. Currently, new maps tend to use old DLLs, at least until recently. This creates a few problems with mining beacons and natural disasters like volcanoes. Just coding a simple DLL setup for multiplayer would help out a few of the map makers.

And yeah, even a simple AI that fakes it would at least be something. We really could use new colony games.

 

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« Reply #12 on: November 28, 2004, 06:09:50 PM »
Hey, i hit a bump, that i cannot get over:

How do i find out if a certain map square has a tube on it ? I cannot find anything in the "SDK" (or in the outpost executable for that matters), so how is it done ?!? Any of you know ?

Eddy
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Need help/input for creating AI
« Reply #13 on: November 28, 2004, 07:57:35 PM »
I'm not sure why you'd need to know that but you can find that out by using GameMap.GetCellType or GameMap.GetTile. You should probably use GetCellType though since the GetTile function will return a range of values depending on what the tube looks like (eg. what terrain type it's on, lava rock, rock, dirt, and what direction it is facing or adjacent tubes it is connected to). Plus GetTile is tile set dependent rather than attribute dependent (it's value will change if you reordered the tile set). GetCellType returns a value that describes characteristics of that tile such as move speed. Plus, when I tested that out a few days ago, I got the same value for all tiles that were considered tubed.

I can't remember what the value is for tube, but just call it on a known tile that has a tube on it and use that value. Also, the space occupied by buildings is considered tubed and will return the same value.

If you want the AI to build/rebuild tubes, that can be set with BuildingGroups. Use BuildingGroup.RecordTube to record a tube the AI needs to build, and use BuildingGroup.RecordTubesTouching to record the tubes that were placed when the initial buildings were placed. This will make the AI rebuild tubes that are cut.
 

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« Reply #14 on: November 29, 2004, 02:27:23 AM »
Hey - that's wonderful information !

I'll start working on the GetCellType fucntions tonight. Have a pleasant day :)

[EDIT] It works just fine !! .. i can find the things i need, but i still have one problem; maybe you have already a solution to that. If not i guess i'm going to have to dig further into outpost.exe  :'(

GetCellType:
15 : bulldozed
17 : walled (concrete - the rest i didn't check yet)
1A : tubed

I can create new walls or tubes using TethysGame::CreateWallOrTube but there is no function for bulldoze....  Using SetCellType has no effect (don't know why ?!?)
« Last Edit: November 29, 2004, 06:20:06 PM by Eddy-B »
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Need help/input for creating AI
« Reply #15 on: November 29, 2004, 06:55:13 PM »
SetCellType won't change the graphics, but I bet it'll change the characteristics. If you move a vehicle across the terrain it'll probably move faster after using SetCellType, but for it to appear bulldozed, you'll also have to use SetTile.

Also, as a side note. There are multiple entries for tubes. I don't know what the other entries are used for though. It seems to give the same value across different terrain types and different graphics. My only other guess is that different players have different tubes, but that seems kinda unlikely. (Wouldn't mind if you'd check though ^_^)


 

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« Reply #16 on: November 30, 2004, 02:27:50 AM »
the above values is what i found after checking a map.
i've tried several cell types:

04 : orange soil
06 : ice (inpassable, i guess)
07 : normal lava-rock
0E : a tube, created by map editor (not by earthworker)
15 : buldozed
16 : rubble
17 : wall (concrete)
1A : tube (created by earthworker)

i did not checked every single map tile, but i will tonight..
soil types don't seem to matter much.. a tube is still 15, wether it's build on a gray or orange..  AND i don't think its just those values, it's probably the BITS that matter, but i haven't figured out what they all do (yet). Although it seems whenever you change something (bulldozer/earthworker/building) BIT4 (0x10) is set.

[EDIT] it should actually read the other way around: i put a tube somewhere, and it turned out to be a '1A' etc..
It doesn't matter much who builds the tube, it's the same celltype and tile. Same goes for walls. When you doze a square, the cell type turns to 0x15 and the tile itself is set to a dozed tile, for example 0x199 - in order to re-create tiles at runtime, you need to set both celltype (needed for the game engine) and the tileset (this is only visual). I found out, you can put a tube onto the gamemap (either with a map editor or with SetTile), and an earthworker is still able to build a tube on that very sqaure. This would also suggest the game does NOT recognise this "orginal" tile as a tube.

I'll keep everybody updated on what i find.
My mission is progressing fine. Mission 1 is nearly done, mission 2 has been started already { programming HAS TO overlap, since i make them interconnecting }
« Last Edit: November 30, 2004, 04:06:54 PM by Eddy-B »
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Need help/input for creating AI
« Reply #17 on: December 01, 2004, 12:56:58 AM »
Well, I guess I should save you some time here. So here's a bit of what I know....

Quote
i don't think its just those values, it's probably the BITS that matter
Actually, the value is just an index into a table. The bits mean nothing themselves. Here is the meaning of the table entries.

00 (0x00) "Fast Passible 1"
01 (0x01) "Impassible 2"
02 (0x02) "Slow Passible 1"
03 (0x03) "Slow Passible 2"
04 (0x04) "Medium Passible 1"
05 (0x05) "Medium Passible 2"
06 (0x06) "Impassible 1"
07 (0x07) "Fast Passible 2"
08 (0x08) "North Cliffs"
09 (0x09) "Cliffs - High side"
10 (0x0A) "Cliffs - Low Side"
11 (0x0B) "Vents and Fumaroles"
12 (0x0C) "zPad 12"
13 (0x0D) "zPad 13"
14 (0x0E) "zPad 14"
15 (0x0F) "zPad 15"
16 (0x10) "zPad 16"
17 (0x11) "zPad 17"
18 (0x12) "zPad 18"
19 (0x13) "zPad 19"
20 (0x14) "zPad 20"
21 (0x15) "Dozed Area"
22 (0x16) "Rubble"
23 (0x17) "Normal Wall"
24 (0x18) "Microbe Wall"
25 (0x19) "Lava Wall"
26 (0x1A) "Tube0"
27 (0x1B) "Tube1"
28 (0x1C) "Tube2"
29 (0x1D) "Tube3"
30 (0x1E) "Tube4"
31 (0x1F) "Tube5"

So yeah, that's how I know there is more than one value for tubes. But I've only ever seen 26 (0x1A) used. If you have any idea when the others are used, I'd love to hear about it. Anyways, that table really contains more than just the terrain type names. It also contains the movement rate for each vehicle track type. (I think anyways, haven't had much time to look into it. There might be more in the table too). (Also, you might see why I suspected different players get different tube values since there are 6 players and 6 tube types, but then the game really uses 7 players internally so I never really thought the idea plausible enough to bother proving wrong.)

If you're wondering about that odd value from the editor, I'd guess it's because we only really found this stuff out recently. Probably about a week ago (maybe two).


Quote
I found out, you can put a tube onto the gamemap (either with a map editor or with SetTile), and an earthworker is still able to build a tube on that very sqaure. This would also suggest the game does NOT recognise this "orginal" tile as a tube.
Most definately how it works. The value for the tile really means nothing to the game at all. It's just an index of which tile to display for that square. Even which one represents a tube is arbitrary. There is a structure that maps ranges of tiles to corresponding tube/wall/rublle/bulldozed tiles. Each terrain type (rock/lava rock/dirt) has it's own table, so that's why when you bulldoze/tube/etc. the background color of the terrain stays the right color. All the game does is check which terrain type the tile falls in (all terrain types are a consecutive run of tile indexes) and replace that tile index with the corresponding one in the table for bulldozed terrain (or tubes, but that's more complicated since the graphics are directional and depend on surrounding tubes).

So yeah, those tile values are simple, meaningless, indexes. If you were to change the tilesets, those values would be useless since the new graphics would (most likely) be in a different order.
 

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Need help/input for creating AI
« Reply #18 on: December 01, 2004, 12:16:52 PM »
thanx for this info. i'll work it into my headers somewhere. I guess i was wrong about the bits   :blush:

For the factory bay question: i figured it out by myself today. I've written a small subroutine that will get the bay contents. As you've said: it's actually quite simple to get it, it's the WAY it's done, that isn't nice. But that's not my problem: they should have done a better job @ Sierra online in the first place !
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz