title: How do I generate a waypoint map in a 2D platformer without expensive jump simulations?
body: <p>I'm working on a game (using Game Maker: Studio Professional v1.99.355) that needs to have both user-modifiable level geometry and AI pathfinding based on platformer physics. Because of this, I need a way to dynamically figure out which platforms can be reached from which other platforms in order to build a node graph I can feed to A*.</p>
  
  <p>My current approach is, more or less, this:</p>
  
  <ol>
  <li><p>For each platform consider each other platform in the level.</p></li>
  <li><p>For each of those platforms, if it is obviously unreachable (due to being higher than the maximum jump height, for example) do not form a link and move on to next platform.</p></li>
  <li><p>If a link seems possible, place an ai_character instance on the starting platform and (within the current step event) simulate a jump attempt.</p></li>
  </ol>
  
  <p>3.a Repeat this jump attempt for each possible starting position on the starting platform.</p>
  
  <ol start="4">
  <li><p>If this attempt is successful, record the data necessary to replicate it in real time and move on to the next platform.</p></li>
  <li><p>If not, do not form a link.</p></li>
  <li><p>Repeat for all platforms.</p></li>
  </ol>
  
  <p>This approach works, more or less, and produces a link structure that when visualised looks like this:</p>
  
  <p><a href="http://i.imgur.com/IjaqMko.png" rel="nofollow">linked platforms</a> (Hyperlink because no rep.)</p>
  
  <p>In this example the mostly-concealed pink ghost in the lower right corner is trying to reach the black and white box. The light blue rectangles are just there to highlight where recognised platforms are, the actual platforms are the rows of grey boxes. Link lines are green at the origin and red at the destination.</p>
  
  <p>The huge, glaring problem with this approach is that for a level of only 17 platforms (as shown above) it takes over a second to generate the node graph. The reason for this is obvious, the yellow text in the screen centre shows us how long it took to build the graph: over 24,000(!) simulated frames, each with attendant collision checks against every block - I literally just run the character's step event in a while loop so everything it would normally do to handle platformer movement in a frame it now does 24,000 times.</p>
  
  <p>This is, clearly, unacceptable. If it scales this badly at a mere 17 platforms then it'll be a joke at the hundreds I need to support. Heck, at this geometric time cost it might take years.</p>
  
  <p>In an effort to speed things up, I've focused on the other important debugging number, the tests counter: 239. If I simply tried every possible combination of starting and destination platforms, I would need to run 17 * 16 = 272 tests. By figuring out various ways to predict whether a jump is impossible I have managed to lower the number of expensive tests run by a whopping 33 (12%!). However the more exceptions and special cases I add to the code the more convinced I am that the actual problem is in the jump simulation code, which brings me at long last to my question:</p>
  
  <p>How would you determine, with complete reliability, whether it is possible for a character to jump from one platform to another, preferably without needing to simulate the whole jump?</p>
  
  <p>My specific platform physics:</p>
  
  <p>Jumps are fixed height, unless you hit a ceiling.</p>
  
  <p>Horizontal movement has no acceleration or inertia.</p>
  
  <p>Horizontal air control is allowed.</p>
  
  <p>Further info:
  I found <a href="https://vimeo.com/77361668" rel="nofollow">this video</a>, which describes a similar problem but which doesn't provide a good solution. This is literally the only resource I've found.</p>