ai_helper.find_best_move: return nil instead of {} if no move found
This is done for consistency with similar functions in mainline. In principle this breaks backward compatibility. However, while it is theoretically possible for this to happen, this function will generally always return at least the hex the unit is on, so it is very unlikely that this actually makes a difference somewhere.
This commit is contained in:
parent
41bd835f76
commit
cd8af96607
1 changed files with 2 additions and 4 deletions
|
@ -1416,16 +1416,14 @@ function ai_helper.find_best_move(units, rating_function, cfg)
|
|||
-- best_hex: format { x, y }
|
||||
-- best_unit: unit for which this rating function produced the maximum value
|
||||
-- max_rating: the rating found for this hex/unit combination
|
||||
-- If no valid moves were found, best_unit and best_hex are empty arrays
|
||||
|
||||
-- TODO: change return value to nil if no unit/hex is found later in 1.13., but keep as is in 1.12
|
||||
-- If no valid moves were found, best_unit and best_hex are nil
|
||||
|
||||
cfg = cfg or {}
|
||||
|
||||
-- If this is an individual unit, turn it into an array
|
||||
if units.hitpoints then units = { units } end
|
||||
|
||||
local max_rating, best_hex, best_unit = - math.huge, {}, {}
|
||||
local max_rating, best_hex, best_unit = - math.huge
|
||||
for _,unit in ipairs(units) do
|
||||
-- Hexes each unit can reach
|
||||
local reach_map = ai_helper.get_reachable_unocc(unit, cfg)
|
||||
|
|
Loading…
Add table
Reference in a new issue