Posted: Fri Jan 05, 2007 4:23 am Post subject: On writing a Balance AI (from scratch)
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 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 )
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 Back to top
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.
Posted: Fri Jan 05, 2007 5:35 am Post subject: Re: On writing a Balance AI (from scratch)
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
Posted: Fri Jan 05, 2007 7:43 am Post subject: Appendix: Pascal-ish script language (in progress)
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 Is this information already written elsewhere?
Update: Oops. That was my Journal file, not my Appendix. Why did I do that? 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
Posted: Fri Jan 05, 2007 9:08 pm Post subject: Re: On writing a Balance AI (from scratch)
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
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
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: - Syndicate forums:
Page Generation: 0.17 Seconds