Tank Wars framework for Scarlet HackNiite
Project description
Robot Wars
Engine for the Robot Wars hack night.
Requirements
- Python 3.10
- pygame 2.3.0 (SDL 2.24.2, Python 3.10.2)
How do I run it?
Run init.py in Python. (This is a testing script and will be changed/moved in the future.)
Structure
engine- 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 Do
- Map Creation
- [IMPLEMENTED] 1v1 Map - For now, we can use
engine/maps/circles.json. - Battle Royale Map - Extra-large map with adequate
Walls spread across the map. - Zoom-In - Useful for observing the battle royale map!
- [IMPLEMENTED] 1v1 Map - For now, we can use
- Optimization
- [IMPLEMENTED] Quadtree Collision Filtering - Use a
Quadtreedata structure to filter which collisions to check for as opposed to checking every pair ofEntitys. - Parallelize
Entity.update- Invoke all calls ofEntity.updatein parallel since they operate mostly independently (exception is modification of sharedArenastate, like spawningBullets viaRobot.shoot). - Parallelize
Entity.handle_collision- Invoke all calls ofEntity.handle_collisionin parallel; modify the method to return newpositionandrotationproperties that will be applied in parallel.
- [IMPLEMENTED] Quadtree Collision Filtering - Use a
- Game Rules
- [IMPLEMENTED]
RobotDestruction - Incorporate health inRobotand damage inBullet. - Win Condition - Destroy the other
Robot. - Stalemate Condition - Both
Robots are still alive after n seconds of simulation. - [IMPLEMENTED] Coins - Place
Coinentities around theArena; whicheverRobotcollects the most wins in case of stalemate.
- [IMPLEMENTED]
RobotProgrammability- [IMPLEMENTED]
RobotManipulation - Expose API to move and turn theRobotand shootBullets. - [IMPLEMENTED] Enemy
RobotDetection - Expose API to find the nearestRobotto a givenRobot. - [IMPLEMENTED] Pathfinding - Expose API for
Robots 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 any
Entitys or theArena; the only accessible component is theRobotControlclass.
- [IMPLEMENTED]
RobotPersonalization- [IMPLEMENTED] Color - Set
Robotcolors via propertiescolorandhead_color. - Size - Set
Robotsize; larger size increases health and decreases speed.
- [IMPLEMENTED] Color - Set
RobotExamples- Unit Tests
- Prepare for Distribution
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tank_wars_iit-1.0.2.tar.gz
(47.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tank_wars_iit-1.0.2.tar.gz.
File metadata
- Download URL: tank_wars_iit-1.0.2.tar.gz
- Upload date:
- Size: 47.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68e39093cfb0d7357be2cdf4b70121ddfc8814b82a02f3f83f133d9546c7e5ad
|
|
| MD5 |
802244e4493454082c93d7c64805291f
|
|
| BLAKE2b-256 |
eb2e02340167869cd6083c84addc444942f3be5df9b81b6641599906bc0c8441
|
File details
Details for the file tank_wars_iit-1.0.2-py3-none-any.whl.
File metadata
- Download URL: tank_wars_iit-1.0.2-py3-none-any.whl
- Upload date:
- Size: 54.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac5e982a5faaa5491f56e4aae13e6045b95d9ec0858a89827a7b42b7bb4182a7
|
|
| MD5 |
ce851a612b2f08028fd52f9e3ed7a81e
|
|
| BLAKE2b-256 |
7befc9c4a1d0ba03f542d31d86663c93da112986cbca0e5b6ba3deab69f8b82f
|