Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Swarm AI

Author
Message
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 18th Oct 2006 00:09 Edited at: 18th Oct 2006 00:21
Here's a code snippet that simulates a swarm of insects, a school of fish, or a flock of birds. Left click to add an obstacle, scroll mouse wheel to increase/decrease seperation value, which controls how close the entities in the swarm want to be. Entities are attracted to the cursor unless you rightclick, in which case they run away from the mouse.

DarkMasta
18
Years of Service
User Offline
Joined: 21st Apr 2006
Location: Typed on your screen.
Posted: 18th Oct 2006 13:52
I'm also fond of creating my own 2d-AI as smooth as I can. I will post it here too once I think. It could be very handy: You get enemies pursuing, shooting and fleeing again in my module. 'Sounds similar to your one. I'll check that out.

Wherever you plan to go,
it's the next step you never know.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 18th Oct 2006 13:56
I like

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 19th Oct 2006 22:55
Cool, they regroup when they get separated

Confucius Say...
Mr Tank
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 22nd Oct 2006 06:10
Oh my word. That's so ace! I'm going to have to figure out how this works and stick it in my asteroids game. Space bees or something.


You'll be able to click on this someday.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 22nd Oct 2006 18:43
Coolios


Kyhoshi
18
Years of Service
User Offline
Joined: 21st Jun 2006
Location: Somewhere over the rainbow.
Posted: 24th Oct 2006 09:28
just one word... nice! i find it fun to trap em in a corner...

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Oct 2006 11:52 Edited at: 25th Oct 2006 11:53
Very cool. I had them confined to a sort of racing track I drew with the circles - but even better would be if you developed this code so that entities are not only repelled from obstacles, but are also attracted to user defined waypoints. This would enable you to get the entities to follow the track in a certain direction, instead of changing direction half way along and either doubling back on themselves, or running in circles. That would then be the basis of some very nice flocking+pathfinding AI. Come to think of it - that would be a good idea for a future coding challenge, too!

lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 3rd Nov 2006 12:05
Not sure why, but it looks like the Scout/Search AI thread got deleted (http://forum.thegamecreators.com/?m=forum_view&t=92173&b=6 ). Anyway, here was the code:
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd Nov 2006 15:09
fixed that problem for you.

Kaurotu
18
Years of Service
User Offline
Joined: 20th Oct 2006
Location: My Computer Chair
Posted: 9th Dec 2006 05:42
Nice. When you gather up some objects with your mouse and hold it in one spot, it looks like electrons flying around a nucleus.

Good ol' chemistry class.

tripleF
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 9th Dec 2006 13:53
if u like this kinda stuff check out http://www.red3d.com/cwr/boids/.
Cave Man
18
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 12th Dec 2006 21:08 Edited at: 12th Dec 2006 21:09
Pretty nice. I want to win the next coding challenge so i can make an AI challenge. Maybe i can convince whoever wins to do that.

Anyways, your thing is neat, you seem to be good at that sort of stuff.

Login to post a reply

Server time is: 2024-11-22 23:05:11
Your offset time is: 2024-11-22 23:05:11