AI detail level and scripting

I’m just at conception stages of a new game and thinking about how to implement AI. The game takes place in two fields:

  1. A risk style level map where units are moved around to protect resoruce given by owning areas

  2. A combat arena where the units from the top level map fight it out in turn based strategy to take ownership of areas

Having never done much formal AI coding I was wondering about two things. First, does it make sense to treat both of scenarios seperately (as in completely decoupled) or to provide some way of the two interacting.

Second, I think I might finally bite the bullet and look at scripting again for the purposes of AI. I hear that Lua is the preferred option where AI is concerened but I’m not really sure of the pros/cons of different dynamic alternatives. LuaJava looks pretty mature and well used so I guess it’s a good option?

It’s all turned based so I’m thinking performance isn’t too much of a concern.

Thoughts appreciated,

Kev

Don’t have experience with scripting, tho i could say something about AI;

I guess you could treat both scenario’s the same. You’d prolly have to calculate a priority for each area every turn for all of the owned areas and the ajecent enemy ones,. The priority should be something constructed from the amount of units in the certain area, ajecent area sovereignity and some other factors. From there on you should be able to decide on where you want to move troops from and to (ie from low priority area to a high one). Maybe you could do something with A* pathfinding aswell if the units have to come from elsewhere.

About scripting, I’ve been really disappointed with it.

Seems like there are 3 main options and they are all half-baked IMO.

Groovy - must be fast since it turns the script into byte code and runs it in the JVM. Problem is that it is a whole new language that is similar but different to java. You can’t just cut and paste java code into and out of your program. http://groovy.codehaus.org/
F3 - Hasn’t been fully released yet and it is not real java either. http://blogs.sun.com/chrisoliver/entry/f3
BeanShell - Is meant to be like pure Java but there are lots of bugs. eg declaring an array can only be done like String anArray[] = …; Also the error reporting isn’t very good and the project hasn’t been active since mid-2005 it seems. Unlike Groovy the code isn’t turned into bytecode and fed to the JVM, instead it manipulates the objects using Reflection which is slower. http://www.beanshell.org/index.html

I hadn’t heard of Lua Java but it looks OK if you are already familiar with it… but once you’ve perfected the AI code wouldn’t you want to stick it in the Java code with the rest of the program?

Keith

I’m only going on others advice - as mentioned, AI and me haven’t really been together very long. Scripting gives the ability to tweak with in game editing without extra leg work. Sure once it’s perfected you could put it back into the source, however if it’s fast enough why bother?

Onyx suggested pnuts as a possibility, but so far I haven’t had any time to look at any of them.

As I mull it over in my mind I’m really having trouble justifying using scripting for this game tho - I just can’t picture how it’s going to be a great boon.

Kev

I use LUA when working with C, but for scripting in Java pnuts just rocks. It’s fast, easy to implement, easy to pick up, scripts can be compiled to classes… I can’t say enough good about it. I’ve used it both with and without the new scripting framework. It’s easy to implement either way. It supports generators (coroutines), which are very useful in AI scripting. I’m putting it to work in a project right now and so far, no troubles.

Actually, in testing most of the options, my personal favorite has been Groovy. pnuts has some odd little quirks.

What do you mean by “AI”? That’s anywhere from path-finding to Neural Nets. What you use will really depend on what kind of gameplay you are going for, and will probably be a combination of several things.

Hi,
I was just reading around and came across this site http://theopensourcery.com/jsgpsl.htm which mentions ‘Rhino’. I was wondering if anyone has any insight as to how useful it would be for game scripting.

Well, you can use it to script the menu flow or stuff like dialogs (high level logic). So, you can use it to do all the stuff which is usually done with scripting.

But you can’t script inner loops n stuff like that. Well, you could, but it would be too slow.

If you want to script everything, take a look at Janino (it’s a very fast on-the-fly compiler).