Welcome to Spaceempires.net
Login or Register

Search

Modules
 Home

 Discussions
 Forums
Access restricted to our members Members List
 SE IRC Chat
 SEnet News
 Newsletter
 News by Topic
 News Archive
Access restricted to our members Submit News
 Files & Links
 Downloads
 Shipyards
 Upload File
 Web Links
 SEnet Content
 Content (Stories)
 FAQ
 Game Info
 Hangman
 ModWorks
 Top 10
 Strategy
 Surveys
 User Content
 Fan Fiction
 Image Gallery
 Pages
 SE.net Info
Access restricted to our members Feedback
 Recommend Us
Access restricted to our members Statistics
 Search
 Staff
 Your Info
Access restricted to our members Journal
Access restricted to our members Private Messages
 Your Account

User Info
· Welcome, Anonymous
Membership:
· New: Taker74
· New Today: 1
· New Yesterday: 2
· Overall: 2459

People Online:
· Visitors: 46
· Members: 0
· Total: 46

  

Spaceempires.net :: On writing a Balance AI (from scratch) :: View topic
Forum FAQ :: Search :: Memberlist :: Usergroups :: Profile :: Log in to check your private messages :: Log in


On writing a Balance AI (from scratch)

 
Post new topic   Reply to topic    Spaceempires.net Forum Index -> Balance Mod
View previous topic :: View next topic  
Author Message
Gilmoy
Space Emperor


Joined: Dec 20, 2006

PostPosted: Fri Jan 05, 2007 4:23 am    Post subject: On writing a Balance AI (from scratch) Reply with quote

I delved into the AI scripts. The Pascal-ish language looks powerful enough. The interface (to the game engine) looks sufficiently rich.

I deem Malfador's stock AI scripts to be hopeless. They presume to reduce a complex AI to a simple finite-state automaton, make decisions by rote percentages in the settings file, and basically hard-code a tiny set of possible actions. I think it's an evolutionary dead-end.

I plan to write a new AI from scratch. Are there any AI modding resources? I snooped several sites, including the official Wiki, but didn't find anything concrete.

Goals (easy):
- Research 1 at a time (in series, not in parallel).
- Maximize ship combat firepower.
- Pathologically aggressive Very Happy Kill whatever isn't yours -- with highest priority. Put the 4th 'X' back into "4X".

Progress:
0. I've read through all of the existing scripts, and extracted a primer on the Pascal-ish script language. If you know C++, Visual Basic, Perl, or Java, you can dumb yourself down to this script.

To do:
[_] What script debugging tools are available (e.g. from Malfador)? Is there a line-by-line doc for the Data/DebugSettings.txt file?
[_] How do you snoop on an AI, to check its work? Offhand, I plan to use cheat codes to periodically peek at all AI ship designs.
[_] AI squawking via diplomacy. I need my scripts to write progress strings, and send them to me somehow. Normally, you'd write these into a log file, or single-step through a source debugger, but we don't have those. Trick: Use the diplomacy interface, and send them as a message. I can hard-code my AI to search for me by my player name. Then set the game option to make all players known to each other from the start (equivalently, a 1-system quadrant Very Happy )

Credentials: [ www.playsanctum.com ]. I've been the (sole) NIOGA programmer guy since we acquired Sanctum at the end of 2000. We're in a lull in our own Beta over there, so I have some time to goof off here Very Happy


Back to top
CaptainKwok
Balance Guru


Joined: Aug 04, 2003
Location: Toronto, Canada

PostPosted: Fri Jan 05, 2007 5:16 am    Post subject: Reply with quote

I don't know what every setting does in the debug file - but I know enough to regularly generate a log file of the script's execution for each player's turn. Helpful to follow what's going on with the scripts turn by turn.

Just turn on the ministers for a player's race and you can observe all the actions of the default script. Similarly, you can talk over any generated player of the main empires and follow their actions based on their specific AI files.

It'd be better to develop a range of AI behaviours rather than just blatantly aggressive.


Space Empires Depot | SE:V Balance Mod


Back to top
Psieye
Space Emperor


Joined: Dec 03, 2006

PostPosted: Fri Jan 05, 2007 5:35 am    Post subject: Re: On writing a Balance AI (from scratch) Reply with quote

Quote:

[_] How do you snoop on an AI, to check its work? Offhand, I plan to use cheat codes to periodically peek at all AI ship designs.

1) Save Game at end of your (player) turn
2) Go to "Players" menu and type in the master password ('master' by default)
3) Toggle AI to 'human controlled'
4) Log in as former-AI empire and check them out
5) Load Game and end turn again so the AI takes their turn as usual


Another person has emerged whom people will salute after their hard work bears fruit. I thank you in advance.


Back to top
Gilmoy
Space Emperor


Joined: Dec 20, 2006

PostPosted: Fri Jan 05, 2007 7:43 am    Post subject: Appendix: Pascal-ish script language (in progress) Reply with quote

Here's what I've distilled about the Pascal-ish script language. Pretty simple.

The underlying engine is OO (maybe Delphi?), but this script language isn't. You can't define classes (or even structs). You can manipulate objects that the engine passes to you, using standard dot notation.

My Appendix changes by the hour. Normally, you wouldn't see it so soon Very Happy Is this information already written elsewhere?

Update: Oops. That was my Journal file, not my Appendix. Why did I do that? Laughing Anyways, see the AI modding thread for a more recent copy of my Appendices.


Last edited by Gilmoy on Sun Jan 07, 2007 9:30 am; edited 1 time in total


Back to top
Gilmoy
Space Emperor


Joined: Dec 20, 2006

PostPosted: Fri Jan 05, 2007 7:51 am    Post subject: One thing at a time Reply with quote

CaptainKwok wrote:
It'd be better to develop a range of AI behaviours rather than just blatantly aggressive.

Eventually, of course. But let's crawl before we walk Wink
--
Eric / Gilmoy


Back to top
Gilmoy
Space Emperor


Joined: Dec 20, 2006

PostPosted: Fri Jan 05, 2007 9:08 pm    Post subject: Re: On writing a Balance AI (from scratch) Reply with quote

Gilmoy wrote:
[x] AI squawking via diplomacy ... hard-code my AI to search for me by my player name ...

Did that. It works.
2004.1 Message from Abbidon Enclave: "Hello, world!"

I learned how to compile a script, load it, and set up a game that causes it to be used.
You can even quit, recompile, restart, load, and it'll resume the game with your latest script build.

I also learned that a string within a function call's arg list cannot have an embedded comma. Apparently, the script compiler uses a naive split() on commas without first lexing the line into string and non-string tokens, so it gets confused and complains that you're passing too many args.
Code:
call F(1, "Hello, world!")   -- error, looks like 3 args to arity-2 F

Work-around: Assign the string separately to a var (or globalconst), then pass the var.
Code:
set s := "Hello, world!"     -- ok, set doesn't split on ','
call F(1, s)                 -- ok


Also, I learned that tab is considered a word char, not a whitespace. It is legal within variable and function names. Conversely, any two words separated only by tabs looks like one rilly long word instead.
Code:
function foo<tab>bar returns long    -- silly but legal
  return 15
end

  ...
  set age := foo<tab>bar()           -- ok

--
Eric / Gilmoy


Back to top
Display posts from previous:   
Post new topic   Reply to topic    Spaceempires.net Forum Index -> Balance Mod All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
All logos and trademarks used on this site, all comments and stories posted for reading, all files hosted for download,
and all art work hosted for viewing are property of their respective owners; all the rest copyright 2003-2010 Nolan Kelly.
Syndicate news: SpaceEmpires.net News RSS Feed - Syndicate forums: SpaceEmpires.net Forums RSS Feed
Page Generation: 0.17 Seconds