Bishopviz
- 4 Devlogs
- 8 Total hours
Drunken bishop algorithm implementation with data visualization and other things.
Drunken bishop algorithm implementation with data visualization and other things.
I’ve recorded a demo, published it on BOTH Streamlit and Pypi, fixed any bugs, and added a file input option. I think I’m ready to ship.
I think I’m done with the data part. Lowk, it looked better in my head, but this was more of a practice in Streamlit and plotly than actual data analysis. I wanted to make it so that there was just an option in the CLI and then users could put it to start the server and visualize the data they just put the option. Unfortunately, due to the way Streamlit works, I just made it a separate app. This way users can launch the command from the cli and it can also be deployed as a standalone app.
I’ve got a lot of the cosmetic stuff done.
I moved the algorithm into its own class, which overall made it easier to track certain variables like its position. For the animate option (next paragraph) I had to make a move function that ran 1 generation of the algorithm, so that I could print between frames.
I made an animate option that takes in an amount of seconds and then displays an animation as the bishop moves. The only complicated part about this is that it uses an escape code to move the cursor back up, so as to give the illusion that the same printed text is moving.
I made a character set option and then got ChatGPT to generate some character sets. These follow the convention set by the actual algorithm, in which it’s just 17 characters, with 0 being empty, 15 being the start, and 16 being the ending position. I also added a bishop key so that during the animation it would show where the bishop was. To accomodate the Katakana and emoji options (I didn’t show Katakana but the emojis do show it), I had to modify the draw function to double the width of the graph. It’s still 17, just getting printed as 34 or so.
I got colors too. I just made the same dictionary as a character set but with the color names (I’m using click for the CLI, and it has an API for coloring text) as the values. I then modified the draw function to use the value of the dictionary at the key corresponding to the tile as the foreground if the colorize option was enabled.
Overall, the project has turned out pretty nice, and I will be working on the data visualization part next!
I got the algorithm working, so that’s pretty much half the project done. I wrote the draw function with a character set argument, so that it is possible in the future to change what characters it uses.