Skip to content

A new example project: Projectile Attack#294

Closed
LuHaot1an wants to merge 5 commits intomesa:mainfrom
LuHaot1an:GAME_Projectile_Attack
Closed

A new example project: Projectile Attack#294
LuHaot1an wants to merge 5 commits intomesa:mainfrom
LuHaot1an:GAME_Projectile_Attack

Conversation

@LuHaot1an
Copy link

Summary

A simple 2D projectile attack game built on the Mesa agent-based modeling framework, with a lightweight tkinter GUI. The project demonstrates how physical processes (gravity, wind, obstacles) and agent interactions can be integrated into an interactive simulation.

Motive

This project was created to explore how Mesa can be used beyond purely analytical simulations, extending into interactive and visual experiments. The project serves as a minimal but complete example of combining agent-based modeling, basic physics, and user-driven control in a single, self-contained application. It also provides an accessible reference for contributors interested in building educational or demonstrative simulations with Mesa.

Implementation

The implementation is organized into three core modules:

  • agents.py
    Defines the main agents (Tank, Shell, Target, and Cloud) and their behaviors, including projectile motion, gravity, wind effects, collision detection, and explosion logic.
  • model.py
    Implements the Mesa model, grid, and scheduler. It manages global game rules such as wall placement, wind blocking, shell lifecycle, target movement, and automatic round resets.
  • run.py
    Provides a tkinter-based GUI for interacting with the simulation. Users can adjust firing angle, power, wind strength, wall position and height, and toggle target movement, while also handling rendering and the main simulation loop.

Usage Examples

Start the game with directly running: run.py

Additional Notes

  • Adjust the angle and power sliders to control the projectile trajectory.

  • Enable wind to observe lateral drift and experiment with wall wind-blocking.

  • Toggle target movement to introduce additional challenge.

  • Press Fire to launch a shell when no projectile is active, and observe collision and explosion feedback.

tank_game_vis

@LuHaot1an LuHaot1an force-pushed the GAME_Projectile_Attack branch from aabd090 to 5bf9e20 Compare January 2, 2026 08:50
@tpike3
Copy link
Member

tpike3 commented Jan 3, 2026

Thanks @LuHaotian-UCL . There is a couple significant issues so I am going to close this PR and ask you resubmit

Issues:

  • Why do you make your own Random activation class instead of using the shuffle_do
  • It was an interesting choice to use tkinter, which is fine, but I dont see the GUI module anywhere
  • The pyproject.toml does not appear to accurate reflect the dependencies.

@tpike3 tpike3 closed this Jan 3, 2026
@LuHaot1an
Copy link
Author

@tpike3 I sincerely apologize for these serious mistakes. As I am still new to Mesa, I have taken more time to deepen my understanding of the framework and have revised the example I plan to contribute accordingly in a new pr #310 :

  1. I have already used the shuffle_do method.
  2. I previously used tkinter because I didn't know how to implement the game logic with solara (one simulation represents one game, and one game has several lives), but now I have achieved it, so I have switched to solara for visualization.
  3. I guarantee that the dependencies in the current pyproject.toml are correct.
    I would appreciate it if you could take a bit more time to review my example in the new pr. If there are any further issues, please feel free to reach out, and I will gladly continue refining the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants