Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (797)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Swarming BIODs (or not)  (Read 1932 times)
0 Members and 1 Guest are viewing this topic.
Offline mike_bike_kite
« Posted 2019-04-07 20:52:40 »

I just write arcade games as a hobby. In my new game I wanted to include a visual effect of swarming in the alien creatures. I've seen BIOD swarming algorithms which look perfect but I can't see how to translate them into the data structures I use elsewhere in the code. The published algorithm speaks about a general heading for the local flock mates but I just have an X & Y delta for each alien rather than a heading as such. Also, they talk about local flock mates but if I have say 50 aliens, would that mean I'd have to work out which alien is closest and then which aliens are then all together. This seems like a lot of processing for something that's not central to the game. I just can't quite see the best way to approach the problem.

The rules for swarming BIODs are  :
  • separation: steer to avoid crowding local flockmates
  • alignment: steer towards the average heading of local flockmates
  • cohesion: steer to move towards the average position (center of mass) of local flockmates

Thanks for any suggestions

Mike

Arcade swarm
Board Chess - Checkers - Othello
Offline Mykayla

Junior Newbie





« Reply #1 - Posted 2019-04-11 07:32:11 »

Very great stuff. i really appreicate this!
Vex 4
Offline mike_bike_kite
« Reply #2 - Posted 2019-04-11 10:41:27 »

Mykayla
Unfortunately it appears all your posts are just spam to link to your site.
Bit sad really.
Mike

Arcade swarm
Board Chess - Checkers - Othello
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ewg

Senior Devvie


Medals: 11


Java games rock!


« Reply #3 - Posted 2019-04-13 03:21:20 »

Hey Mike,

By heading they probably mean a normalized directional vector. The x and y deltas you have are more like a direction and a scale, it tells you which direction and how far in that direction the alien is going to move. To get the heading you want to take the scale out of your deltas by normalizing them so that they just represent a direction. That is a linear algebra term that just mean so make the scale of the vector equal to 1. So you can use any vector2d class and put your delta x and y into it and then call the normalize function on the vector2d.

For finding out the neighbor aliens I would recommend starting out by just calculating the distance to each other alien and picking the closest ones. Then when you know the algorithm is working for a handful of boids you can put in optimizations like using a fixed size grid and only checking the distances to boids that are in the same grid box or in on the the 8 surrounding grid boxes.
Offline Longarmx
« Reply #4 - Posted 2019-04-13 04:34:36 »

I remember watching this video several months ago on implementing simple flocking. You may find it helpful as he walks through implementing boids in JavaScript and then discusses some potential optimizations/extensions at the end.

<a href="http://www.youtube.com/v/mhjuuHl6qHM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/mhjuuHl6qHM?version=3&amp;hl=en_US&amp;start=</a>

Like ewg suggested, a fixed sized grid would be a useful optimization. I also think that a Quadtree would be beneficial to learn about and use as they are useful in many situations.

Offline mike_bike_kite
« Reply #5 - Posted 2019-04-13 16:13:04 »

Thanks for the ideas and video. There's quite a lot to understand there. I'll have to put my thinking cap on.

Arcade swarm
Board Chess - Checkers - Othello
Offline Gladys90

Junior Newbie





« Reply #6 - Posted 2019-04-16 06:14:13 »

Excellent post. Please keep up the great work. You may check our website also Visit: Transformice
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (3629 views)
2018-11-16 13:46:03

hadezbladez (1294 views)
2018-11-16 13:41:33

hadezbladez (3634 views)
2018-11-16 13:35:35

hadezbladez (697 views)
2018-11-16 13:32:03

EgonOlsen (4000 views)
2018-06-10 19:43:48

EgonOlsen (4528 views)
2018-06-10 19:43:44

EgonOlsen (2688 views)
2018-06-10 19:43:20

DesertCoockie (3548 views)
2018-05-13 18:23:11

nelsongames (3701 views)
2018-04-24 18:15:36

nelsongames (4726 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!