Page 1 of 2
detecting metal spots
Posted: 14 May 2011, 02:09
by knorke
What is a good way to detect metal spots?
Obviously scanning the map blabla but it is not so trivial to decide where the spots really are.
So I tried this thing: "Metal Spot Finder" by Niobium
http://widgets.springrts.de/springinfo/index.php#183
Sometimes works good, sometimes thinks it is on a metal map even if it is not and returns no spots.
Seems this:
Code: Select all
elseif stripStart then
if mx - gridSize - stripStart > extractorRadius then
Spring.Echo('<WG.metalSpots> Mass metal detected. Disabling.')
return {}
is the detection for it.
So I could just take that out or make less strict but maybe somebody has already done testing with that and has something better?
Re: detecting metal spots
Posted: 14 May 2011, 04:46
by Forboding Angel
Re: detecting metal spots
Posted: 14 May 2011, 05:16
by bobthedinosaur
do trace amounts set off nobium's detector? like if a mapper didnt delete some metal completely or placed some on very lightly.
Re: detecting metal spots
Posted: 14 May 2011, 05:55
by Niobium
knorke wrote:Sometimes works good, sometimes thinks it is on a metal map even if it is not and returns no spots.

...
So I could just take that out or make less strict but maybe somebody has already done testing with that and has something better?
Out of interest, what map is it that you are getting that on? I've got an update (later today) which fixes the uncappable detection so that might fix it.
bobthedinosaur wrote:do trace amounts set off nobium's detector? like if a mapper didnt delete some metal completely or placed some on very lightly.
>0 = metal. I haven't seen any maps with 'trace' amounts other than the cloud metal ones like small divide, which my widget intentionally doesn't work with.
Re: detecting metal spots
Posted: 14 May 2011, 07:22
by knorke
Forb:
thanks but without info if it works better or worse, it is not much use.
tbh I am just looking for something that works reliable
Niob:
happens on ie "Barren"
the spots are a bit fuzzy there but still clearly spots.
Noticed that just converting the canceling into a warning (
http://springrts.com/phpbb/viewtopic.ph ... 8&start=62) seems to work well.
I thought it would place millions of metalspots or get caught in an endless loop or something but even on "Speedballs 16 way" it works. It puts one spot right in the middle of the map, which makes sense.

But I did not test much and if you can make it even better, that is by all means good.
Re: detecting metal spots
Posted: 14 May 2011, 08:45
by Forboding Angel
It works better. Much better. It is what defines the mex spots for easymetal in evo. If it doesn't do it's job right, than evo won't play.
It also does a nice job with making metal maps sort of playable.
Give it a shot, it's quite good.
Re: detecting metal spots
Posted: 14 May 2011, 09:59
by Niobium
Updated to v1.1.
Changelog:
- Removed mid-search exiting
- Fixed valid extractor positions calculation
Rather than changing the high-metal error to a warning I just removed the check altogether, including the messages. So now it will always run the full search and return the positions it found (which for metal maps would be 1 spot the size of the entire map). Note that the widget actually runs the fastest on high metal maps, so this 'early exit on high metal' wasn't required at all.
I figured it should be up to the widgets that make use of the metal spot data to decide what makes sense*, rather than the finder making those decisions itself.
Also the valid positions calculation fix is fairly important, so definitely update just on that alone.
* i.e. if #WG.metalSpots < 5 then exit
Re: detecting metal spots
Posted: 14 May 2011, 12:45
by FLOZi
Re: detecting metal spots
Posted: 15 May 2011, 04:34
by knorke
easymetal has some unrelated stuff in it, cba to take it apart

Niobiums thing with the fixes is perfect.
Re: detecting metal spots
Posted: 15 May 2011, 04:49
by Google_Frog
Here is a standalone file with the easymetal algorithm.
http://code.google.com/p/zero-k/source/ ... finder.lua
Re: detecting metal spots
Posted: 15 May 2011, 05:37
by Niobium
FLOZi wrote:easymetal algorithm gets my vote.
Speed test on Dworld_V1:
Easymetal: 4.828 seconds
Niobiums: 0.131 seconds
Speed test on SpeedBall_10x10:
Easymetal: 13.441 seconds
Niobiums: 0.017 seconds
Re: detecting metal spots
Posted: 15 May 2011, 06:54
by zwzsg
I do it like that:
Code: Select all
local SpotList = {}
local MinSpotDist = math.max(Game.extractorRadius,112)
local minmetal, maxmetal = nil, nil
for x = 16,Game.mapSizeX,32 do
for z = 16,Game.mapSizeZ,32 do
local _,m = Spring.GetGroundInfo(x,z)
if not minmetal or m<minmetal then
minmetal = m
end
if not maxmetal or m>maxmetal then
maxmetal = m
end
end
end
local mediummetal = (maxmetal - minmetal)/2
Spring.Echo("Metal: ["..maxmetal.."-"..minmetal.."]")
if maxmetal == minmetal then -- Special case for metal map, or no metal map
local MinSpotDist = math.sqrt(Game.mapSizeX*Game.mapSizeZ/(4*#Spring.GetTeamList()))
for x = MinSpotDist/2,Game.mapSizeX,MinSpotDist do
for z = MinSpotDist/2,Game.mapSizeZ,MinSpotDist do
table.insert(SpotList, {x=x, y=Spring.GetGroundHeight(x,z), z=z})
end
end
else
for x = 16,Game.mapSizeX,32 do
for z = 16,Game.mapSizeZ,32 do
local _,m = Spring.GetGroundInfo(x,z)
if m >= mediummetal then
local newSpot=true
for _,g in ipairs(SpotList) do
if math.sqrt((x-g.x)*(x-g.x) + (z-g.z)*(z-g.z)) < MinSpotDist then
newSpot = false
break
end
end
if newSpot then
Spring.Echo("Insert!")
table.insert(SpotList, {x=x, y=Spring.GetGroundHeight(x,z), z=z})
end
end
end
end
end
for _,g in ipairs(SpotList) do
Spring.CreateFeature("geovent", g.x, g.y, g.z)
end
Not sure if optimised. On metal maps, put about four spots per team.
Re: detecting metal spots
Posted: 15 May 2011, 09:23
by CarRepairer
I updated the easymetal algo in evo so it's slightly better optimized than the one in zk (which I first wrote a hundred years ago).
Easymetal is intended to work with any metalmap, including those large blob metal spots.
This link, not the one forb linked...
https://code.google.com/p/evolutionrts/ ... ymetal.lua#
Re: detecting metal spots
Posted: 15 May 2011, 09:54
by Cheesecan
Niobium wrote:FLOZi wrote:easymetal algorithm gets my vote.
Speed test on Dworld_V1:
Easymetal: 4.828 seconds
Niobiums: 0.131 seconds
Speed test on SpeedBall_10x10:
Easymetal: 13.441 seconds
Niobiums: 0.017 seconds
Lol pwned.
Re: detecting metal spots
Posted: 15 May 2011, 10:51
by Niobium
Well I used the one that YOU linked, not forb... but anyway I retested using the 'better optimized' evo version:
Speed test on Dworld_V1:
Niobums: 0.131 seconds
Easymetal (ZK): 4.737 seconds
Easymetal (Evo): 6.002 seconds
'better optimized' == 'even slower'. Interesting.
Re: detecting metal spots
Posted: 15 May 2011, 20:24
by CarRepairer
Easymetal
Niobium's
Easymetal
Niobium's

Re: detecting metal spots
Posted: 16 May 2011, 05:47
by Forboding Angel
Cheesecan wrote:Niobium wrote:FLOZi wrote:easymetal algorithm gets my vote.
Speed test on Dworld_V1:
Easymetal: 4.828 seconds
Niobiums: 0.131 seconds
Speed test on SpeedBall_10x10:
Easymetal: 13.441 seconds
Niobiums: 0.017 seconds
Lol pwned.
NOU.
And that, ladies and gentlemen, is why easymetal reigns supreme. Hurrah!
Re: detecting metal spots
Posted: 16 May 2011, 17:40
by knorke
they have different goals.
Re: detecting metal spots
Posted: 16 May 2011, 17:45
by SinbadEV
Obviously I'm not anything like a map lua coder but... couldn't you include both (or more) algorithms... make some kind of cursory analysis of the metal map (including extractor radius... one would assume a tiny extractor radius implies a ota style metal placement strategy) and then run the appropriate algorithm?
edit: Categories of metal placement
Core Prime (whole map is metal)
TotalA (metal spots smaller then the extractor radius)
Clouds (metal spots larger then the extractor radius or spread out and diffuse metal)
Jerk (metal map intentionally designed to screw up metal placement algorithms)
Re: detecting metal spots
Posted: 16 May 2011, 18:13
by CarRepairer
knorke wrote:they have different goals.
Yes. My silly algo is years old, sat in ca's repo unloved and unused. Its original purpose was not to find places to put your mexes, but to replace the whole metalmap concept and work with all exisiting spring maps. It's indeed slow and if you don't care about the 3% of maps with stupid metal, use Nio's code by all means. I hate those maps anyway.