15 January 2009

Houston, we have a problem

[This is something of a failed post - a cool idea that was too complex for a simple demonstration, and a false start on the correct solution. I've been sitting on it for almost two weeks now and haven't had time to rework it. I'll post it anyway, and maybe someone can help me fix it.]

Having discussed a simple graph paper race game, and mentioning that it would be fairly easy to turn it into a "space race" sort of game, I set out to do so. Further, I'm writing this as I'm working out how the game works in an Excel spreadsheet (does this count as live blogging?). Here is my progress so far (This may be a bit cryptic, but this is also a test for me to see if I can convey these sorts of ideas to my readers via a spreadsheet, without going into painstaking detail. Question? Please ask, and I'll try to do better.):
The green shaded cells on row 2 (turn 0) allow you to enter starting conditions for the game. The first six values are ddX/ddY, dX/dY , X/Y are for acceleration, starting vector, and starting position (all initially zero). The next six are "goal" parameters, X-Y coordinates that define the "race course" for this game, here the point (5,10), (10,5), and (15,15). The "ship" must pass within a distance of one from each of these points to successfully complete the course, which is indicate here by the first three gold shaded cells, which are "1" is the goal has been acheived and "0" otherwise. The final gold shaded cell is the number of turns needed to acheive the third and final goal.
In the green shaded columns ddX/ddY I have entered a starting condition, a series of moves that acheive each of the three goals. You can see it tool my ship 14 turns to reach the 3rd goal, and I'd like to do better. Tinkering with this by hand I could probably come up with a good solution, but I want to do this another way. Excel has an "Add-in" tool which used Newton's Method to find the solutions to mathematical formulations that meet certain criteria. This is why I set the goals in the spreadsheet, so I could use the goal to allow the Solver to help me find the best solution. So now I use Tools --> Solver ... and discovered I left something out. I need to be able to limit the thrust (ddX/ddY) to a maximum of one. I'll add this in, but it's now going to turn out a little differently than I expected. Here is the new starting solution: And now I can use the solver ... ok ... more problems ... try to imagine me banging my head on the keyboard ...
... banging my head because the solver fails and goes off to a nonsense solution, ignoring the course after the first goal. This problem trickier than I had realized, and so I have not set it up in a way that Newton's method can find the best answer, or even any answer at all.

Uncle - I give up - for now at least. I do not mind that this problem escapes me for the moment, because I had fun trying. I have a good idea of what I did wrong, so I'll think on it and try again later.

Here is the spreadsheet if you want to try it yourself.

[Epilogue]
Since I wrote that a few evenings weeks ago I came back and made another effort. It turns out my goals were a really bad way to formulate the problem. I made some marginal improvements, but nothing really worth showing off. I've made this work before, and the method deserve a better demonstration that I've given it here.
Post a Comment