Java AI: choose start point

Java AI: choose start point

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Java AI: choose start point

Post by playerO1 »

I using Java for write AI. I using function 'clb.getMap().getStartPos()' for get info about start point to AI. But I found that if start pos set as 'box' mode then this return left-top cornier of boxes. How get start pos type and box square?
And I found description about function 'clb.getGame().sendStartPosition(boolean ready, AIFloat3 pos)' but don't undestand how use it. From where method I can call this function update, init, message(int player, String message)? How it work?
I want say to bot in point message where he will be start and they start on this point.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Java AI: choose start point

Post by Anarchid »

It doesn't work and it can't work because your bot gets its Init() when and only when the game starts.

And it's too late by then.

Sorry.

I'd love to pick my own startpos, too.
And I found description about function 'clb.getGame().sendStartPosition(boolean ready, AIFloat3 pos)' but don't undestand how use it

Code: Select all

AIFloat3 position = getStartPosition(); // self-implemented function to pick best spot
this.callback.sendStartPosition(true, position);
This is how you would be using it if it worked.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: Java AI: choose start point

Post by lamer »

Struggling the same issue.
I see next options to solve it:
1) Create and initialize NativeAI before NETMSG_STARTPLAYING (rts/Net/NetCommands.cpp) occurs. Couldn't find in code exact position to move init yet, still looking.
And when choose position stage occurs - send EVENT_CHOOSEPOS to localIAs.
2) Write some magic unsynced Lua that has to know which players are local native AIs. Somewhere during LuaAI initialization stage it has to compute and send NETMSG_STARTPOS for each local native AI.

2nd aproach is something of sience fiction to me because i have no idea about Lua capabilities, APIs. And its not good to have Lua part when i want to write NativeAI :)
1st method requires engine modification, 2nd (if its even possible) - presumably not.
Any thoughts or suggestions?
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: Java AI: choose start point

Post by lamer »

Made implementation of 1st method. It occurs much easier than i thought (if i didn't broke anything, but tests were good). And there was no need for separate EVENT_CHOOSEPOS, just init earlier.

Will submit a pull request in the near future.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Java AI: choose start point

Post by Anarchid »

Please sign here to accept your shipment of massive kudos.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: Java AI: choose start point

Post by lamer »

X
signed. Kudos, kudos, kudos, kudos, cookies, kudos, kudos.
Pushed pull request into spring's pool. Awaiting approval/denial.

https://github.com/spring/spring/pull/118
Post Reply

Return to “AI”