eighthill / Slime_Mold_Simulation

A student project simulating smile mold🧫
MIT License
6 stars 0 forks source link

Create a new .py with an test where an agent moves through the scree #5

Closed ModusMorris closed 10 months ago

ModusMorris commented 11 months ago

So I have now started the first test and wanted to see if the visualization works with vispy. First of all what the code does. agents = [{"x": 0.5, "y": 0.5, "vx": random.uniform(-1, 1), "vy": random.uniform(-1, 1)} for _ in range(1)] SPEED = 0.01 Here, the agents are defined as a list of dictionaries. Each agent has an x and y position ("x" and "y") and a random initial speed ("vx" and "vy") between -1 and 1. 1 agents are created here. SPEED is a factor that controls the speed of the movement. 2. vertex_shader and fragment_shader: The vertex and fragment shaders are defined here. The vertex shader defines the positions of the points, and the fragment shader defines the color of the points (here white). 3. canvas and program The canvas (the drawing area) and the program for the shaders are created here. 4.program["position"] = [(agent["x"], agent["y"]) for agent in agents] The initial positions of the agents in the program are defined here. 5. def update() This defines the function that is called for each timer event. It updates the positions of the agents based on their speed and changes direction when an agent reaches the edge of the screen. 6. timer = This creates a timer that triggers the update event every 0.01 seconds. 7. def on_draw(event) This defines the function that is called when the canvas is redrawn. It deletes the previous image (gloo.clear()) and draws the points of the program (program.draw('points')). 8. Finally, if name The canvas is displayed here and the app is started if the script is not executed interactively.

ModusMorris commented 11 months ago

It is still missing that the agent can move on the whole window, at the moment it only moves on a certain radius

eighthill commented 11 months ago

@ModusMorris Checks are failing. Looks like Black (code formatter) is causing the issue. The error is called on this file: SlimeMold_OneAgent.py Could you update your code so black --check doesn't exit with an error? I think the solution would be to run Black on your file and let it format it according to it's standards.