Page 1 of 3

New Java AI, HughAI

Posted: 06 Sep 2009, 16:12
by hughperkins
New Java AI, HughAI

To install

Make sure you have hoijui's Java Interface v0.1 installed. I believe this is installed automatically if you have Windows. Other platforms may have varying mileage.

Once you have Java Interface 0.1 installed ok:

1. Download HughAI from:

http://manageddreams.com/hughai/HughAI20090921b.tar.bz2

2. remove any old HughAIs, by deleting any existing directory AI/Skirmish/HughAI

3. untar (using Winzip or your favorite zip utility) into AI/Skirmish, so you should have the following directory structure:

AI/
Skirmish/
HughAI/
0.1/
SkirmishAI.jar
... other files ...

4. Run springlobby, create a single-player game, and do "add-bot"
- you can also use your favorite ai-supporting lobby, such as tasclient, though the instructions for use may vary slightly.

Note that the AI needs to be playing on Balanced Annihilation. On anything else, it will probably just sit there and do nothing :-D

It can beat E323AI v2.12.0 , when maphack is turned on.

More info

http://springrts.com/wiki/AI:HughAI

Edited on 7 September 2009 to add link to HughAI.tar.bz2, and brief installation instructions, and to remove lots of technical stuff.

Edited on 9 September 2009 to update link to new version of HughAI

Edited on 14 September 2009 to update link to new version of HughAI

Edited on 21 September 2009 with 20090921 release.
Edited on 21 September 2009 with 20090921b release.

Re: New Java AI, HughAI

Posted: 06 Sep 2009, 16:23
by hughperkins
Notes on source-code in src-ai/architecture.txt:

http://github.com/hughperkins/HughAI/bl ... ecture.txt

Edited on 9 Sep 2009 to remove the contents of the architecture file, to keep the thread cleaner.

Re: New Java AI, HughAI

Posted: 06 Sep 2009, 16:47
by AF
I assume you're using Vista? Your swing UI may not work as intended outside of windowed mode under XP or below due to architectural improvements in vista and later.

Re: New Java AI, HughAI

Posted: 06 Sep 2009, 16:50
by hughperkins
Ubuntu. I take it the GUI acts strangely in XP?

Re: New Java AI, HughAI

Posted: 06 Sep 2009, 22:17
by AF
I wouldnt knwo as Im in vista, but XP does not virtualize the gpu memory liek Vista and some linux distros do, so thing sliek runnign 2 opengl programs at once isnt possible, so it could be a problem with fullscrene OGL spring + java ogl/directx swing rendering.

Re: New Java AI, HughAI

Posted: 07 Sep 2009, 13:22
by hoijui
Tested here on WinXP, no problem. You have some cool stuff there! :D
Surely good for testing and bug hunting, i would say :-)

The Java AI Interface comes with spring for windows since 0.79, it is not possible to install spring through an installer without that interface.
It is in the Ubuntu default packages since 0.80.4 (if i am not mistaken, definatly in 0.80.4.1). I guess it is not in the Gentoo overlay, and i have no idea about other distributions.

TASClient also supports AIs, QTLobby does not yet, and i have no ide about other lobbies.
In general, also with SpringLobby, it is more convenient to host a muliplayer game, even if you want to play alone agaisnt bots. just set a password for your game. This way you will get the default map and mod set when you open a game with SL, and you have more options, plus this interface is much more tested. For a simple human vs bot, it does not make a big difference though.

Re: New Java AI, HughAI

Posted: 08 Sep 2009, 07:00
by hughperkins
hoijui wrote:Tested here on WinXP, no problem. You have some cool stuff there! :D
Thanks, hoijui!
Surely good for testing and bug hunting, i would say :-)
;-)

Re: New Java AI, HughAI

Posted: 09 Sep 2009, 12:12
by hughperkins
New version, can beat yesterday's version of E323 ;-) Not sure about today's git version of E323, haven't tried yet, quite happy at at least having won one game against E323 :-DDDD

See first post for link (I'll edit it in a second), or grab the link from the wiki:

http://springrts.com/wiki/AI:HughAI

Changes this version:
- added threatmap (obviously... it was one of the two things that meant E323 annihilated me before)
- added maphack (the other major thing that prevented anything exciting happening against E323 before)
- added configuration tab to gui
- added console tab to gui

Under the covers:
- migrated from generic Float3s all over the place to usage-specific classes, such as TerrainPos, BuildMapPos, LosMapPos, and so on, since I was tired of figuring out what granularity each map was, and how to convert from one pos to another, and getting it consistently wrong ;-)

A picture of the Console, for techies:

Image

Re: New Java AI, HughAI

Posted: 09 Sep 2009, 12:41
by imbaczek
you really really really don't want a Java console, use jython or jruby or groovy or rhino js or whatever, but not java please...

Re: New Java AI, HughAI

Posted: 09 Sep 2009, 14:27
by hughperkins
Well, I nearly did it in Rhino, because it looked easier to code a Rhino console, but, I felt I'd rather have it in Java, since it saves learning yet-another-language.

We could arguably make the language of the console configurable / pluggable. Could a console in Rhino (seems to be built into Java, so not a PITA to deploy) be interesting to you?

Hugh

Re: New Java AI, HughAI

Posted: 09 Sep 2009, 15:11
by imbaczek
being able to do just showmsg("stuff") instead of 6 or so lines of code is always a win, so yeah.

Re: New Java AI, HughAI

Posted: 10 Sep 2009, 02:51
by hughperkins
Ok, a teaser picture for you:

Image

Re: New Java AI, HughAI

Posted: 10 Sep 2009, 11:07
by imbaczek
now this is cool. well done.

Re: New Java AI, HughAI

Posted: 10 Sep 2009, 23:45
by cranphin

Code: Select all

0 ms: ... slopes calculated
0 ms: GenerateVehicleAccessibleMap
0 ms: GenerateBoatAccessibleMap
0 ms: CreateAreas
0 ms: Exception: java.lang.ArrayIndexOutOfBoundsException: 320
0 ms: UnitCreated()
0 ms: Exception: java.lang.NullPointerException
0 ms: Exception: java.lang.NullPointerException
0 ms: Exception: java.lang.NullPointerException
I probably did something wrong XD
where's the stacktraces of the exceptions tho ? :)

Re: New Java AI, HughAI

Posted: 11 Sep 2009, 03:05
by hughperkins
Erm.... that is odd.... normally, most(all, in theory) AI events have e.printStackTrace() in their catches, but maybe I missed one, or maybe it's being 'caught' somewhere else.

Could you confirm:
- which version of HughAI you are using? (from git? if so, which commit / date. from the download above? the one from 9th September, or an earlier download?)
- the mod you are using
- the map you are using
- how far into the game it got before it crashed.

Basically, I've been testing on BA6.96(? whatever seemed the current version about four weeks ago anyway) against SmallDivide.

Re: New Java AI, HughAI

Posted: 11 Sep 2009, 10:23
by cranphin
Hi!

Some answers from memory, since I'm prolly off for the weekend, mayby, my pc is in the back of my car so.. XD

Hey, try my ai btw. XD (See Java interface forum :) )

I think this happend with both the downloaded precompiled file as with the latest git , since I think I remember wanting to try the git source to see if it would solve it, think the precompiled had a nullpointerexception too :)
(Git version was yesterday late, the commit to notes.txt something to do with not being possible to fix performance or so :D).

This is with Spring 0.80.4.1.
I think it's BA 7.00
Map was DeltaSiegeDry probably.


Don't fret too much about it/put much time in it, I may have done something weird :)
If I get some time and motivation I'll remote debug it :)

My way of building is pretty bad too, I just created 2 jars out of the class files eclipse made, and copied that in your 'binary' release folder, along with whatever was in the release folder :)

P.S. Ohyeah, you may be able to tell this from the log file, but it was right at the start of the game, the commander never moves :) And it was against KAIK version included with latest Spring :)

Re: New Java AI, HughAI

Posted: 12 Sep 2009, 04:01
by hughperkins
Hi cranphin,

I spent several hours trying to download deltasiegedry, and failed ;-)

Anyway, I poked around the code a little, and what I think is that deltasiegedry is probably a rectangular map? and I only tested on square maps, there was a bit of code that looked like:

Code: Select all

for( int y = 0; y < mapwidth / granularity; y++ ) {
         for( int x = 0; x < mapwidth / granularity; x++ ) {
          ... stuff
    }
}
... using mapwidth for both dimensions.

I've corrected that issue, but there may be other places with the same error, and I don't have a rectangular map to test with just yet. I'll keep trying to download deltasiegedry. Maybe you could try with a square map for now? Or you could try with deltasiegedry, and just keep sending me the exceptions as they occur ;-)

For the stacktrace... I poked around a little ... I think that the stacktrace was probably logged to the console, which is what I tend to use day to day, but not to the actual logfile. I've tweaked the code so that the stacktrace should be logged now also to the logfile.

Both corrections are in current HughAI git.

Do you have a link to your ai, or to the appropriate thread cranphin? I searched around but either couldn't find it, or didn't realize it was yours.

Hugh

Edit: I've managed to download deltasiegedry. I'll give that a whirl and check that there are no other issues with rectangular maps.

Re: New Java AI, HughAI

Posted: 12 Sep 2009, 05:05
by ato
Were you trying to download the map with the SpringLobby torrent client? That almost never works for me. Try springfiles.com instead.

I've added links for E323AI, CransJavaAI and my (planned ie doesn't do anything yet) ClojAI to the wiki list.

Re: New Java AI, HughAI

Posted: 12 Sep 2009, 13:50
by cranphin
Yup, git works now, it was a non square map issue :D

Hmm, mayby I should steal the console idea :)
The only Issue I see/have with the console is that on XP and with 0.80, which seems to have introduced issues with alt-tabbing out of fullscreen on XP, it makes the console take the forecround, and thus the fullscreen dissapear, which then nearly locks up everything XD
But easily solved by playing in windowed mode :)

My ai (which apparently has been put on the wiki now XD) at: http://code.google.com/p/crans-java-ai/.
I didn't promote it much yet since it's not a very good port yet, and people other then developers/curious are better off with just KAIK :)
But guess it's ok to be on the wiki ^_^

Will play more with your wen I actually find time :)

P.S. Ohyeah, found this in the log, no idea what I did to do that :)
Very much at the end tho, so prolly before I did exit.

Code: Select all

0:1:45.0: java.lang.NullPointerException
	at hughai.basictypes.OOPCommands$MoveToCommand.ToSpringCommand(OOPCommands.java:189)
	at hughai.GiveOrderWrapper.GiveOrder(GiveOrderWrapper.java:204)
	at hughai.GiveOrderWrapper.MoveTo(GiveOrderWrapper.java:157)
	at hughai.packcoordinators.SpreadSearchPackCoordinatorWithSearchGrid.ExploreWith(SpreadSearchPackCoordinatorWithSearchGrid.java:240)
	at hughai.packcoordinators.SpreadSearchPackCoordinatorWithSearchGrid.Recoordinate(SpreadSearchPackCoordinatorWithSearchGrid.java:144)
	at hughai.packcoordinators.SpreadSearchPackCoordinatorWithSearchGrid$GameListenerHandler.Tick(SpreadSearchPackCoordinatorWithSearchGrid.java:276)
	at hughai.CSAI.update(CSAI.java:629)
	at hughai.loader.HughAILoader.update(HughAILoader.java:104)
	at com.springrts.ai.oo.OOAIFactory.handleEvent(OOAIFactory.java:93)
0:1:45.0: Exception: java.lang.NullPointerException

Re: New Java AI, HughAI

Posted: 13 Sep 2009, 09:21
by hughperkins
cranphin wrote:Yup, git works now, it was a non square map issue :D
Great!
Hmm, mayby I should steal the console idea :)
Please do! Grab whatever you want, copy and paste, grab the code. I'd appreciate my name in any relevant copyright notices, and some form of attribution proportional to the quantity of code grabbed, but I'm very happy if other people use the code.
The only Issue I see/have with the console is that on XP and with 0.80, which seems to have introduced issues with alt-tabbing out of fullscreen on XP, it makes the console take the forecround, and thus the fullscreen dissapear, which then nearly locks up everything XD
I've added an option to my config file to make the gui possible to be disactivated, but perhaps the easiest thing could be to have it disactivated by default, and then to have a spoken command to make it appear?
My ai (which apparently has been put on the wiki now XD) at: http://code.google.com/p/crans-java-ai/.
Wow, you ported KAIK in it's entirety! That's very cool. Maybe I'll take a look. Depending on how it looks I may look at extending / tweaking KAIK rather than extending / tweaking HughAI. I'll take a look and see which seems to be the easiest path to me.
I didn't promote it much yet since it's not a very good port yet, and people other then developers/curious are better off with just KAIK :)
Can you give me a list of the points you feel are outstanding in getting it to run more or less as well as the original KAIK?
P.S. Ohyeah, found this in the log, no idea what I did to do that :)
Ok, it looks like probably a unit was killed off, and then the pack coordinator didn't realize that for some reason. Don't suppose.... if you still have it... could you paste the entire log into pastebin, or attach it to a message please?

Hugh