- Get the newest data from the Concept 2
- Update the AI boats
- Visualize the latest available data
Let’s just jump into these steps to get an overview:
Get data from the Concept 2: This is where PyRow is used. I created a static class called ErgStats which wraps around the PyRow-API. This way I’m not depending on PyRow everywhere in my application and I can easily swap it out if needed. A more object oriented way would be to create some sort of dependency injection here, that way I could more easily switch between generating test data and using the real data. Currently I implemented a quick hack where I used a try/catch when importing PyRow. If it fails to import I fall back to test data.
Update the AI: I created a PlayGround-class which holds a list of all the boats in the simulation. All boats get updated every cycle. The current logic implementation allows it to have different types of boats available, I just implemented a constant rowing boat and a very simple rubberband boat for now, but there’s potential to have more complex boats integrated.
Visualize everything: At first I used the TKInter Canvas because I wanted to use as less thirdparty software as possible. Python brings lot’s of stuff, so I thought it isn’t really needed to integrate more stuff from external repositories. My targeted hardware specification caused me to rethink this approach: I want DynRow to run on very basic hardware, at best it could be used on something simple like a Raspberry Pi. TKInter.Canvas, or at least the way I used it, is not very performant. After struggling a bit I added PyGame to the mix, which also provides some easy to use Gameloop-mechanics. My current implementation isn’t as optimized as it could be, but I’m quite happy with the resulting look and performance.
That’s almost everything you need to know. I wanted to keep the program as simple as possible, my primary focus was on creating a usable prototype as early as possible.