Page 1 of 1

Metal maps and AI

Posted: 20 Aug 2014, 14:09
by playerO1
Some AI crash or can't start on metal maps. Metal maps - wap where all square have metal.
I fount that call getMap().getResourceMapSpotsPositions(metal) is dangerous on this map (too many points).
I test this map by call getResourceNearest(), but found next bug: sometime Y(Z) position is far from start check point.
I check near position for metal around commander:

Code: Select all

METAL TEST >pos=8319.0:8976.0 result k=8296.0:1336.0
  >d=7640.0347
  >d fix=23.0
METAL TEST >pos=8295.188:9057.096 result k=8296.0:1336.0
    >d=7721.0957
    >d fix=0.81152344
METAL TEST >pos=8231.3125:9112.444 result k=8248.0:1336.0
    >d=7776.4624
    >d fix=16.6875
...
METAL TEST >pos=8231.3125:8839.556 result k=8248.0:1336.0
    >d=7503.574
    >d fix=16.6875
METAL TEST PARAM. pos=8169.0:8976.0 Avg k=129.5752 nApprox=10 dLmax=23.0 extractorR=20.0
This is a map with metal field. Average k=17.97876
Exist more best and fast method for check: is the metal field map? I found getResourceMapRaw() but don't know it is more fast or slow.

Re: Metal maps and AI

Posted: 21 Aug 2014, 18:01
by lamer
As far as i know there is no predefined way to determine metal maps or metal zones.
But here are some ideas:
1) The easiest solution is to test if size of getResourceMapSpotsPositions() = 10000 (don't remember exactly max number). When you sure that this is metal map call getResourceMapRaw and test if there is metal around your start position manually. (I assume there is no bug with getResourceNearest, it just looking for nearest spot from only 10000 precalculated positions and not from all metal zones).
2) Zero-k game has param "mex_count" in GameRulesParams, and if its = -1, then this is metal map. But there is no API to get that parameter (before 97.0.1-312).

I'm not an engine dev nor AI dev, so i could be wrong.