Commit ea527b5d authored by Hubert Denkmair's avatar Hubert Denkmair
Browse files

sort return values of apiFindFood and apiFindSegments

parent d2845f70
......@@ -199,6 +199,12 @@ std::vector<LuaFoodInfo>& LuaBot::apiFindFood(real_t radius, real_t min_size)
}
}
std::sort(
m_luaFoodInfoTable.begin(),
m_luaFoodInfoTable.end(),
[](const LuaFoodInfo& a, const LuaFoodInfo& b) { return a.v > b.v; }
);
return m_luaFoodInfoTable;
}
......@@ -227,12 +233,18 @@ std::vector<LuaSegmentInfo>& LuaBot::apiFindSegments(real_t radius, bool include
segmentInfo.bot.get(),
relPos.x(),
relPos.y(),
segmentInfo.bot->getSnake()->getSegmentRadius(),
segmentRadius,
direction,
distance
);
}
std::sort(
m_luaSegmentInfoTable.begin(),
m_luaSegmentInfoTable.end(),
[](const LuaSegmentInfo& a, const LuaSegmentInfo& b) { return a.dist < b.dist; }
);
return m_luaSegmentInfoTable;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment