Blizzard / s2client-api

StarCraft II Client - C++ library supported on Windows, Linux and Mac designed for building scripted bots and research using the SC2API.
MIT License
1.66k stars 281 forks source link

Make function robust to existing command structure #280

Open yanntm opened 6 years ago

yanntm commented 6 years ago

If there is already a building, or, e.g. creep in a location, the placement queries for a CommandCenter (line 19) will answer false. In the onStart method of a bot, it is likely that your own initial base is blocking at least one expansion location. This led to the algorithm returning points way off the map, or in e.g. (0,0). With this patch, we a posteriori edit the results of the query, so that an existing CC/Hatch/Nexus still counts as a good location to build in.

yanntm commented 6 years ago

The code is non intrusive w.r.t. to the existing code structure so I hope that helps the PR go through. The only thing I'm not really sure about is that 1.0f squared 2D distance, but obviously I don't want any == on floats. It worked in practice on ladder maps where the previous function had erroneous reporting.