MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Data Structures | Public Member Functions | Static Public Member Functions | Static Public Attributes
MFM::Element_Boids< CC > Class Template Reference

#include <Element_Boids.h>

Inheritance diagram for MFM::Element_Boids< CC >:
MFM::Element< CC > MFM::Element_Boids1< CC > MFM::Element_Boids2< CC >

Public Member Functions

Vector GetHeading (const T &atom) const
 
void SetHeading (const T &atom, const Vector v) const
 
SPoint PickPossibleDestination (EventWindow< CC > &window, const Vector &target, Random &random) const
 
virtual void Behavior (EventWindow< CC > &window) const
 
- Public Member Functions inherited from MFM::Element< CC >
 Element (const UUID &uuid)
 
void AllocateType ()
 
u32 GetType () const
 
const char * GetAtomicSymbol () const
 
const char * GetName () const
 
virtual void AppendDescription (const T *atom, OString64 &desc) const
 
bool IsType (u32 type) const
 
const UUIDGetUUID () const
 
virtual const T & GetDefaultAtom () const
 
virtual u32 PhysicsColor () const
 
virtual const char * GetDescription () const
 
virtual u32 DefaultPhysicsColor () const =0
 
virtual u32 DefaultLowlightColor () const
 
void ToggleLowlightPhysicsColor ()
 
virtual u32 LocalPhysicsColor (const T &atom, u32 selector) const
 
virtual u32 Diffusability (EventWindow< CC > &ew, SPoint nowAt, SPoint maybeAt) const
 
u32 NoDiffusability (EventWindow< CC > &ew, SPoint nowAt, SPoint maybeAt) const
 
const ElementParameters< CC > & GetElementParameters () const
 
ElementParameters< CC > & GetElementParameters ()
 
const AtomicParameters< CC > & GetAtomicParameters () const
 
AtomicParameters< CC > & GetAtomicParameters ()
 

Static Public Member Functions

static bool IsBoidType (u32 type)
 

Static Public Attributes

static const u32 TYPE = 0xbd
 
static const u32 TYPE_BITS = 8
 
static const u32 TYPE_MASK = (1<<TYPE_BITS)-1
 
static const u32 BITS_PER_DIM = 4
 
static const u32 STATE_HEADING_IDX = 0
 
static const u32 STATE_HEADING_LEN = 2 * BITS_PER_DIM
 
static const u32 STATE_BITS = STATE_HEADING_IDX + STATE_HEADING_LEN
 
- Static Public Attributes inherited from MFM::Element< CC >
static const u32 COMPLETE_DIFFUSABILITY = 1000
 

Additional Inherited Members

- Protected Member Functions inherited from MFM::Element< CC >
virtual T BuildDefaultAtom () const
 
const BitVector
< P::BITS_PER_ATOM > & 
GetBits (const T &atom) const
 
BitVector< P::BITS_PER_ATOM > & GetBits (T &atom) const
 
bool IsValidAtomicSymbol (const char *symbol)
 
void SetAtomicSymbol (const char *symbol)
 
void SetName (const char *name)
 
void Diffuse (EventWindow< CC > &window) const
 
virtual u32 PercentMovable (const T &you, const T &me, const SPoint &offset) const =0
 

Detailed Description

template<class CC>
class MFM::Element_Boids< CC >

A clump-forming class. Goals:

Class: (C1) Name is Ball (C2) Type is 0xba11 (C3) State is BallState

Sets: (S1) BallState is { center, when }, with (S1.1) center, a TinyVec<3> — heading to believed center (S1.2) when, a u3 — events since last two+ point confirmation on center. — max value for 'when' means no confidence in 'center' (S2) BallInfo is { center, count, distance, nearus, adjemp }, with (S2.1) center, a Point — location of claimed Ball center (S2.2) count, a u8 — number of votes for that center (S2.3) distance, a u8 — distance to nearest-us voter for this center (S2.4) nearus, a Point — location of nearest-us voter for this center (S2.5) adjemp, a Point — location of Moore neighborhood empty nearest this center

(S3) Centers is Array[limit 3] of BallInfo (S4) Empties is Array[limit 7] of Point — Moore neighborhood empties

Actors: (A1) self, a Ball (A2) info, a Centers (A3) empties, an Empties (A4) i, an Index into info (A5) e, an Index into empties

Self check:

Perception:

Reactions:

(R1) self.when = 0

(R2) Place(self), then (R3) Done

(R4) self.when = 0, then (R5) self.center += empties[e]-self, then (R6) self <=> empties[e], then (R7) Done

Thought:

— (1) If I'm part of a confirmed ball stay near center — (2)

(1) If info.length > 0: — At least one confirmed center

(1.1) If there exists i such that self.center info[i].center:

Do (R1), then

(1.1.1) Length(info[i].center) > 1: — We're not at center (1.1.1.1) There is an adjacent empty e closer than self to center Do (R5), (R6), then Done (1.1.1.2) — No closer empty Do (R2) then Done (1.1.2) MinDist to ball <= 1 (1.1.2.1) There is an adjacent empty e farther from ball but no farther than self from center Do (R5), (R6), then Done

:=> Stand

Member Function Documentation

template<class CC >
virtual void MFM::Element_Boids< CC >::Behavior ( EventWindow< CC > &  window) const
inlinevirtual

Describes the behavior of this Element. This is invoked when an Atom of this Element is chosen as the center of an EventWindow for an Event, which is given as a parameter.

Parameters
windowThe EventWindow describing the Event which is currently being executed.

Implements MFM::Element< CC >.


The documentation for this class was generated from the following file: