[C++] Access MapHardness param

[C++] Access MapHardness param

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

Moderators: hoijui, Moderators

Post Reply
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

[C++] Access MapHardness param

Post by lamer »

Would it be useful to have access to MapHardness and notDeformable map params?
I don't use it yet but for the future: it could be used to determine if HeavyTank (ZK) factory is appropriate on the map for example. Though there are additional sections in .smd like

Code: Select all

	[TERRAINTYPE0]								
	{
		name=AstroTurf;
		hardness=1;
		tankmovespeed=1;
		kbotmovespeed=1;
		hovermovespeed=1;
		shipmovespeed=1;
	}

	[TERRAINTYPE255]
	{
		name=Eta Carinae Nebula;
		hardness=10;
		tankmovespeed=0;
		kbotmovespeed=0;
		hovermovespeed=0;
		shipmovespeed=0;
	}
And i also kinda don't see how to access those sections (except parsing .smd).
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: [C++] Access MapHardness param

Post by PicassoCT »

is that nullProblemo-hard or nullProblemo-soft :D?
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: [C++] Access MapHardness param

Post by lamer »

Eh, someone should call Troll Care & Control Centre.
But thanks for the feedback, now i see its easier to parse text files than asking community about ai interface or its changes.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: [C++] Access MapHardness param

Post by zwzsg »

If the map use a .lua instead of a .smd, your parser won't be of much use.

And even if you slap a Lua interpreter on your AI, I feel there's some cases where tiny changes in the environment could make it produce different output. If you don't care about these as they make a tiny proportion of all existing Spring maps, please at least make sure the AI code handle the error nicely.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: [C++] Access MapHardness param

Post by Silentwings »

I once had a similar problem wanting to find out the set of startpoints in the mapinfo smd/lua file. I don't know of a good solution.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: [C++] Access MapHardness param

Post by lamer »

Just for clarification: i'm talking about only native ai interfaces (Java, C++). Gadget ais have much more callins i believe.

@zwzsg, thanks for warning. I'll mark it in todo/fixme. And thats actually +1 for adding all (or atleast standart map parameters that engine knows) into AI's Map interface. Yet i'm too green to do it now (not before version 1.0 of my ai for zk).

@Silentwings, i guess startpoints issue is similar. I know only that there are list of strart positions in Game::GetSetupScript. If map's strartpoints is something standart, then it could go into AI's Map/Game interface too. So far i had little interest to startpoints, because of plan to make decisions about critical points based on ai's own terrain analyzer (e.g. where are the largest metal spots, building plateau, probably bounding box, chokepoints etc.).
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: [C++] Access MapHardness param

Post by lamer »

Back to this issue.
My ai made it to factory selection stage, and it really lacks (i believe) MapHardness parameter. Because of that it almost always prefers all-terrain factory to heavy-tanks (low-slope units).
I'm looking forward to add Map::GetHardness() function (ignoring local terrain types so far) into AI interface.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: [C++] Access MapHardness param

Post by Anarchid »

Afaik there's no global map hardness; hardness is defined per map terrain type, which is then applied via typemap.

An example is SandCastles, which have soft sand but uber hard castles.

So, ideally, your new AI function would expose the typemap as well as a description of each terrain type.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: [C++] Access MapHardness param

Post by lamer »

There is global hardness and on top of that applied local terrain-types hardness (those are multipliers to mapHardness).

Therefore 2 ways i can think of:
1) clone LuaSyncedRead::GetGroundInfo(x, z) and split it into set of functions:
float Game::GetMapHardness() // returns global hardness
bool Map::IsDeformable();
float Map::GetHardness(x, z) // returns mapHardness * terrainType.hardness
float Map::GetTankSpeed(x, z)
float Map::GetKbotSpeed(x, z)
float Map::GetHoverSpeed(x, z)
float Map::GetShipSpeed(x, z)

2) Make hardnessMap (like slopeMap, heightMap)
std::vector<float> Map::GetHardness()
std::vector<float> Map::GetTankSpeed()
...
Last edited by lamer on 12 Nov 2015, 15:47, edited 2 times in total.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: [C++] Access MapHardness param

Post by AF »

The decision as to wether to use tanks or kbots etc, is best not decided using map hardness, but rather map height differences/slopes, otherwise you're going to have to code in a whole routine if a soft map with minimal passable areas for vehicles is used so that you can blast your way a path to the other player. Meanwhile the other player used kbots and blew up your base.

This combined with the trend towards maps that have no ground deformation at all, it doesn't make so much sense when heightmap analysis and passability can yield more interesting results
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: [C++] Access MapHardness param

Post by lamer »

The decision as to wether to use tanks or kbots etc, is best not decided using map hardness, but rather map height differences/slopes
Thats exactly what i do now (borrowed from RAI terrain analyzer) and AI rather prefer spiders (because they can cope with most height differences/slopes).
Now imagine large pure flat map (low height differences) but very soft (1 hit will make tank stuck). Should AI even consider to start with tanks?

So imo next factors can influance factory choice:
1) map height differences/slopes;
2) unit's speed/map size;
3) map hardness;
aeonios
Posts: 202
Joined: 03 Feb 2015, 14:27

Re: [C++] Access MapHardness param

Post by aeonios »

Icy shell is a good example of where map hardness becomes problematic. Icy shell is very flat and mostly veh friendly, but it has very low hardness to the point where reapers get flipped over in potholes created by their own weapons after only a few shots. It's true that there aren't very many maps like that, but they do exist and are played.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: [C++] Access MapHardness param

Post by lamer »

Final (almost) decision:

Code: Select all

bool Map::IsDeformable();

/** Returns global map hardness */
float Map::GetHardness();

/**
 * Returns hardness modifiers of the squares adjusted by terrain type.
 *
 * - index 0 is top left
 * - each data position is 2*2 in size (relative to heightmap)
 * - the value for the full resolution position (x, z) is at index ((z * width + x) / 2)
 * - the last value, bottom right, is at index (width/2 * height/2 - 1)
 *
 * @see getHardness()
 */
std::vector<float> Map::GetHardnessModMap();

/**
 * Returns speed modifiers of the squares
 * for specific speedModClass adjusted by terrain type.
 *
 * - index 0 is top left
 * - each data position is 2*2 in size (relative to heightmap)
 * - the value for the full resolution position (x, z) is at index ((z * width + x) / 2)
 * - the last value, bottom right, is at index (width/2 * height/2 - 1)
 *
 * @see MoveData#getSpeedModClass
 */
std::vector<float> Map::GetSpeedModMap(int speedModClass);
I have doubts about GetHardnessModMap (return raw modifiers or multiply with hardness?)
PR
Post Reply

Return to “AI”