![]() |
Atten Devs: AI (Rules-based dynamic scripting?)
Here's a paper on an AI technique called dynamic scripting. The authors took a complex tactical game (Neverwinter Nights) with a script-based AI, and were able to show that a learning algorithm can 1.) pick out effective combinations of rules vs. different play styles, and 2.) adjust difficulty to "barely lose, in interesting ways" against human players of different skill levels. They also report that a later, improved AI from the game developer resembled the scripts the algorithm learned by itself at much less effort.
http://www.cs.unimaas.nl/p.spronck/P...cScripting.pdf I wonder whether this is something that can be applied to Dominions. I don't know whether the strategic AI is rules-based, but a learning AI does seem to be well-suited to Dominions because 1.) tactical combat is AI-controlled anyway, so you don't need to worry about self-trained AIs somehow missing out on tactical "tricks" because of e.g. bad pathfinding, 2.) AIs can easily play games against themselves because the engine is fast, 3.) the strategic space is *huge*, with many different and interesting counters possible to any specific tactic, so even a fairly dumb hill-climbing search may stumble across a good counter to, say, E9N9 Niefelheim (e.g. race for Alt-6 and Iron Bane). I'm still kind of new to Dominions, but is writing AI rules something that can be done in a mod, or is it something only the devs can do? I'd love to implement "dynamic scripting" and see what kind of AIs fall out. Also check out http://rolec.unimaas.nl/. -Max Wilson |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Neverwinter Nights is a great game but it was built from the ground up to be scripted. From the beginning of Dominions Ive mentioned scripted AIs. Some great games are out there where players have created programs you can run which will play the enemy like it was another player.
Unfortunately adding it to a game later is like starting over. For everything that the AI does there would have to be a "hook" written in. Variables and commands. Such as, giving a commander an item would requre variables for the slots and ways to detect if it already has something. Or making a move would require variables for neighbors and commands for looking, evaluating, etc. Those are in the game of course but they usually arent done in a clear variable that can be "seen" from outside the game. The closest we get right now are the modding commands (which there are alot of and more all the time) Maybe for Dom4. But I think it might be something that would be so involved that they would just write a new game instead. IMHO |
Re: Atten Devs: AI (Rules-based dynamic scripting?
I appreciate the point about Neverwinter Nights, and if the Dominions AI isn't internally doing scripting I guess it wouldn't be trivial to make it learn. Still, I wonder if the PBEM aspect of Dom3 offers enough "hooks" to build a scripting AI client anyway; you'd have to know how to write .trn files and, as you pointed out, how to read game state like "who controls province #33 this turn, and how many units do I see in it?" and "What items is my Pretender carrying?" It doesn't necessarily have to tie into the existing AI engine, but at least in principle the PBEM orders/execution/results division offers everything you need to write a learning engine.
Even if it did have to wait for Dom4, which I hope it doesn't (I'm off to look at my .trn files in a minute and try to figure out what's in them), an adaptive AI would be incredible for us SP folks and a real selling point. Not that Dom3 is lacking in selling points. http://forum.shrapnelgames.com/images/smilies/happy.gif Terrific game, even if I just discovered it three weeks ago. -Max |
Re: Atten Devs: AI (Rules-based dynamic scripting?
By the way, how much AI programming can you do with the mod commands?
-Max |
Re: Atten Devs: AI (Rules-based dynamic scripting?
You cant really change how the AI thinks. But with map commands you can build an AI nation that makes better use of the AI brain.
With mod commands you can change just about everything. Remove units and spells you feel its using too much, patch weak points that are too well known and abused by players, etc etc. Its not really a bad AI (IMHO) but the random generation when it sets up a nation makes it rare that you get one where the setting choices match that nations best abilities. Manually making an AI would tend to work better. |
Re: Atten Devs: AI (Rules-based dynamic scripting?
This is a very interesting point. Perhaps, instead of selecting AI in game set-up, a human is selected and a script would generate a turn using the ftherlnd file, if that file contains data the AI could use.
Just thinking out loud. |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Making the fatherland formating available in general would create a situation for cheating.
But if the game shifted to a fatherland for each nation then it might work. |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Gandalf,
I thought that in MP only the host has the ftherlnd file. Are you thinking of cheating by the host? Depending on how much information is in .trn files I can see how cheating could be an issue (it could let you observe battles you have no way of knowing about, or see the distribution of forces across enemy empires), but I didn't think that sort of information wound up in .trn files. How much is actually known about what resides in each file? -Max |
Re: Atten Devs: AI (Rules-based dynamic scripting?
In SP, the .trn, .2h and ftherldn files are all in the save game directory.
|
Re: Atten Devs: AI (Rules-based dynamic scripting?
The fatherland does exist only on host. But at this time even the host does not have that level of access to the games. It might not be a problem but it would be a nasty one-way trip if it turned out to be one. Actually, the level of info available by the debug command concerns me enough as things are now.
The internal formats are rarely discussed. If the faatherland was broken up by players or created seprately for the AI then it could be accessed seperatly without knowing everything about everyone. That would probably be best anyway since it would allow for creating a view of teh world that includes only what the AI has "seen". |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Surely the trn file has everything an AI might need in order to play its turn, in the same way that it has everything a human needs to play its turn.
What Max needs to know, if I understand correctly, is if anyone knows what the format of the trn and 2h files is (the AI would need to create 2h files). I have no idea, but I presume the answer is that no one knows the formats. It's not obvious that there should be any problem with releasing them, though. |
Re: Atten Devs: AI (Rules-based dynamic scripting?
If we did have the file formats, it would open up a whole new arena of metagames... We could have AI contests!
|
Re: Atten Devs: AI (Rules-based dynamic scripting?
Quote:
Still, since it looks like a genetic algorithm, it's probably the best approach there is for Dom3. I think it would be worth trying for some simple cases to see how well it does against the current tactical AI. (If the game has the right hooks, of course...) |
Re: Atten Devs: AI (Rules-based dynamic scripting?
If you are interested in seeing the AI "think" you can turn on debug logging and direct it to a file. If you turn on debugging to an extensive level, you will get a HUGE file very quickly. In linux it would be -ddddddd >log.txt
In windows I think it might be just adding -ddddd and it goes automatically to log.txt (best viewed with WordPad since NotePad doesnt handle the unix style of formatting very well) |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Oh, yeah. I watch it think frequently. But to take that and evaluate it against another AI would take simulating the "battle engine".
OTOH, that the game does produce that kind of output suggests that hooks to replace the AI might be in place. It looks like the game evaluates moves (spell choices, etc) for each unit on the battlefield, and then passes them off to other routines to carry out. If the evalution and "do this move" calls can be brought out to an API, it shouldn't be too hard to attach Dom3 to another AI. (He says, knowing nothing of Dom3's internals. http://forum.shrapnelgames.com/images/smilies/happy.gif ) |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Its written on linux (ubuntu to be specific) and then ported to mac and windows versions. Other than that.. you might look in the mod directory where some people have taken apart bits of it.
But generally, discussion of format internals has felt like it got kinda squashed in the past. |
Re: Atten Devs: AI (Rules-based dynamic scripting?
The main discussions on format internals that have been going on here that I have seen have been related to the unit, spell and site formats to enable better modding and nothing integral to the mechanics of the game in the same way as people are talking about in this thread.
The spell modding issue is actually helpful since it allows wider modding of spells without tedious trial and error research to find what you need. The site and unit stuff is mainly useful for making the DB better than it already is and helping modders and mapmakers. I'm rather uncomfortable with how so many people want to see the file structure for trn, 2h and fthrlnd files, given the abuse potential. I still remember the ****storm Norfleet managed to create when he got found out cheating and if the file format info is widely available, it's going to make similar incidents inevitable since less skilled people will be able to do similar things. |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Prior to hosting, the game could check the incoming .2h files against the .trn files that were sent out. Most everything should be the same, and what's different should be accounted for (or accountable for) by what's being hired, cast, forged, etc. I know something like this already happens when cheat detection is turned on, though I'm not sure how thorough it is. With that in place, it would be impossible to cheat on the client side. I'm not so concerned about cheating by the host; there are already plenty of ways the host can cheat, especially with the master password, and it hasn't been much (or any?) of an issue. Besides, we don't need the fthrland format to play with external AIs. We just need to know how to read a .trn and write a .2h. It would be such fun... Come on, Illwinter! Let us AI nerds play!
|
Re: Atten Devs: AI (Rules-based dynamic scripting?
Sadly, neither AI scripting nor external AIs will work in/for Dom3 at it is now (we have been talking 'bout this before). The following is based what I know from Dom2 and beta-testing Dom3, and some details might have changed in the meantime. I doubt, though, that the underlying principle has changed:
scripting There are no means in the engine to 'externalize' the AI to scripts. Some reasons already have been given - it effectily would require re-coding big parts of the engine. Modding isn't comparable with AI scripting, because the mod commands are simply read in and the 'standard values' (variables) replaced before a turns orders are evaluated. During this evaluation the game works 'autonomous', starting with a special seed for a random sequence, which is saved with the turn file. Using this seed and the orders file, you can basically re-generate the turn every time you wish - the results are deterministic. Or should be - this is the reason for the "battle inconsistency" bug which at some points occured. And maybe the 2 bug still prevalent: (non-)dieing pretenders and wrong battle outcomes. external AI Because the turn results are basically re-created based on the game rules, active mods and the turns random seed(s), an external AI would need to do the same to get the full overview over a turns results: One would have to redo Dom3 in the AI code to be able to do that. Might as well use the game engine itself .. how to improve the AI I dunno. I heard Johan doesn't like doing GUI because it's boring. I would think doing AI is more interesting, but I never got any direct feedback from him, even when I presented pseudo-code in the forum. On the other hand, the AI does build forts now. I have no idea if I had any influence in this, though. Why the dynamic scripting shown in that paper will not work with Dominions Quote:
------------------------------------------------------------------------------------------- As for AI the most effective work around to this problem so far is to simply use an American instead, they tend to put up a bit more of a fight than your average Artificial Idiot. James McGuigan on rec.games.computer.stars somewhen back in 1998 |
Re: Atten Devs: AI (Rules-based dynamic scripting?
@Evil Dave
I haven't played Neverwinter Nights, but I understand that its tactical space is also pretty large (300+ spells). Also note that they were starting from square one, with all rules equally-weighted, to test out the effectiveness of dynamic scripting itself. In practice you'd probably be starting from a known rulebase that works against "most players." But yeah, it's unlikely that this would produce a truly intelligent AI--I'd settle for merely an adaptive one, so that it's no longer meaningful to talk about how to beat "the computer" but rather "this computer." Plus, I think the idea of AI programming metagames is a fun one. http://forum.shrapnelgames.com/images/smilies/happy.gif -M.D.W. |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Hmmm. Thanks for the inside information.
-Max |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Arralen, external AIs (of many types) could work. You'd have a program that would take as input a .trn file, a .map file, and any .mod files in effect (if you were feeling mod-friendly). It would do its thing, and give back a .2h file. Now, training some types of AI could be harder, since it wouldn't have direct access to the battle resolution engine; it still wouldn't be impossible though (remember the battle simulator from Dom2? Or it could create a microgame on a special 3-province AI-map to test strategies, much as real humans sometimes do...)
|
Re: Atten Devs: AI (Rules-based dynamic scripting?
Quote:
Quote:
If the file format is made public for an AI project, it might still be possible to see what units were deployed where at the start of battle. And the *exact* orders the enemy scripted his units with... which isn't normally available... so here's a small *unavoidable* cheating opportunity. Quote:
|
Re: Atten Devs: AI (Rules-based dynamic scripting?
Id be happy with AIs that had more of a range in their randoms. Or better yet, a setting that can affect the basic random rolls.
|
Re: Atten Devs: AI (Rules-based dynamic scripting?
Quote:
UNFORTUNATELY... in Dominions_3 the #startspell command is broken because it only works for ONE turn!! Based on the progress things are getting fixed it looks like my favorite map command will remain broken in Dominions_3. http://forum.shrapnelgames.com/images/smilies/fear.gif |
Re: Atten Devs: AI (Rules-based dynamic scripting?
Probably yes. Broken commands in the game tend to stay broken. Its taken me literally years to get some fixed.
|
All times are GMT -4. The time now is 03:58 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.