Coding battle at Take Eat Easy
After this intro, Jean-Christophe Libbrecht presented what Take Eat Easy is in simple words: delivery on time. The technical challenge was presented with focus on the same company values: optimal delivery management. I gotta say that I had a flashback to my university discipline of operations research for a minute, when thinking about routes and shortest distance. Luckily, the challenge was easier to understand than the academic subject!
The overall atmosphere was agréable et la majorité parlèrent en français. Positive support and guidance was coming all the time.
Quoting an abstract from the problem definition:
You play one of TEE’s bike courier
Your goal is to make as much € as you can
You compete with other couriers in the city
So, participants had to program a courier bot, which plays with other courier bots in an imaginary city. Taking and delivering orders in an optimal way.
An example node client bot was given. I find it to be a good boilerplate for a start. Most importantly it’s clear where to include the custom logic and what are the tools to use to take actions.
Another positive prerequisite was the sample state object, which contained enough structure to understand the data that will be received by the client on every turn of the game. Note some important concepts are pretty obvious, I think: orders, possible actions and score.
All possible actions that the bots were able to play with: moving up/down/left/right, pick order, drop order. There were 2 advanced actions: upgrade fighter (be able to kick other players) and upgrade electric (move doubled).
I will repeat this again, I was content with the organizers. Help was kindly provided, with hints and advice all the way during the game. That made it fun to play. (No matter the fact that my team didn’t manage to get points :)
- Visualize the end result (expectation) before going in the code
We never ran the server “city” to see how our bot moves. That was not a clear problem until the end of the competition until when we were still working on the details on how to move our courier. Grep-ing the continuously changing state object helped us get some ideas about the dynamics, but honestly it was not easy to imagine how the courier bot is actually moving on the map without the real picture.
Now I believe it’s important to run the server (mock) locally during development just to understand and visualize the dynamics as they will be in the real game.
2. Learn and understand the start examples and code samples
In my first competition I made the mistake to try to understand the logic of the core engine (server) running the game, but this time was better focusing on the sample code. Yet, I think we missed useful points and functions that we could have utilized in our favor without thinking too much.
More specifically, the head of the function that was invoked in every turn of the game contained the following:
// Fetch my courier and possible order from the state
var state = data.state;
var possibleActions = data.possibleActions;
And guess what? That was prepared for us before-hand so that we could use these variables “as-is”. I have to say, I was mixing the `data` and `state` variables pretty much, but that’s another topic.
Another part of the code contained this line:
// Sample response.
`getDirection()` returns the best move depending on the current position and possible actions.
`respond()` is the function to invoke in order to take actions.
The respond() took us away, because we decided to focus on the actions, and somehow it was pretty late in the game when we figured the getDirection() function for possible re-use.
3. Strategy and task separation
Probably the most complex part of all.
Even though we didn’t have clear strategy while developing the bot, it surely would have helped. For example, we started implementing functions for the bonus skills like having an electric bike and kicking other players before deciding how to move and take orders :D
But seriously, possible strategy for this challenge could probably be to separate the approach in 2: functions for working with distance, and such for working with actions. Though we didn’t manage to have a complete combination of actions based on distance and value, we spoke about the fact that we were not clear about the order of combined actions we need to take. We took a delivery and then we were just standing at a place, since the next step was not foreseen. However, we prepared to be able to kick other players just standing there with our delivery in our hands! (we never got the points for the advanced action of kicking)
I feel that breaking down a challenge into small tasks plays an important role in problem solving, especially in short-time hack event. Also, event handling actions with state management seem to be recurring patterns, so it’s worth getting some more practice there too.
The next coding battle will be at Microsoft and the event is open for registrations. I’d recommend you to grab the opportunity to broaden your experience.
Lastly, consider inviting your colleagues to join you too. As you can imagine, the short hacking time will naturally give you ideas on how to communicate effectively with your colleagues when you work together in different environment. Also, you will see new ways to break down tasks and problem solve by observing and sharing with other developers you meet at the event.
What do you think?
I’m really interested to hear feedback on my thoughts and ideas about the code and the highlights. Maybe you have a different point of view? Share it in the comments!