Page 1 of 1
[C++] Access MapHardness param
Posted: 13 Feb 2015, 23:47
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).
Re: [C++] Access MapHardness param
Posted: 15 Feb 2015, 09:16
by PicassoCT
is that nullProblemo-hard or nullProblemo-soft :D?
Re: [C++] Access MapHardness param
Posted: 15 Feb 2015, 12:18
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.
Re: [C++] Access MapHardness param
Posted: 15 Feb 2015, 18:53
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.
Re: [C++] Access MapHardness param
Posted: 15 Feb 2015, 20:06
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.
Re: [C++] Access MapHardness param
Posted: 15 Feb 2015, 22:30
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.).
Re: [C++] Access MapHardness param
Posted: 11 Nov 2015, 21:18
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.
Re: [C++] Access MapHardness param
Posted: 12 Nov 2015, 03:00
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.
Re: [C++] Access MapHardness param
Posted: 12 Nov 2015, 11:41
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()
...
Re: [C++] Access MapHardness param
Posted: 12 Nov 2015, 15:19
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
Re: [C++] Access MapHardness param
Posted: 12 Nov 2015, 15:30
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;
Re: [C++] Access MapHardness param
Posted: 15 Nov 2015, 13:07
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.
Re: [C++] Access MapHardness param
Posted: 16 Nov 2015, 18:21
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