mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
STRATEGO
* functional additions
This commit is contained in:
parent
58f4eead1c
commit
d2b7d46227
@ -222,6 +222,7 @@ STRATEGO = {
|
|||||||
-- @field #number points
|
-- @field #number points
|
||||||
-- @field #number coalition
|
-- @field #number coalition
|
||||||
-- @field #string coalitionname
|
-- @field #string coalitionname
|
||||||
|
-- @field Core.Point#COORDINATRE coordinate
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @type STRATEGO.Type
|
-- @type STRATEGO.Type
|
||||||
@ -703,14 +704,21 @@ end
|
|||||||
|
|
||||||
--- [USER] Get a list of the nodes with the highest weight.
|
--- [USER] Get a list of the nodes with the highest weight.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
|
-- @param #number Coalition (Optional) Find for this coalition only. E.g. coalition.side.BLUE.
|
||||||
-- @return #table Table of nodes.
|
-- @return #table Table of nodes.
|
||||||
-- @return #number Weight The consolidated weight associated with the nodes.
|
-- @return #number Weight The consolidated weight associated with the nodes.
|
||||||
function STRATEGO:GetHighestWeightNodes()
|
function STRATEGO:GetHighestWeightNodes(Coalition)
|
||||||
self:T(self.lid.."GetHighestWeightNodes")
|
self:T(self.lid.."GetHighestWeightNodes")
|
||||||
local weight = 0
|
local weight = 0
|
||||||
local airbases = {}
|
local airbases = {}
|
||||||
for _name,_data in pairs(self.airbasetable) do
|
for _name,_data in pairs(self.airbasetable) do
|
||||||
if _data.weight >= weight then
|
local okay = true
|
||||||
|
if Coalition then
|
||||||
|
if _data.coalition ~= Coalition then
|
||||||
|
okay = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if _data.weight >= weight and okay then
|
||||||
weight = _data.weight
|
weight = _data.weight
|
||||||
if not airbases[weight] then airbases[weight]={} end
|
if not airbases[weight] then airbases[weight]={} end
|
||||||
table.insert(airbases[weight],_name)
|
table.insert(airbases[weight],_name)
|
||||||
@ -719,16 +727,24 @@ function STRATEGO:GetHighestWeightNodes()
|
|||||||
return airbases[weight],weight
|
return airbases[weight],weight
|
||||||
end
|
end
|
||||||
|
|
||||||
--- [USER] Get a list of the nodes a weight less than the give parameter.
|
--- [USER] Get a list of the nodes a weight less than the given parameter.
|
||||||
-- @param #STRATEGO self
|
-- @param #STRATEGO self
|
||||||
|
-- @param #number Weight Weight - nodes need to have less than this weight.
|
||||||
|
-- @param #number Coalition (Optional) Find for this coalition only. E.g. coalition.side.BLUE.
|
||||||
-- @return #table Table of nodes.
|
-- @return #table Table of nodes.
|
||||||
-- @return #number Weight The consolidated weight associated with the nodes.
|
-- @return #number Weight The consolidated weight associated with the nodes.
|
||||||
function STRATEGO:GetNextHighestWeightNodes(Weight)
|
function STRATEGO:GetNextHighestWeightNodes(Weight, Coalition)
|
||||||
self:T(self.lid.."GetNextHighestWeightNodes")
|
self:T(self.lid.."GetNextHighestWeightNodes")
|
||||||
local weight = 0
|
local weight = 0
|
||||||
local airbases = {}
|
local airbases = {}
|
||||||
for _name,_data in pairs(self.airbasetable) do
|
for _name,_data in pairs(self.airbasetable) do
|
||||||
if _data.weight >= weight and _data.weight < Weight then
|
local okay = true
|
||||||
|
if Coalition then
|
||||||
|
if _data.coalition ~= Coalition then
|
||||||
|
okay = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if _data.weight >= weight and _data.weight < Weight and okay then
|
||||||
weight = _data.weight
|
weight = _data.weight
|
||||||
if not airbases[weight] then airbases[weight]={} end
|
if not airbases[weight] then airbases[weight]={} end
|
||||||
table.insert(airbases[weight],_name)
|
table.insert(airbases[weight],_name)
|
||||||
@ -985,7 +1001,9 @@ function STRATEGO:FindStrategicTargets()
|
|||||||
name = name,
|
name = name,
|
||||||
dist = dist,
|
dist = dist,
|
||||||
points = fpoints,
|
points = fpoints,
|
||||||
coalition = coa,
|
coalition = coa,
|
||||||
|
coalitionname = UTILS.GetCoalitionName(coa),
|
||||||
|
coordinate = self.airbasetable[name].coord,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local enemycoa = self.coalition == coalition.side.BLUE and coalition.side.RED or coalition.side.BLUE
|
local enemycoa = self.coalition == coalition.side.BLUE and coalition.side.RED or coalition.side.BLUE
|
||||||
@ -1000,7 +1018,9 @@ function STRATEGO:FindStrategicTargets()
|
|||||||
name = name,
|
name = name,
|
||||||
dist = dist,
|
dist = dist,
|
||||||
points = fpoints,
|
points = fpoints,
|
||||||
coalition = coa,
|
coalition = coa,
|
||||||
|
coalitionname = UTILS.GetCoalitionName(coa),
|
||||||
|
coordinate = self.airbasetable[name].coord,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1031,6 +1051,7 @@ function STRATEGO:FindConsolidationTargets()
|
|||||||
points = fpoints,
|
points = fpoints,
|
||||||
coalition = coa,
|
coalition = coa,
|
||||||
coalitionname = UTILS.GetCoalitionName(coa),
|
coalitionname = UTILS.GetCoalitionName(coa),
|
||||||
|
coordinate = self.airbasetable[name].coord,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local enemycoa = self.coalition == coalition.side.BLUE and coalition.side.RED or coalition.side.BLUE
|
local enemycoa = self.coalition == coalition.side.BLUE and coalition.side.RED or coalition.side.BLUE
|
||||||
@ -1046,7 +1067,8 @@ function STRATEGO:FindConsolidationTargets()
|
|||||||
dist = dist,
|
dist = dist,
|
||||||
points = fpoints,
|
points = fpoints,
|
||||||
coalition = coa,
|
coalition = coa,
|
||||||
coalitionname = UTILS.GetCoalitionName(coa),
|
coalitionname = UTILS.GetCoalitionName(coa),
|
||||||
|
coordinate = self.airbasetable[name].coord,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1060,10 +1082,14 @@ end
|
|||||||
-- @param #boolean Enemies (optional) If true, find only enemy neighbors.
|
-- @param #boolean Enemies (optional) If true, find only enemy neighbors.
|
||||||
-- @param #boolean Friends (optional) If true, find only friendly or neutral neighbors.
|
-- @param #boolean Friends (optional) If true, find only friendly or neutral neighbors.
|
||||||
-- @return #table Neighbors Table of #STRATEGO.DistData entries indexed by neighbor node names.
|
-- @return #table Neighbors Table of #STRATEGO.DistData entries indexed by neighbor node names.
|
||||||
|
-- @return #string Nearest Name of the nearest node.
|
||||||
|
-- @return #number Distance Distance of the nearest node.
|
||||||
function STRATEGO:FindNeighborNodes(Name,Enemies,Friends)
|
function STRATEGO:FindNeighborNodes(Name,Enemies,Friends)
|
||||||
self:T(self.lid.."FindNeighborNodes")
|
self:T(self.lid.."FindNeighborNodes")
|
||||||
local neighbors = {}
|
local neighbors = {}
|
||||||
local name = string.gsub(Name,"[%p%s]",".")
|
local name = string.gsub(Name,"[%p%s]",".")
|
||||||
|
local shortestdist = 1000*1000
|
||||||
|
local nearest = nil
|
||||||
for _route,_data in pairs(self.disttable) do
|
for _route,_data in pairs(self.disttable) do
|
||||||
if string.find(_route,name,1,true) then
|
if string.find(_route,name,1,true) then
|
||||||
local dist = self.disttable[_route] -- #STRATEGO.DistData
|
local dist = self.disttable[_route] -- #STRATEGO.DistData
|
||||||
@ -1082,9 +1108,13 @@ function STRATEGO:FindNeighborNodes(Name,Enemies,Friends)
|
|||||||
else
|
else
|
||||||
neighbors[cname] = dist
|
neighbors[cname] = dist
|
||||||
end
|
end
|
||||||
|
if neighbors[cname] and dist.dist < shortestdist then
|
||||||
|
shortestdist = dist.dist
|
||||||
|
nearest = cname
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return neighbors
|
return neighbors, nearest, shortestdist
|
||||||
end
|
end
|
||||||
|
|
||||||
--- [USER] Find a route between two nodes.
|
--- [USER] Find a route between two nodes.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user