This repository contains a small Boids simulation written in Julia using GameZero.jl (render + input loop) and Colors.jl for visuals. The simulation implements the classic three steering behaviors: Separation, Alignment, and Cohesion.
I am currently unable to launch the simulation window ("view mode") on my Windows setup. This README documents the code, the expected behaviour, the minimal tests I ran, observed symptoms and logs, and a clear reproduction recipe so maintainers can diagnose the problem quickly.
-
Spawns
ncircular agents (boids) with random positions and velocities. -
Each update step computes steering forces for each boid using three rules:
- Separation: steer away from nearby boids to avoid collisions.
- Alignment: steer toward the average heading of nearby boids.
- Cohesion: steer toward the centroid of nearby boids.
-
Forces are combined and applied to velocities; positions wrap at borders.
Key tunable parameters in the code:
perception_radius— how far a boid senses neighborsmin_speed,max_speed— speed clampingseparation_dial,alignment_dial,cohesion_dial— influence / smoothing factors
All rules are computed for each boid i by scanning neighbors j within perception_radius.
Separation
- For each neighbor
jcompute the vector from neighbor to self:s = (x_i - x_j, y_i - y_j). - Sum these vectors across neighbors and divide by
total_neighborsto get an average separation vectorS. - The steering contribution is
(S - v_i) / separation_dial(rounded/clamped tomin_speed..max_speed). - Purpose: produce a short-range repulsive force proportional to proximity.
Alignment
- Compute the average velocity of neighbors
V = mean(v_j). - Steering =
(V - v_i) / alignment_dial(clamped). - Purpose: gradually steer boid velocity toward local group heading.
Cohesion
- Compute the average position of neighbors
C = mean(position_j). - Steering =
(C - position_i - v_i) / cohesion_dial(clamped). - Purpose: gently pull boids toward the local center of mass.
Final acceleration is the sum of the three steering contributions for each axis; velocities are updated and clamped to min_speed..max_speed.
using GameZero
# define draw in the GameZero namespace so the package picks it up
function GameZero.draw(g::Game)
background("black")
circle((200, 200), 50, "red")
endExpect: running julia testgame.jl from the folder should open a small window with a red circle.
using SimpleDirectMediaLayer.LibSDL2
if SDL_Init(SDL_INIT_VIDEO) != 0
error("SDL_Init Error: ", unsafe_string(SDL_GetError()))
end
window = SDL_CreateWindow("SDL2 test",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480,
SDL_WINDOW_SHOWN)
if window == C_NULL
error("SDL_CreateWindow Error: ", unsafe_string(SDL_GetError()))
end
SDL_Delay(2000)
SDL_DestroyWindow(window)
SDL_Quit()Expect: a 640×480 SDL window appears for ~2 seconds and then closes.
Pkg.status("GameZero")reportsGameZero v0.3.1installed in environment.- Running
SimpleDirectMediaLayer.SDL_Init(SimpleDirectMediaLayer.SDL_INIT_VIDEO)returned0(SDL video subsystem initialized successfully). - Running the minimal
testgame.jlhad no visible window pop up; in REPL it printedGame(#undef, #undef, ... ). - Attempts to call
run()producedMethodError: no method matching run(); therunsymbol is shadowed by other packages in my environment (VSCode debug adapter exposes otherrunmethods). methods(GameZero.draw)returned zero methods (GameZero saw nothing to call), whilemethods(draw)inMainshowed methods defined there.include("...")vsjulia testgame.jldifferences were tested: running from CMD (julia testgame.jl) exits immediately without opening a window;includein REPL returns method info but no visible window.
I have not been able to get the GameZero event loop to hold and render frames; it appears the package does not call the draw/update loop in my execution path.
-
Clone repo or download files to
C:\Users\adrian\Desktop\julia\julia_boid_simulation. -
In a terminal (PowerShell or CMD):
cd C:\Users\adrian\Desktop\julia\julia_boid_simulation julia testgame.jl
-
Observe: no window created; process returns to prompt with no visible UI.
From the Julia REPL I tried:
cd("C:/Users/adrian/Desktop/julia/julia_boid_simulation")
include("testgame.jl") # defines draw
Game() # constructed object printed as Game(#undef...)No window appeared.
If you reply to this issue, please include the following in your comment so I can reproduce exactly on my side:
julia -v] status GameZero(orimport Pkg; Pkg.status("GameZero")output)] status SimpleDirectMediaLayer(orPkg.status("SimpleDirectMediaLayer"))- OS: Windows 10 build/version
- The exact command you used to run the file (REPL
includeor CLIjulia testgame.jl) - Full stacktrace if you saw a
MethodErroror other error in the console
I need help diagnosing why GameZero is not launching its event loop on my Windows 10 machine. Specifically:
- Does GameZero expect
GameZero.drawto be defined (module-qualified) or isdraw(::Game)inMainsufficient? Which pattern is correct for the current release (please cite the canonical example). - Is there any known interaction with the VSCode debug adapter or REPL that can block SDL windows from appearing? (I saw
run()being shadowed by VSCode's DebugAdapter.) - Are there additional runtime dependencies (DLLs) or environment variables required on Windows for GameZero / SimpleDirectMediaLayer that are not described in the README?
- If requested, I can provide a small public repo with the exact files and an example
Project.toml; please advise what else to include to make reproduction trivial.
Please review the attached minimal repro files and advise next steps, or point to a working minimal example that you have validated on Windows 10.
testgame.jl— minimal GameZero draw examplesdltest.jl— minimal SDL2 window testboids_full.jl— full boids simulation (original code)
Thank you for your time and help. Please comment with pointers, or tag a maintainer if this looks like a bug in GameZero or SimpleDirectMediaLayer on Windows.