Skip to main content

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 all Entity classes supported by the engine.
      • bullet.py - Contains the Bullet class (inherits Entity); represents a bullet that moves in the direction it faces, bounces off walls, and collides with Robots.
      • entity.py - Contains the Entity abstract class, which represents a geometric object in an Arena.
      • robot.py - Contains the Robot class (inherits Entity); represents a robot that can move, turn, turn its turret, and shoot Bullets.
      • wall.py - Contains the Wall class (inherits Entity); represents a static, unmovable barrier.
    • maps - Directory containing map JSON files which can be used to easily instantiate an Arena with Walls and spawn locations.
      • basic.json - A small, wide map with five Walls and two spawns.
      • circles.json - A medium, square map with two concentric circles of Walls and four spawns.
      • stress_test.json - A large, square map with no Walls 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 the Arena class, which represents a battle arena for one or more Robots.
    • map.py - Contains type definitions and guards for the map JSON format.
    • quadtree.py - Contains the Quadtree class, which is a data structure used to optimize collision filtering.
  • tools - Useful scripts to automate workflows.
    • generate_circles.py - Generates the engine/maps/circles.json map.
    • generate_stress_test.py - Generates the engine/maps/stress_test.json map.
  • init.py - Loads an Arena from a map, spawns a user-controlled Robot and several NPC Robots, 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!
  • Optimization
    • [IMPLEMENTED] Quadtree Collision Filtering - Use a Quadtree data structure to filter which collisions to check for as opposed to checking every pair of Entitys.
    • Parallelize Entity.update - Invoke all calls of Entity.update in parallel since they operate mostly independently (exception is modification of shared Arena state, like spawning Bullets via Robot.shoot).
    • Parallelize Entity.handle_collision - Invoke all calls of Entity.handle_collision in parallel; modify the method to return new position and rotation properties that will be applied in parallel.
  • Game Rules
    • [IMPLEMENTED] Robot Destruction - Incorporate health in Robot and damage in Bullet.
    • Win Condition - Destroy the other Robot.
    • Stalemate Condition - Both Robots are still alive after n seconds of simulation.
    • [IMPLEMENTED] Coins - Place Coin entities around the Arena; whichever Robot collects the most wins in case of stalemate.
  • Robot Programmability
    • [IMPLEMENTED] Robot Manipulation - Expose API to move and turn the Robot and shoot Bullets.
    • [IMPLEMENTED] Enemy Robot Detection - Expose API to find the nearest Robot to a given Robot.
    • [IMPLEMENTED] Pathfinding - Expose API for Robots to navigate their way to a location around Walls.
    • RobotControl Class - Incorporate all programmable/personalizable Robot features into one class which each team extends with their implementation. For now, it's semi-implemented as the Robot.on_update callback, which is unideal because it doesn't secure the engine from unwanted modifications.
    • Engine Encapsulation - Prevent raw access to any Entitys or the Arena; the only accessible component is the RobotControl class.
  • Robot Personalization
    • [IMPLEMENTED] Color - Set Robot colors via properties color and head_color.
    • Size - Set Robot size; larger size increases health and decreases speed.
  • Robot Examples
  • Unit Tests
  • Prepare for Distribution

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tank_wars_iit-1.0.2-py3-none-any.whl (54.6 kB view details)

Uploaded Python 3

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

Hashes for tank_wars_iit-1.0.2.tar.gz
Algorithm Hash digest
SHA256 68e39093cfb0d7357be2cdf4b70121ddfc8814b82a02f3f83f133d9546c7e5ad
MD5 802244e4493454082c93d7c64805291f
BLAKE2b-256 eb2e02340167869cd6083c84addc444942f3be5df9b81b6641599906bc0c8441

See more details on using hashes here.

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

Hashes for tank_wars_iit-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ac5e982a5faaa5491f56e4aae13e6045b95d9ec0858a89827a7b42b7bb4182a7
MD5 ce851a612b2f08028fd52f9e3ed7a81e
BLAKE2b-256 7befc9c4a1d0ba03f542d31d86663c93da112986cbca0e5b6ba3deab69f8b82f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page