Mex built above and left of metal spot

Mex built above and left of metal spot

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

Moderators: hoijui, Moderators

Post Reply
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Mex built above and left of metal spot

Post by hangfire »

Hello,
Got a tad excited when I found out about the spring project, been keeping an eye for something like this for a while.

Anyway I have a noob question so please forgive me if this is obvious.

So on unitFinished the economy manager i built makes a list of all the metal spots and then the method nearestMetalSpot gives returns a AIFloat3 value of the nearest metal spot.

I then give the command to my commander to build a mex, but the mex is always not on top of the metal spot, but placed diagonally top left of it.

I'm wondering in the metalspot position is the top left corner and the build position is the bottom right corner of the structure.

Would someone mind putting me right?

Thank you
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Mex built up and left of metal spot

Post by AF »

When SJ first introduced the engine, it was with an air to producing an XTA which deviated somewhat from OTA, in that he'd have energy webs of sort, and one of his changes, was metal radius, rather than metal spots.

The cosnequence of this si that a metal extractors output will depend on the values of the metalmap covered by its radius. People didnt like this resulting in metalmaps which had just spots and tiny radii to replicate OTA behaviour. You'll see metalmaps SJ style on maps such as brazillian battlefields.

So, now we know a metal extractor needs to be within range of a spot to extract, not built directly and only directly ontop, we come to the algorithm that reads in the metalmap grid and figures out where to place the extractors.

The best we have so far are variants of the algorithm devised originally for KAI.These place them to the upper left corner because that's a quirk of its algorithm. Press f4 however and you'll see that the extractor is still placed within range of the metal spot.

Because of this, any translation to fix this adjustment would be purely cosmetic, and some players and AIs deliberatly do this offsetting to exploit the mechanics, e.g. building a moho extractor on the spot while the metal extractor continues mining offsetted, so you dont loose income while building.
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: Mex built up and left of metal spot

Post by hangfire »

Oh yeah, i just tried it and took control of a commander, built a mex right on top of a metal spot and it was producing 1.99, then resigned to examine the mexes the AI had built and likewise producing 1.99.

Thanks for the reply, i'll not worry about the cosmetics and crack on with the next bit.

Thanks again
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Mex built up and left of metal spot

Post by hoijui »

btw... are you using the Java AI-Interface or the (new) C++ AI Wrapper?

in both cases, there will be some (relatively big) changes in those when the next mayor version of spring comes out (0.83). You can see them, and changes required for them in AIs by looking at spring master branch already (we refer to changes as the pureint changes).
Just saying, cause you probably want to code for that right away, depending on your goals.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Mex built up and left of metal spot

Post by AF »

A new pureint sticky for the next release detailing changes?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Mex built up and left of metal spot

Post by AF »

>.< We need a lightning dance unicorn gif for stickies
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: Mex built above and left of metal spot

Post by hangfire »

lol, a lot of what you say goes right over my head! Sorry.

I have another question if that's okay?

My bot is working fine in the CA mod, but not the BA mod.
I think it's something to do with how i'm creating a command, like this...

Code: Select all

AICommand command = new BuildUnitAICommand(this.commander, -1, new ArrayList<AICommand.Option>(), 10000, this.botFactory, pos, 0);
then in another method which handles the commands this
int ret = this.clb.getEngine().handleCommand(AICommandWrapper.COMMAND_TO_ID_ENGINE, -1, command);
edit: sorry yes I am using the java interface
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Mex built above and left of metal spot

Post by hoijui »

you should really come to the #ai channel in the lobby!
with the pureint changes (see link i posted above), the way commands work will change completely. commands will be integrated into the callback interface.
though, it is unlikely that it is the way you use commands, as this is not different between CA and BA. if something does not work, explain exactly what/how it does not work, and if it crashes, attach infolog.txt to your post.
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: Mex built above and left of metal spot

Post by hangfire »

Thanks for your advice the other day.

I've altered my code so it build units based on UnitDef properties as opposed to unit name, which in case anyone was wondering is why my bot worked in CA and not BA - rookie mistake.

So i'm thinking about long term memory for my bot. Would something like an XML file be the easist way to store battle results or does Spring have a database i could hook into?

Hang
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Mex built above and left of metal spot

Post by hoijui »

there is a replays site, which.. i think.. also has a DB with the basic statistics (how many teams, who won, ...).
do not have link though.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Mex built above and left of metal spot

Post by knorke »

hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: Mex built above and left of metal spot

Post by hangfire »

Wow, cool links. Although I was thinking of something for my bot to learn...true AI stylie. I'll figure it out...

Anyone know why the getMoveData() methods would cause spring to crash when applied to Air units?

I'm trying to make my bots build units based on their qualities, as opposed to their names, but after an airfactory has been built spring crashes. I know it's those lines of code cause when I comment them out and rebuild the bots work fine.

Hf
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Mex built above and left of metal spot

Post by AF »

always check for returned null pointers when making API calls
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: Mex built above and left of metal spot

Post by hangfire »

That's a fair comment and indicative of my desire to crack on with developing the AI element of the bot. I was simply returning the results to a log so I could examine the return values and were not to going to be apart of the final code.

But why does the getMoveData method not work for air type units?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Mex built above and left of metal spot

Post by AF »

I think its because of historical reasons in how Air movement is implemented, in that air relies on the unitdef values such as aeleron ( did I spell that right ) etc, to simulate aircraft movement, which is completely different to how ground units and movedefs work.

Error values in the API tend to take the form of null pointers being returned, or error positions, most notable the upvector constant float3(0,1,0). This is why one should be careful, and why basic AIs just starting out will give commands in the top left corner sometimes.

Maybe this post and one or two others should be separated out into a sticky on handling API error return values?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Mex built above and left of metal spot

Post by hoijui »

if spring crashes while using the Java AI API, it is likely a bug of spring/the AI Interface. in spring, move-data is something that air units do not have, but the crash should not happen of course, but null should be returned.
It is quite likely that this is fixed in pureint changes though, so again.. i encourage you to use spring master (unstable), instead of current release.
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: Mex built above and left of metal spot

Post by hangfire »

You guys seem to have you own language or something :lol:
i've been on the thread that discusses the pureint changes and there's nothing to download or links to a page that allows you to download the pureint version.

Of course I have been to the download page and can only see that I can download the current stable version.

@AF I can't remember if I thanked you for your answer, it was helpful. I guess because Spring is constantly evolving there are dead ends and pit falls that I need to be more careful about.

Finally can anyone help me with a quandry?

Here's a very simple build command

Code: Select all

AICommand command = new BuildUnitAICommand(this.unit, -1, new ArrayList<AICommand.Option>(), 10000, solar, pos, 0);
I understand that this parameter

Code: Select all

new ArrayList<AICommand.Option>()
can be used to simulate a shift click or alt click. But how?

Cya HF
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Mex built above and left of metal spot

Post by hoijui »

join the channel i told you in the lobby, and ask for help there.

this is the currently latest master build (installer), and it contains pureint changes.
you might encounter random bugs of course, as they are more common in the master build then in release versions.
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: Mex built above and left of metal spot

Post by hangfire »

I've been in the channel tonnes of times.
Usually there's one or two people in there and getting a reply takes about 10 minutes and usually I'm at work most of the day.

Why, what's wrong with asking questions on a forum? At least that way there's an audit trail so if other people have the same/similar questions they might get the answer by reading the thread.

Ah well, i'll just struggle on and see how far I get.
Post Reply

Return to “AI”