This project is work-in-progress. This readme file will be updated once the project is done... unless I forget.
TODO:
- fix collision logic. They still aren't taking the minimum turn angle to avoid the borders
- make them not go into a death loop. Would better collisions with the borders help with this?
- make consts for defining the color of everything
- reduce max allowed velocity the greater the angular velocity is
- (actually this might not be worth it. Only do it if you find a solution quickly) find 1D noise function for gradual turning instead of using 2D noise which is more expensive
- make collission logic. This might actually be pretty easy! When resolving a collission you of course want it to go in the direction that requires it to turn as little as possible, and not turn 180 degrees or something. Although sounding a bit scuffed, a way to do this would be to when it detects a collission, go back one step, rotate it to the left 5 degrees, and walk forward. If it still collides, to the same but on the right. If it still collides, then repeat this again but with 10 degrees, then 15, then 20, etc (might want smaller or bigger angle gaps). It will thus turn the way that requires the least amount of turning, without having to do any surface normal calculations or anything like that! Also, note that if the actual check for if a collission is happening gets too expensive with having to check all the rectangle geometry objects, then you could try instead making it save a lower resolution 2D grid of what positions are and aren't colliding, where if an ant has to check for a collission it can just index that 2D array and see if that spot is blocked or not. Actually, a potentially better way that uses way less memory (and might also be more efficient, as you still need to update thousands of points whenever the map changes, unless you can dynamically update certain parts) is to divide the map into a grid, where when a rectangle spawns it keeps track of what new cells it grows into, and when it shrinks it keeps track of what cells it goes away from. Each cell should have an array for what rectangles are in that region, and when collission checks happen, it should see what cell the collission coordinate is in, then loop through only the rectangles in that specific cell. After implementing collission detection you can now also add better logic for when the ants try to move offscreen, as right now the code you have for it is pretty jank
- make randomly rotated beams able to spawn, where they spawn by slowly increasing in length, and then despawn by slowly decreasing in length. The slowness is to make it less sudden when viewing the simulation, and also to reduce the chances that any ants get stuck in the growing collission
- at the end of the project, make the amount of ants spawned, and other parameters that decide how the simulation works, specified as parameters when running the command for starting the program in the terminal. The zoom level of the camera and resolution of the actual window definitely needs to be a parameter. It would for other screen resolutions make sense that there is one for the map's size and stuff, but that might require a lot of refactoring of the code and stuff, and it's not like you are planning to get a non 16:9 monitor any time soon (sorry if the 0.01% chance occurred where someone actually found this project and are interested in it who has a weird screen)