hermanschaaf
Joined 14 years ago
Joined 14 years ago
In the game, some of the elevators are automated, and I wanted to choose an algorithm that best aligned with what players would expect an elevator to do. I ended up going with something close to LOOK, which (as the article states) is mostly what people expect. Except in case of ambiguity, I had it prioritise floors that have been waiting longer, to improve the p90, which is important in the game.
But now, add in these challenges:
- double-deck cabs (where attached cabs cover two floors at once)
- transfer floors between shafts
- express shafts
and the best (or at least, most expected) algorithm becomes much less obvious! I'll leave it as an exercise for the reader to figure out the best one.
Luckily I was in charge of a game, not a real elevator system, so I just had to find a heuristic that was good-enough, and could tweak the rules to let players manually override the elevator's plan if they don't like where it's going. This seems to have satisfied most players.
Could you share a comparison with the other tools out there?
I had a question: how much time do you typically spend on this activity in a day? Do you have tips for how to adjust based on the time you have available?
Q: Given V (the number of vertices), E (the number of edges) and L (a list of the edges) for a connected undirected graph, determine whether the graph is a tree.
----
A: It can be done in O(1) by: return V == E + 1
The number of vertices in a tree is always one more than the number of edges. We also know that the graph is connected, so it has to be a tree.