Package: tank-wars-iit
Robot WarsEngine for the Robot Wars hack night.RequirementsPython 3.10pygame 2.3.0 (SDL 2.24.2, Python 3.10.2)How do I run it?Runinit.pyin Python. (This is a testing script and will be changed/moved in the future.)Structureengine- Package containing full Robot Wars engine.entity- Package containing allEntityclasses supported by the engine.bullet.py- Contains theBulletclass (inheritsEntity); represents a bullet that moves in the direction it faces, bounces off walls, and collides withRobots.entity.py- Contains theEntityabstract class, which represents a geometric object in anArena.robot.py- Contains theRobotclass (inheritsEntity); represents a robot that can move, turn, turn its turret, and shootBullets.wall.py- Contains theWallclass (inheritsEntity); represents a static, unmovable barrier.maps- Directory containing map JSON files which can be used to easily instantiate anArenawithWalls and spawn locations.basic.json- A small, wide map with fiveWalls and two spawns.circles.json- A medium, square map with two concentric circles ofWalls and four spawns.stress_test.json- A large, square map with noWalls and 64 spawns, meant for stress testing the engine.util- Package containing engine utility modules.draw.py- Contains helper functions for drawing gradients on screen.geometry.py- Contains helper functions for collision detection between two convex polygons.arena.py- Contains theArenaclass, which represents a battle arena for one or moreRobots.map.py- Contains type definitions and guards for the map JSON format.quadtree.py- Contains theQuadtreeclass, which is a data structure used to optimize collision filtering.tools- Useful scripts to automate workflows.generate_circles.py- Generates theengine/maps/circles.jsonmap.generate_stress_test.py- Generates theengine/maps/stress_test.jsonmap.init.py- Loads anArenafrom a map, spawns a user-controlledRobotand several NPCRobots, and runs the simulation with visuals. Used for testing.To DoMap Creation[IMPLEMENTED]1v1 Map- For now, we can useengine/maps/circles.json.Battle Royale Map- Extra-large map with adequateWalls spread across the map.Zoom-In- Useful for observing the battle royale map!Optimization[IMPLEMENTED]Quadtree Collision Filtering- Use aQuadtreedata structure to filter which collisions to check for as opposed to checking every pair ofEntitys.ParallelizeEntity.update- Invoke all calls ofEntity.updatein parallel since they operate mostly independently (exception is modification of sharedArenastate, like spawningBullets viaRobot.shoot).ParallelizeEntity.handle_collision- Invoke all calls ofEntity.handle_collisionin parallel; modify the method to return newpositionandrotationproperties that will be applied in parallel.Game Rules[IMPLEMENTED]RobotDestruction- Incorporate health inRobotand damage inBullet.Win Condition- Destroy the otherRobot.Stalemate Condition- BothRobots are still alive afternseconds of simulation.[IMPLEMENTED]Coins- PlaceCoinentities around theArena; whicheverRobotcollects the most wins in case of stalemate.RobotProgrammability[IMPLEMENTED]RobotManipulation- Expose API to move and turn theRobotand shootBullets.[IMPLEMENTED]EnemyRobotDetection- Expose API to find the nearestRobotto a givenRobot.[IMPLEMENTED]Pathfinding- Expose API forRobots to navigate their way to a location aroundWalls.RobotControlClass- Incorporate all programmable/personalizableRobotfeatures into one class which each team extends with their implementation. For now, it's semi-implemented as theRobot.on_updatecallback, which is unideal because it doesn't secure the engine from unwanted modifications.Engine Encapsulation- Prevent raw access to anyEntitys or theArena; the only accessible component is theRobotControlclass.RobotPersonalization[IMPLEMENTED]Color- SetRobotcolors via propertiescolorandhead_color.Size- SetRobotsize; larger size increases health and decreases speed.RobotExamplesUnit TestsPrepare for Distribution