Long before I was learning physics, I was doing programming! My first foray into the coding universe was when I picked up Microsoft Small Basic when I was around 7. The precise details of how I chanced upon it currently elude me, but I was really into mathematics at that time, and so I viewed programming as both a recreational offshoot and a (perhaps lucrative) opportunity to make video games. My very first program was a math quiz, and I have vivid memories of discovering what a for loop was shortly after working out how long it would take me to copy-paste and edit 200,000 lines of if-statements.
Later on I was taught C, at age 9, and then I self-learnt Java by reading the two volumes in the Core Java series by Cay Horstmann and Gary Cornell (the second edition, printed circa 2000!). Learning programming languages became something of a pastime after that, and I am now also conversant in C++, Rust, and - despite the repeated insistence of my younger self that it was not a “real” language - Python (spoiler alert: I love it now). For a long period, I was intent on becoming a game developer, and so I have many game projects in Unity strewn around too. I also enjoy app development, particularly in Flutter.
My favourite extended projects that I’ve undertaken include a chess engine, a physics engine and a machine learning library, all of which have undergone substantial rewrites and transcriptions into multiple languages. Some other smaller highlights include an editor and simulator for Conway’s Game of Life (discrete and smooth versions!), an FFT-based noise reducer, quantum chemistry calculations of observables in helium, a quantum tunnelling simulation, a ray tracer, and an ASCII art generator. I’m looking to expand my repertoire in hardcore scientific programming, as I sense it’ll be very handy in the future.
-
How to Build your own Chess Engine! (Data Structures) 08 Jun 2022
Representing the Board State
Before commencing with an algorithm, we need to settle on our data structures - in particular, how do we represent the state of the chess board? An obvious method, particularly if you’re an OOP fiend, would be to use an array of Piece objects, with each piece type (knight, bishop, etc.) a class inheriting from Piece. If that’s what you thought of, discard it immediately! For extremely time-sensitive applications, you’ll find...
-
2D Physics Engine Demos 02 Jul 2021
As you might know, I’ve made a constraint-based 2D physics engine in Python. Here it is on GitHub: https://github.com/nkarve/shard. On this page I’ll be adding some recordings I made of different scenes running the physics engine.
-
How to Make a 2D Physics Engine - Collisions 02 Jul 2021
In the previous post, I showed how enforcing $\mathbf{Jv}=0$ imposes one or more constraints. If you have gone ahead and implemented this, you will notice that the system often collapses (especially when gravity is involved) - once the constraint is slightly violated, it never recovers, and the associated rigidbodies plummet down. However, consider what would happen if we were to add in a “bias” term (should be familiar to anyone who’s tried their hand at...
-
Why I Chose Flutter 02 Jul 2021
Flutter, developed by Google, is a (relatively) recent entrant to the mobile app development scene, where it competes with the likes of React Native to deliver a framework for frontend UI development and smooth backend integration.
Since I haven’t personally used React Native all that much, I will primarily focus on the elements of Flutter that I enjoyed, rather than stage a boxing match between the two. A bit of a backstory first: I originally...
-
How to Make a 2D Physics Engine - Constraints 01 Jul 2021
For reasons of stability and accuracy, we typically work with velocity-based constraints to introduce interesting features into our physics engine, like joints and collisions. This approach outstrips its peers, since:
Acceleration-based updates lead to extreme instabilities as the accumulated acceleration can go to infinity Position-based updates either look jittery or unrealistic (“hugging”), without a good balance in between. You can’t even implement friction at a velocity level.
These constraints are well-defined, and are essentially 100%...
-
How to Make a 2D Physics Engine (Collider + Rigidbody) 30 Jun 2021
Welcome. In this post, I’ll be describing my implementation of the collider and rigidbody classes. If these terms are unfamiliar, I recommend you take a quick look at my previous post, where I provide an overview of the various components of a physics engine. To summarise: a rigidbody stores the physics properties of the GameObject, while the collider stores its shape and material properties. Although (or perhaps because) these two classes form the core of...
-
How to Make a 2D Physics Engine (Overview) 29 Jun 2021
What is a Physics Engine?
It’s simply a framework that allows you to simulate the effects of physics on objects. The physics engine on its own merely performs computations on vectors, so it is typically accompanied by a graphics or render engine, with which it runs in tandem. The level of realism achieved by the physics engine varies greatly depending on the requirements, with real-time game physics engines sacrificing pinpoint accuracy to preserve FPS and...
-
How to Build your own Chess Engine! (Overview) 11 Mar 2021
Today I’m going to talk about one of my favourite hobbies: chess engines. There’s nothing like seeing an engine that you’ve made rise up in ELO until it’s finally able to beat you. It’s also, as I’ve found, incredibly addictive - you won’t be able to stop searching for small tweaks and optimisations to speed up and strengthen it! As some background, I made my first chess engine in Java around 3 years ago. It...
-
Introducing Mentr 18 Nov 2020
I’ve been working on this app - it’s called Mentr, and it’s designed to connect mentees with mentors (teachers, parents, alumni, even seniors) in school, replacing what used to be a cumbersome (and virtually non-existent) process. I used Google’s cross-platform Flutter toolkit (Android Studio is a hulking mess) along with Firebase, which, of course, integrates really well considering they’re both Google products. Although it’s not fully functional yet (quite a few features are mock-ups), I...
-
Convolutions in 4D 07 Jul 2020
I wanted to see a 4-D convolutional layer. I was tired of sifting through the Tensorflow source code on Github only to find layers upon layers (pun intended) of what seemed like circular references. After hours of arduous searching (okay, maybe not) I thought I’d hit the jackpot, but through the mist, all I saw was an arcane cuDNN call rearing its ugly head. :(
Of course, the Internet is absolutely littered with 1-D and...