Author Topic: Ai Weight-system  (Read 4646 times)

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Weight-system
« on: May 15, 2006, 04:35:41 AM »
Continueing on a quote by levi, i'll start creating a weight-list for use with the AI.
This (below) is just a basic list; and weights need to be added to each item. I can use initial weights to make the list appear as the quote below, but depending on game development, the weights will change and with it the order of construction and research.

All i need now is the events that will change a targets weight.
For a few, the answer is simple:
Residence -- directly derived from residence demand
Power -- directly derived from unused power (when close to 0, the weight for a tokamak will increase. If it is 0, the weight will be very high).
Food -- directly derived from food increase per turn. Once this number turns negative, it's time to build a new agridome.


Quote
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)
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 Tellaris

  • Sr. Member
  • ****
  • Posts: 460
Ai Weight-system
« Reply #1 on: May 15, 2006, 06:00:45 PM »
I'd like to inquire...
Will the AI make use of the wall ability?   And will it place Guardposts semi-intelligently along said wall?

If it DOES use walls, you may want to consider having it do segmented bases.   A lot more work to program, but also a lot harder to take out.
The Sierra AIs already do this.   EX. Eden Starship 1, Plymouth Starship 2.
« Last Edit: May 15, 2006, 06:01:13 PM by Baikon »
Spell Checker!   The PoWeR tOoL
Click Here For Coolness
Self Proclaimed OPU Help desk.

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Ai Weight-system
« Reply #2 on: May 15, 2006, 07:13:26 PM »
"BO". Hahaha. Haha ha. Ha.

Offline Sl0vi

  • Sr. Member
  • ****
  • Posts: 464
Ai Weight-system
« Reply #3 on: May 15, 2006, 08:13:32 PM »
About the agridome weight. Shouldn't it also take into consideration how much food it has stored? Sure, if morale is on negative production will give negative morale, but still in some situations the AI should perhaps weight it a little less because might have alot of food stored, and there may be even more important buildings for it to get first.

Like if it has just been heavily attacked, and needs to quickly get defences back up. It should weight if defences or food are more important. Ofcourse not push the food too far back, since low morale can be very painful. If morale is off, it can push the agridome as far back as it likes, as long as it doesn't run out of food.
!!!YAY!!!

Offline james239

  • Newbie
  • *
  • Posts: 49
Ai Weight-system
« Reply #4 on: May 15, 2006, 09:50:31 PM »
Will the weight change depending on the situation, say the base is under attack, will it push the residence down on the list and instead focus on building units to defend itself? I found it quite funny once while playing a colony game when the "AI" sent a convec to build a recreation facility right where I was attacking.

*edit: I just realized that I just asked what Sl0vi just asked... oops
« Last Edit: May 15, 2006, 09:52:00 PM by james239 »

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Weight-system
« Reply #5 on: May 17, 2006, 04:30:32 AM »
the reason for the weight-system is so the AI can adapt to current situations. So that answer is: YES .. weights WILL change when things like attacks or disasters happen.
And of course, food stored is also important. On the other hand the AI that dynamix wrote has no morale to take care of: it is at a fixed "good" level, and people never die.
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 james239

  • Newbie
  • *
  • Posts: 49
Ai Weight-system
« Reply #6 on: May 18, 2006, 05:41:07 PM »
So Dynamix wrote a cheater AI? that's lame... I don't like playing against computers that cheat.

Offline omagaalpha

  • Sr. Member
  • ****
  • Posts: 372
Ai Weight-system
« Reply #7 on: May 18, 2006, 06:02:11 PM »
james239 most game at some level do cheat to be competive against a human player .

ps sorry for kindy off-topic but thought james239 need know that ai cheat is nothing new lol
Sorry if my grammar and spelling is bad, but I have disablity with it.
Yes, English is the first and only language that I know.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Weight-system
« Reply #8 on: May 19, 2006, 09:46:08 AM »
it's not really offtopic, omegaalpha
Thing is, i don't think i can make the AI work if i re-enable those morale and poeple death settings. And its pretty frustrating to have the AI die off by itself if you are getting ready for a full scale attack on its base..

So, a little cheat isn't that bad, but i removed a LOT of "cheats" already: the original Dynamix-ai doesn't "DO" research. Neither does renegades missions 1~4 btw: it just uses a timer setting that will enable the computer player to build certain technologies after a period of time, mimmicing the research.
My new AI does real research, and uses scientist to do it. I still have some "cheats" intact, but my main objective is to have the ai react to circumstances, rather then following the exact same set of rules each time you play the mission. On top of that, it needs to be so adaptive, that it can be inserted into ANY map, without having to specify where to build, or what to build, or where it can expect to be attacked. ALL that information MUST be determined by the ai on its own without me influencing those decisions by hard-coding them into the ai library (cause then it will again not function correctly if you give the ai a new map).

Still, the ai code has a set of rules it has to follow, like what the research order should be, and which events can change this order. Like if you park a couple of lynx in front of the ai, it should make sure it has adequate defenses. If you build a lot of spiders, i think an Eden-ai should react by developing acid cloud tech to defend against them. Stuff like that...

So i need input about those 'events' that changes the way the ai "thinks"
Some basic things i've already put down, like more residences when the residence demand goes over 90. The weight-system makes sure that only the one with the most points gets done first. So if i have residence demand at 110 points, but power is at 130 points, if will build a power plant first. When it's completed, power points will drop to, lets say 60 points...  By then the ai would have figured there's a small army coming in, and it sets its lynx-points to 150... so again residences will have to wait....  

The most difficult thing is to get it all balanced to something that works. I've decided to make 100 the standard, because of the direct use of residence demand. The pivoting point for power supply will be higher, because i don't want any unpowered buildings, while having a res.demand >100 doesn't really cause much problems. This means, by the time "unused power" reaches 50, the power-points will go up far enough to force the ai to contruct extra power (whichever best kit it has).

Once the ai 'reacts' to the points-setting, the code will reset that value to a lower one, and re-evaluate all the weights. If the points were high in the first place, it may again decide to construct the same type of building/vehicle, or move on to another type.


INPUT !!  guys, come on!
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 TH300

  • Hero Member
  • *****
  • Posts: 1404
    • http://op3game.net
Ai Weight-system
« Reply #9 on: May 19, 2006, 10:57:40 AM »
AI has few scientists, but some unoccupied workers -> train new scientists
enemy (Plymouth) builds spaceport -> AI (eden) builds missile defense
AI has a mine that hasn't full smelters yet && AI has enough unoccupied workers -> build extra smelters
AI's stored ore is increasing && unoccupied workers available -> build extra vf. (assuming that existing vfs are producing non-stop)
supernovas are near AI's base -> guard entrances
supernovas are near && enemey (Plymouth) launched EMP missile -> move units to some other place
enemy (Plymouth) defends with ESG -> don't attack with lynxes
vortex/earthquake is in AI's base -> move all vecs away from it, don't build there
electric storm is heading towards AI base -> move vecs out of range
 

Offline omagaalpha

  • Sr. Member
  • ****
  • Posts: 372
Ai Weight-system
« Reply #10 on: May 19, 2006, 11:26:49 AM »
you want input, here it is: most of it sound good except this part

Quote
...............If you build a lot of spiders, i think an Eden-ai should react by developing acid cloud tech to defend against them......................
1st thought was hopeful only when it does see spider unit.
But then I realise that in outpost 2 there no cloud of darkness.
Lol but then wait min. at night you can't see enemy units so should make differents.
« Last Edit: May 19, 2006, 11:28:15 AM by omagaalpha »
Sorry if my grammar and spelling is bad, but I have disablity with it.
Yes, English is the first and only language that I know.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Weight-system
« Reply #11 on: May 19, 2006, 11:56:57 AM »
both of you have good points.
omagaalpha: i thought about that: i can detect if units have their lights on, but not yet if they are in the nighttime area.. Once i got that worked out, i can take it into concideration.
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 omagaalpha

  • Sr. Member
  • ****
  • Posts: 372
Ai Weight-system
« Reply #12 on: May 19, 2006, 12:15:05 PM »
Thankyou for  the response. Glad to be of help.
Sorry if my grammar and spelling is bad, but I have disablity with it.
Yes, English is the first and only language that I know.

Offline TH300

  • Hero Member
  • *****
  • Posts: 1404
    • http://op3game.net
Ai Weight-system
« Reply #13 on: May 19, 2006, 03:21:05 PM »
Consider that units are even visible to human players with lights switched off in "total darkness".
Maybe you want to make it so that the "difficult" AI detects all units always.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Weight-system
« Reply #14 on: May 20, 2006, 08:55:21 AM »
all goods points, but those are still advanced ai procedures.
i want to start with the more basic procedures, to have it build its base.
i'm starting out with setting initial tech weights for a couple of technologies:
nursery: 20
university: 25
standard lab: 150
advanced lab: 100

i have an ai-procedure that should be called every 5 game marks, which increases those weights: univ and nursery by 1, and both labs by 2 points.
If the ai has one of those technologies already, its weight will be ignored. Setting the std.lab at higher starting weight then the adv.lab makes it sure that the ai builds its standard lab first. Same goes for univ/nurs.

Other technologies should also have some starting weight. Now we've all seen the basic research-order an ai should have at startup. The order could still change if certain things happen, like if the enemy has lynx, the ai should increase its mobile weapons weight.
It is not very important to work the techtree-order into the weights-system. If a technology cannot be researched, the weight is ignored. The ai researches the tech with the highest weight that it CAN research. It could be it has a couple of weights over 200 points, while it eventually starts on a 20-point research, just coz it cannot do any of the others. So for instance, if the ai should at all time invent artificial lightning, i could set that weight to 200 at mission start, making sure that once the research becomes available it WILL be researched immediatly.

So the first step is to set up the initial weigths of all the technologies and also all building types. The building weights are more or less a building-demand level, like the residence demand displayed in-game, with 100 being the "pivot-point"
 
« Last Edit: May 20, 2006, 09:07:25 AM 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 omagaalpha

  • Sr. Member
  • ****
  • Posts: 372
Ai Weight-system
« Reply #15 on: May 20, 2006, 12:20:21 PM »
just though of this, after read your post.
Will be way for those using your ai in there maps or for just more during more test out ai script to in game or output to files of ai weight list that is not ignore.
Sorry if my grammar and spelling is bad, but I have disablity with it.
Yes, English is the first and only language that I know.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Weight-system
« Reply #16 on: May 20, 2006, 02:42:49 PM »
uhm.. ur grammar is way off... looks like this is translated by a website..
but i think you mean to say 'will it be possible to use this ai in any given map'  -- the answer is: yes, this will a general AI that should work with any user-made mission/map
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 omagaalpha

  • Sr. Member
  • ****
  • Posts: 372
Ai Weight-system
« Reply #17 on: May 20, 2006, 05:12:32 PM »
actual no, during the game:
    will I be able to see ai weight list(importance of what to do) at any  
    give time for ai computer.
come think of it does not make sense to be able see it on less it for ai programer for the code debuging
Sorry if my grammar and spelling is bad, but I have disablity with it.
Yes, English is the first and only language that I know.

Offline Tellaris

  • Sr. Member
  • ****
  • Posts: 460
Ai Weight-system
« Reply #18 on: May 21, 2006, 02:38:15 AM »
OP2 won't be able to easily display that, for the simple fact that the com menu SUCKS.   Better to write an external program to monitor it, or to just test it excessively.
Spell Checker!   The PoWeR tOoL
Click Here For Coolness
Self Proclaimed OPU Help desk.

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
Ai Weight-system
« Reply #19 on: May 21, 2006, 05:28:48 AM »
If you want to monitor: simple messages in the messagelog will do. For more extensive monitoring, like having the entire weightlist at all times, the only way is to use another program, as baikon suggests, running simultaniously with OP2.
For me as the programmer of this, i can create debug-breakpoints at any time, and then inspect whatever variable i want, or even modify them at will, after which i can resume the game. That is what debugging is. Use a standalone monitor is a nice thought - i may write another dll that displays a monitoring window -
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