7 ms·
Show HN: Demo of Agent Based Model on GPU with CUDA and OpenGL (Windows/Linux)
Demo of agent based model on GPU with CUDA and OpenGL (Windows/Linux)
Agent instances on GPU memory
Uses SSBO for instanced objects (with GLSL 450 shaders)
CUDA OpenGL interops
Renders with GLFW3 window manager
Dynamic camera views in OpenGL (pan,zoom with mouse)
Libraries installed using vcpkg
(https://github.com/KienTTran/ABMGPU https://github.com/KienTTran/ABMGPU)
- sgt101 3y agoreminds me of the flocking demos 20 years ago...
- ktt8788 3y agoThanks. It's a nostalgia app haha.
- blurbleblurble 3y agoWhat exactly is an "agent based model" in this case? What I see is a lot of triangles moving around, but what exactly drives them?
- 3abiton 3y agoFrom my understanding it's the term used for Complex Modelling Systems in Social Sciences.
- ktt8788 3y agoHi, thank you for your interest. Agent based model is a term refers to an interaction between multiple object (called agent) with its own property. The triangle is one agent in this case and in this example it moves along a random trajectory (just like people in a crowd). Each triangle also has its own color of its population so agents in the same population will have the same color.
- TheHideout 3y agoAre the agents independent or are they affected by neighbors? It would be nice to see some classic ABM examples like wolf-sheep population, flocking, and wildfire spread to demonstrate the utility of this.
- ktt8788 3y agoRight now it's independent. I just want to provide a playground and people can make more with it. Loves your idea though.
- m-murphy 3y agoAre the entities interacting in any way here? That's pretty critical for agent based models as they enable complicated/unexpected emergent behavior from simplified rules due to the interactions of the entities.
- ktt8788 3y agoYeah they should be interact to each other. Right now I just started with it and want to share so everyone can take advantage in their ways.
- m-murphy 3y agoAnother related project for ABMs utilizing GPUs: https://docs.flamegpu.com/guide/index.html https://docs.flamegpu.com/guide/index.html
- ktt8788 3y agoThis is supercool and beyond what I've done. Thanks for sharing.
- TheEzEzz 3y agoSuper cool, curious to see where you take this! I did some work on GPGPU for agent simulations for an RTS years ago ( https://www.youtube.com/watch?v=P4fKJIrv0J8 https://www.youtube.com/watch?v=P4fKJIrv0J8 ). Doing things like pathfinding on the GPU gets tricky, especially taking into account how agents affect paths of other agents. Happy to jam anytime if you're brainstorming applications.
- ktt8788 3y agoThis's awesome. Happy to know that you're doing the same.
- jasonjmcghee 3y agoYou should work on inter-agent interaction next! It's so much fun. I have played with this a fair amount and put a couple of my experiments in a repo- both slime mold simulation and "particle life". Here's the repo: https://github.com/jasonjmcghee/compute-shaders https://github.com/jasonjmcghee/compute-shaders And a video of the slime mold: https://twitter.com/_jason_today/status/1663378736098738177?s=46&t=ZjF9if4qtE9ppAnug9UOPQ https://twitter.com/_jason_today/status/1663378736098738177?...
- ktt8788 3y agoWow it's amazing visualization. Thanks for suggestion.
- posnet 3y agoAnother fun one, not sure about accuracy, but the visuals are stunning. https://youtu.be/dSkxvi9igqQ https://youtu.be/dSkxvi9igqQ https://github.com/chrxh/alien/ https://github.com/chrxh/alien/
- ktt8788 3y agoThis is brilliant. Thanks for sharing.
- moritonal 3y agoIf you want to create some pretty effects, add the concept of a velocity-texture which is added to agents velocity as they pass over it. Then let the user draw on the texture. Very cheap way to get interactivity. My own version from before compute shades were a thing (https://moritonal.github.io/force-particles/ https://moritonal.github.io/force-particles/)
- ktt8788 3y agoThanks for your advice. I will update more in the next version.
- westurner 3y agoCould this work in WebGL and/or WebGPU (and/or WebNN) with or without WASM in a browser? https://stackoverflow.com/questions/48228192/webgl-compute-shader-and-vbo-ubos https://stackoverflow.com/questions/48228192/webgl-compute-s... https://github.com/conda-forge/glfw-feedstock/blob/main/recipe/meta.yaml https://github.com/conda-forge/glfw-feedstock/blob/main/reci... pyglfw: https://github.com/conda-forge/pyglfw-feedstock/blob/main/recipe/meta.yaml https://github.com/conda-forge/pyglfw-feedstock/blob/main/re... - [ ] glfw recipe for emscripten-forge: https://github.com/emscripten-forge/recipes/tree/main/recipes/recipes_emscripten https://github.com/emscripten-forge/recipes/tree/main/recipe... Emscripten porting docs > OpenGL ES 2.0/3.0 *, glfw: https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html https://emscripten.org/docs/porting/multimedia_and_graphics/... WebGPI API > GPUBuffer: https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API gpuweb/gpuweb: https://github.com/gpuweb/gpuweb https://github.com/gpuweb/gpuweb https://news.ycombinator.com/item?id=38355444 https://news.ycombinator.com/item?id=38355444 : > It actually looks like pygame-web (pygbag) supports panda3d and harfang in WASM Harfang and panda3d do 3D with WebGL, but FWIU not yet agents in SSBO/VBO/GPUBuffer. SSBO: Shader Storage Buffer Object: https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Object https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Ob... /? WebGPU compute: https://www.google.com/search?q=webgpu+compute https://www.google.com/search?q=webgpu+compute "WebGPU Compute Shader Basics" https://webgpufundamentals.org/webgpu/lessons/webgpu-compute-shaders.html https://webgpufundamentals.org/webgpu/lessons/webgpu-compute...
- ktt8788 3y agoBasically possible. You have to remove all Cuda code and port C++ code to use glfw with specific library for web. The shader can be reused.