jdno / auto-traffic-control

A video game for programmers about safely routing planes to an airport πŸ›¬
https://auto-traffic-control.com
Apache License 2.0
134 stars 9 forks source link

Make the game easier to debug #177

Open izidormatusov opened 2 years ago

izidormatusov commented 2 years ago

I love the idea of the game and having fun implementing my solution.

However, my current solution has a bug in it as two planes crashed into each other:

Screenshot 2022-08-21 at 10 27 45

How does one go about debugging this? It is impossible to know what were the plane ids or what wast their flight plan. I would have to go over the logs of my solution and try to painfully reconstruct the state in order to find where my solution made an error. It is feasible for somebody who has a lot of experience doing that but it is no fun 😞

At the moment UI window just shows the current state. It could be extended to show information like:

The information could be displayed always or only on hovering over the plane. Few mockups:

Screenshot 2022-08-21 at 10 51 58

Screenshot 2022-08-21 at 10 54 14

When the game stops, it would be useful to play with the game and debug it: Be able to rewind the game and see how the planes were moving around. You could inspect planes (their ids and the flight plan at the given time) and see when the flight plan changes were issued.

These changes would make it much easier to debug. The player can focus more time into writing algorithms rather than debugging / building their own debugging tools.

jdno commented 2 years ago

The API includes the ids of the airplanes in the GameCollided event:

message AirplaneCollided {
  string id1 = 1;
  string id2 = 2;
}

But I fully agree that the observability of the game is not great right now. Rendering the names and flight plans is something I've considered as well, as is highlighting the planes that crashed by drawing a circle around them or so. This shouldn't be too complicated to implemented.

Replays would be great to have as well, but I honestly don't know how much work they would be to implement. If it's too complicated to do in the engine, maybe we can just record a video or so.

(Just fyi, this game is my attempt to get into game development. So I'm sadly not experienced enough to hammer out a feature like this in a weekend. πŸ˜¬πŸ˜…)

noahc commented 2 years ago

One way to start would be to have a logger toggle that logged to a log file everything needed to play back the game. The log by it self would be valuable, but you could at a later stage, take old log files or new ones and play back the game for debugging purposes.