Inspiration
This project was inspired by the mathematics department challenge.
What it does
Billiard Wizard is a general-purpose billiard simulator. It can take an arbitrary number of billiard balls, with initial positions and velocities, and simulate their evolution over time in an arbitrary nested polygonal enclosure, which allows for complex geometries (see Photos). It is accompanied by a powerful GUI that allows the user to easily create these polygonal geometries. The simulator is also capable of modeling elastic collisions between the billiard balls and applying basic models of friction and inelastic collision. Finally, it provides basic diagnostics like the number of collisions and the position of the centre of mass over time.
How we built it
We built Billiard Wizard in pure Python, with numpy and matplotlib, and without the use of artificial intelligence as per the challenge guidelines. Instead of looping through the balls, we make use of numpy’s powerful array operations to vectorise these computations, thus potentially gaining a large speedup over the naïve sequential algorithm. The display and interface is built with matplotlib, whose surprisingly powerful tools allows us to go beyond graphing and display large numbers of billiard balls, with accompanying velocity vectors. The polygon generator, since it is only an auxiliary input to the billiard simulator itself, is written in pygame.
Challenges we ran into
The main challenge we ran into was how hard this program was to debug. It contains a lot of math & formulae and not much easily interpretable internal state and so a single flipped sign could require hours of poring over frame-by-frame strings of arbitrary numbers to find. Another problem was getting used to that incredibly powerful but quite daunting API of numpy, which none of us had extensively used before.
Accomplishments that we're proud of
We’re most proud of all the solutions we developed on our own to the problems we faced while developing Billiard Wizard. At many moments, we were forced to pause to determine how to determine a crucial piece of information, work it out on paper and then translate that into code. It was a very challenging but ultimately very rewarding experience. We’re very proud of having been able to think creatively during the creation of this project.
What we learned
As mentioned earlier, we learned how to numpy and about some basic concepts in linear algebra, both necessary to solve this problem. However, we also learned valuable skills regarding how to break complex problems down into manageable pieces and solve seemingly difficult problems that we initially didn’t know how to go about
What's next for Billiard Wizard
The first step is to fix up some of the remaining bugs and rough ends in the program, such as the billiards being able to escape the enclosure at oblique angles. The next step would be to add some more interesting features that would be of interest to mathematicians, such as fixed-point detection, long-range forces between the billiard balls, more diagnostics and statistics about the behaviour of the balls throughout the simulation, etc. A final thought we had during our initial brainstorm phase and that we would like to someday implement is a quantum analogue to a classical billiard simulator. Instead of discrete billiard balls bouncing around an enclosure, they would be a set of wavefunctions evolving and interfering with each other. The simulator would use a numerical integration technique to solve Schrodinger’s equation on a discrete grid and the visualizer would demonstrate the probability density in each region over time.
Log in or sign up for Devpost to join the conversation.