植绒行为问题 [英] Flocking boids behaviour problem

查看:221
本文介绍了植绒行为问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我遇到了Craig Reynolds的 Boids ,随后发现我已经给了在Java中实现一个简单的2D版本。
我已经根据 Conrad Parker的笔记

Yesterday I came across Craig Reynolds' Boids, and subsequently figured that I'd give implementing a simple 2D version in Java a go. I've put together a fairly basic setup based closely on Conrad Parker's notes.

但是,我得到了一些相当奇怪的(在我看来)行为。目前,我的boids合理地快速移动到粗糙的网格或格子中,然后在现场进行抽搐。我的意思是他们移动一点并且经常旋转。

However, I'm getting some rather bizarre (in my opinion) behaviour. Currently, my boids move reasonably quickly into a rough grid or lattice, and proceed to twitch on the spot. By that I mean they move around a little and rotate very frequently.

目前,我已实施:


  1. 对齐

  2. Cohesion

  3. 分离

  4. 速度限制

  1. Alignment
  2. Cohesion
  3. Separation
  4. Velocity limiting

最初,我的boids随机分布在屏幕区域(与Parker的方法略有不同),它们的速度都指向屏幕区域的中心(注意随机初始化的速度给出相同的结果)。更改速度限制值只会改变boids进入此模式的速度,而不是形成模式。

Initially, my boids are randomly distributed across the screen area (slightly different to Parker's method), and their velocities are all directed towards the centre of the screen area (note that randomly initialised velocities give the same result). Changing the velocity limit value only changes how quickly the boids move into this pattern, not formation of the pattern.

正如我所看到的,这可能是:

As I see it, this could be:


  1. 我正在使用的参数的结果(现在我的代码如Parker的伪代码所述;我还没有尝试过一个由Reynolds所描述的角度和半径。)

  2. 我需要实现但我不知道的东西。

  3. 我做错了什么。

预期的行为会更加顺畅在Reynolds的boids页面上applet中发生的二维版本,虽然现在我还没有实现任何方法来保持屏幕上的boid。

The expected behaviour would be something more along the lines of a two dimensional version of what happens in the applet on Reynolds' boids page, although right now I haven't implemented any way to keep the boids on screen.

已经有没有遇到过这个?有关原因和/或如何解决的任何想法?如果它有帮助,我可以发布一个.gif的行为。

Has anyone encountered this before? Any ideas about the cause and/or how to fix it? I can post a .gif of the behaviour in question if it helps.

推荐答案

也许你对分离规则的权重过强,导致所有的boid尽可能远离所有相邻的boids。我的伪代码中有各种常量作为权重:规则1中的/ 100和规则3中的/ 8(规则2中的隐含* 1);这些可以调整,这通常可用于建模不同的行为,如密集蜂鸟或滑翔的鸟类。

Perhaps your weighting for the separation rule is too strong, causing all the boids to move as far away from all neighboring boids as they can. There are various constants in my pseudocode which act as weights: /100 in rule 1 and /8 in rule 3 (and an implicit *1 in rule 2); these can be tweaked, which is often useful for modelling different behaviors such as closely-swarming insects or gliding birds.

此外,任意|距离| <应修改分离规则中的100以匹配模拟的单位;此规则应仅适用于近距离的boids,基本上是为了避免碰撞。

Also the arbitrary |distance| < 100 in the separation rule should be modified to match the units of your simulation; this rule should only apply to boids within close proximity, basically to avoid collisions.

玩得开心!

这篇关于植绒行为问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆