Author Topic: AI Empire v0.1.1; now with finer control  (Read 15369 times)

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
AI Empire v0.1.1; now with finer control
« on: August 30, 2010, 11:24:23 PM »
New in 0.1.1

All of these buttons affect the AI, now:



- with 'Defense' also covering fighter management.

AI Empire no longer modifies basic_ai.as; instead player empires are given their own derived AI script.

New in 0.1.0

Updated for 1.0.2.0

There are new options in the AI Controls window, but only the old ones (Governors, War, Peace, Trade, Research, Build) yet do anything.

The AI was auto-refusing treaties when you told it not to consider them; it now leaves them alone.

New in 0.0.10

Updated for 1.0.6.  GID_StrikeCraft (Fighter) now inferred for designs scale-3 or below hat have weapons and engines.

Due some problem with the box formation, AI formation default is 'Wedge' for this version.

New in 0.0.9

layout_win.as and friends restored to AI Empire, with their determination of GIDs for your saved layouts.  Apparently I forgot that vanilla SR didn't do this...

New in 0.0.8

AI suppression structures are gone; use the AI Controls button in your Empire window.



You can now prevent the AI from changing governor types.

the Renovate All button there will be replaced with a button that opens an Empire Tools window as I develop more of them.

New in 0.0.7

GID_Lead was a hole in the AI-goal-inferencing system of the previous version.  If you want the AI to give a fleet to a ship, &c, add the Fleet Bridge subsystem to it.

You can build AI Suppression structures on planets.  When they're constructed, they turn parts of the AI off.  When they're destroyed, those parts are turned back on.  You can prevent the AI from declaring war, accepting or offering peace, pursuing research goals, building ships, and accepting or offering trade agreements, independently.

New in 0.0.6

Every time you save a blueprint, an AI goal is inferred based on its stats (thrust, DPS) and saved with it.  So if you create a new colonizer, and obsolete the old one, the AI will build your new colonizer whenever it wants to colonize.

This is how goals are determined:
Code: [Select]
if(hs.getHint("Leader") > 0.f) return GID_Lead;

if(hasWeapons && hasEngines && isHuge) return GID_Annihilate;
else if(hasWeapons && hasEngines && isTiny) return GID_StrikeCraft;
else if(hasWeapons && hasEngines) return GID_Fight;
else if(hasEngines && hasColony) return GID_Colonize;
else if(hasEngines && hasCargo) return GID_Trade;
else if(hasEngines) return GID_Explore;
else if(hasWeapons) return GID_StaticDefense;
else return GID_Invalid;

A ship 'isHuge' if it scales above 150; a ship 'isTiny' if it scales at or below 3.

New in 0.0.1

[strike]OK, this is a pretty straightforward mod that makes a one-line change, but:[/strike]

1. It took me more than a few minutes to rediscover the one-line change, searching the forums, and

2. It's a fun change, leaving you to focus on ship design, planetary management, and micromanaging combat.

VERSIONS:
v0.1.1: give meaning to the dummy buttons; fork basic_ai.as
v0.1.0: updated for 1.0.2.0, dummy buttons, treaty bugfix
v0.0.10: updated for 1.0.6, infers fighter GID.
v0.0.9: fixed regression in GID determination
v0.0.8: better UI for AI control, suppression of governor changes, Renovate All
v0.0.7: added AI Suppression, Fleet Bridge
v0.0.6: updated for 1.0.1.4, uses your layouts
v0.0.5: updated for 1.0.1.2
v0.0.4: updated to 1.0.1.0
v0.0.3: removed errant structures.txt
v0.0.2: updated to use the new AI script
v0.0.1: initial release.

PLANNED:
v0.1.2: extend the layout window so that you can create a scout with weapons, etc, by overriding inferred design goals.
v0.1.3: more empire macromanagement tools.
« Last Edit: October 19, 2010, 02:45:09 PM by ayrnieu »

vinc3nt

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: Let the AI direct your empire.
« Reply #1 on: August 31, 2010, 07:35:04 AM »
OK, this is a pretty straightforward mod that makes a one-line change, but:

1. It took me more than a few minutes to rediscover the one-line change, searching the forums, and

2. It's a fun change, leaving you to focus on ship design, planetary management, and micromanaging combat.

So the AI in your empire controls the ships only? Like in battles?

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: Let the AI direct your empire.
« Reply #2 on: August 31, 2010, 08:43:03 AM »
No, it controls everything, but its decisions are very easily overridden - although it's pretty eager to accept peace agreements with people I've declared war on, am moving a fleet into the territory of, and will declare war on again once this fleet is in place and the peace treaty expires.  If you take no action, it should fare as well as a normal AI would.

Dakkon

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Let the AI direct your empire.
« Reply #3 on: August 31, 2010, 09:26:58 AM »
Just tried this, very good for playing it in the background.

RazorTS

  • Sentient
  • **
  • Posts: 187
  • Karma: +2/-0
    • View Profile
Re: [REL] AI Empire v0.0.2 - uses the new AI script.
« Reply #4 on: September 02, 2010, 06:21:48 AM »
And its great for game testing. Well done

Fritz

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: [REL] AI Empire v0.0.2 - uses the new AI script.
« Reply #5 on: September 02, 2010, 09:47:52 AM »
I'd love to see something like in DW where you can set the AI to manage everything that you don't like being bothered with.

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: [REL] AI Empire v0.0.2 - uses the new AI script.
« Reply #6 on: September 02, 2010, 09:56:11 AM »
A window with checkboxes that have the AI handle diplomacy, only trade, only colonization, etc.?  I think there might be a client/server problem with that, in AngelScript, but I'll look into it.

What exactly do you want to be able to tell the AI to do?  I haven't played DW.

booface

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: [REL] AI Empire v0.0.2 - uses the new AI script.
« Reply #7 on: September 02, 2010, 10:34:06 AM »
i like it thx helps alot with 10000 star galaxy btw i had the research cheat building in my game with this mod is there any way to remove it sorry i dont know how to do mods myself and i like this mod but dont want the cheat building.

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: [REL] AI Empire v0.0.2 - uses the new AI script.
« Reply #8 on: September 02, 2010, 10:47:28 AM »
Oh, woops.

Just delete the Sub Systems directory in the mod, which has structures.txt

booface

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: [REL] AI Empire v0.0.2/3 - uses the new AI script.
« Reply #9 on: September 02, 2010, 10:52:48 AM »
ok did it thx again this is a very helpful mod

vinc3nt

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: [REL] AI Empire v0.0.2/3 - uses the new AI script.
« Reply #10 on: September 02, 2010, 03:56:42 PM »
Keep up the good work on this mod  ;). I always use this mod as I am very bad at running all my empire at once. So the AI (or military, economic and diplomatic advisors as I call them/it) helps me to run the empire.

This mod is recommended for anyone with a high number of systems in their galaxy

vinc3nt

  • Newbie
  • *
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: [REL] AI Empire v0.0.2/3 - uses the new AI script.
« Reply #11 on: September 17, 2010, 03:18:25 PM »
can you update this for the new patch? thank you ;)

Orophin

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
  • I am a rock. I am an island.
    • View Profile
    • STEAM
Re: [REL] AI Empire v0.0.2/3 - uses the new AI script.
« Reply #12 on: September 18, 2010, 12:22:24 PM »
Yeah, it doesn't seem to be working properly with the new patch for me.

Any chance of an update?
"He was an avalanche from an unexpected quarter. He was a thunderbolt from a clear sky."

Brady

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: [REL] AI Empire v0.0.2 - uses the new AI script.
« Reply #13 on: September 22, 2010, 04:36:54 AM »
A window with checkboxes that have the AI handle diplomacy, only trade, only colonization, etc.?  I think there might be a client/server problem with that, in AngelScript, but I'll look into it.

What exactly do you want to be able to tell the AI to do?  I haven't played DW.

This would be great...
Need to turn off diplomacy and AI research managment...
« Last Edit: September 22, 2010, 04:47:16 AM by Brady »

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.6 - now uses your layouts
« Reply #14 on: October 03, 2010, 01:23:31 AM »
bump.  Please let me know if you want anything else from this mod.

acantoni

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: AI Empire v0.0.6 - now uses your layouts
« Reply #15 on: October 03, 2010, 05:40:08 AM »
Thx for this mod, its quite nice to play in background :)
Since you ask here is something i'd like :)
A simple menu that tells what the ai can do and what can't

For instance i'd like to have the possibility to disable the autodiplomacy, or disable the ai producing ships and leaving them on my control, or disable the ai moving ship around, and so on :D

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #16 on: October 03, 2010, 01:15:38 PM »
bump, you can now disable parts of the AI; see first post.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #17 on: October 03, 2010, 02:05:15 PM »
You've gotten farther along in the AI scripting than me, maybe you'll know:
I want to add goal IDs to ships a human builds.

Ive been trying to get my Auto Refuel code to ID tankers based on that goal entry but every ship that isn't built by the AI is flaged as INVALID.

Is there a way to look at the empire_default.xml and get the goal from a design with a matching name?


Erdrik's Mods:
Refuel Auto-Pilot

Tordash

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #18 on: October 03, 2010, 02:10:41 PM »
For a minor change, this has fantastic effects.  I feel like I'm guiding a civilization with its own governments and behaviors, and less like the guy suckered into managing the toggle switches for the universe.  I don't think I'd want to play large games without this, again!

I'm new to the game, so I'm still getting used to the way it's written.  That said...

I like that we can turn parts of the AI on/off, but I think that it would still be better if the controls could somehow be put into the Empire menu.  Are you using the planet structure lists to store the toggle information?  Maybe there's somewhere else that could be used for Empire-level toggles.

What about the parts of the AI that sets governors for planets?  I keep running into planets that are perfectly suited for certain specializations (mining, farming, etc.), but I cannot set those planets, specifically, to not have their governors changed.  The individual planet structure information may be good for this--just a structure for a quick toggle.

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #19 on: October 03, 2010, 02:21:36 PM »
GoalIDs are stored in HullLayout.metadata - it's a property of the layout, not the ship in space, and it doesn't matter who builds them.  Neither the AI nor the player will have a GID_Tanker; that isn't part of the Enum, and loadDefaultLayouts doesn't look for the string.

So you should start by editing that part of Game Data\scripts\server\include\empire_lib.as

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #20 on: October 03, 2010, 02:39:39 PM »
Quote
For a minor change, this has fantastic effects.

I agree :)

Quote
it would still be better if the controls could somehow be put into the Empire menu.

Star Ruler has two separate AngelScript engines, a client and server; the GUI's in one engine and the AI's in the other, so communicating directives to the AI is a little tricky.  The 'magical structures' path has a server structure definition that calls an server effect that calls a server function that sets a server empire setting - and then the AI independently notices the empire setting and reads it.

If someone else did the GUI for me, the best way I have right now to connect it to the AI is by having the GUI create new ship designs every time you press the 'apply' button, with some changes to the layout window so that you'd never see the magical designs.  Messy, right?

I'll look at governors.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #21 on: October 03, 2010, 02:44:37 PM »
Ive already added GID_Tanker to empire_lib.as
And I have been printing the goalID's in HullLayout.metadata already.
(its how I know something is wrong)

further whenever I build haulers, they come out as "0" which is what INVALID is:
Code: [Select]
enum GoalID {
GID_Invalid = 0,
GID_Lead = 1,
GID_Fight,
GID_Trade,
GID_Explore,
GID_Colonize,
GID_Defense,
GID_Annihilate,
GID_StaticDefense,
GID_FightSpecialised,
GID_Tanker
};

yet every ship the AI builds has the proper goal ID's..
Erdrik's Mods:
Refuel Auto-Pilot

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #22 on: October 03, 2010, 02:50:10 PM »
Please make a new post, and attach your code, and someone can look at it.

Tordash

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #23 on: October 03, 2010, 02:55:09 PM »
Star Ruler has two separate AngelScript engines, a client and server; the GUI's in one engine and the AI's in the other, so communicating directives to the AI is a little tricky.  The 'magical structures' path has a server structure definition that calls an server effect that calls a server function that sets a server empire setting - and then the AI independently notices the empire setting and reads it.

Ah!  So it's just pulling data from recordsets (whatever those may be)?  Is there any other set that could be used?  What about resources?  Is it structured as a record per resource, ID'ed to the player (playerID; resource; varresource; etc.), or is it a flat record with a single list of a set list of resources (playerID; varfood; varmetal; etc.)?  Does the game regularly query that for the AI?

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #24 on: October 03, 2010, 03:01:04 PM »
The AI is pulling data from Empire.getSetting().  Yes.  What are 'resources'?  It's per Empire - the AI knows what Empire it's dealing with.  'flat record'...?  .getSetting() is probably implemented as an AngelScript dictionary, which is probably implemented as a hash table and less likely as an associative array, but what does this have to do with anything?  The AI queries Empire.getSetting() vastly more often than the player ever changes it -- I'm tempted to distribute AI_Empire with a small script, to run outside of Star Ruler, that limits the AI in the way you want.

Tordash

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: AI Empire v0.0.7; can now suppress parts of the AI
« Reply #25 on: October 03, 2010, 03:10:46 PM »
The AI is pulling data from Empire.getSetting().  Yes.  What are 'resources'?  It's per Empire - the AI knows what Empire it's dealing with.  'flat record'...?  .getSetting() is probably implemented as an AngelScript dictionary, which is probably implemented as a hash table and less likely as an associative array, but what does this have to do with anything?  The AI queries Empire.getSetting() vastly more often than the player ever changes it -- I'm tempted to distribute AI_Empire with a small script, to run outside of Star Ruler, that limits the AI in the way you want.

Sorry if that was a little confusing.  As stated, I haven't worked with any of the code from this.  I think I've spent an overall five minutes digging into it, thus far.

Meant to say "flat table", and really more of an '-ish situation.  Anyway....

Sounds like that, yeah, having it run outside may be a very reasonable way to set it up--at least for now.  Perhaps in the future, a modification or something added to the in-game GUI could interact with that.

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.8; vastly better UI, small changes.
« Reply #26 on: October 04, 2010, 11:01:40 PM »
Bump for new version.  Please suggest macromanagement tools.  Right now I have these in mind:

1. Push a button to auto-colonize nearby systems.

2. Hotkeys to switch between groups of pins.

3. Push a button to pin only shipyard worlds / galactic capital / fleet commanders.

4. Variants of the Object List - just all of my planets, just ships, just above scale 6, etc.

(The GUI doesn't use the crazy magical-hull-layouts method I was talking about above.  It's embarrassingly direct.)

Bartje

  • Star Ruler Beta Tester
  • Distracted
  • *
  • Posts: 285
  • Karma: +12/-3
  • -=Lex Generale=-
    • View Profile
Re: AI Empire v0.0.8; vastly better UI, small changes.
« Reply #27 on: October 05, 2010, 10:10:42 AM »
This should be officially added, it's just that handy. :D


Ius Naturale

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.0.10; updated for 1.0.6
« Reply #28 on: October 08, 2010, 03:29:22 AM »
Bump.  Updated for 1.0.6, recognizes fighters, AI default formation is FF_Wedge.

ayrnieu

  • Distracted
  • ***
  • Posts: 383
  • Karma: +30/-8
    • View Profile
Re: AI Empire v0.1.0; updated for 1.0.2.0
« Reply #29 on: October 19, 2010, 01:14:18 AM »
Bump.  Updated for 1.0.2.0