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_Pair< T, R > Class Template Reference

#include <Element_Pair.h>

Inheritance diagram for MFM::Element_Pair< T, R >:
MFM::Element< T, R >

Public Member Functions

Vector GetHeading (const T &atom) const
 
void SetHeading (const T &atom, const Vector v) const
 
SPoint PickPossibleDestination (EventWindow< T, R > &window, const Vector &target, Random &random) const
 
virtual void Behavior (EventWindow< T, R > &window) const
 
- Public Member Functions inherited from MFM::Element< T, R >
 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 void Behavior (EventWindow< T > &window) const =0
 
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< T > &ew, SPoint nowAt, SPoint maybeAt) const
 
u32 NoDiffusability (EventWindow< T > &ew, SPoint nowAt, SPoint maybeAt) const
 
const ElementParameters< T > & GetElementParameters () const
 
ElementParameters< T > & GetElementParameters ()
 
const AtomicParameters< T > & GetAtomicParameters () const
 
AtomicParameters< T > & 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< T, R >
static const u32 COMPLETE_DIFFUSABILITY
 

Additional Inherited Members

- Protected Member Functions inherited from MFM::Element< T, R >
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< T > &window) const
 
virtual u32 PercentMovable (const T &you, const T &me, const SPoint &offset) const =0
 

Detailed Description

template<class T, u32 R>
class MFM::Element_Pair< T, R >

A pair-forming class.

Class: (C1) Name is Element_Pair (C2) Type is 0x2b2 (C3) Role is u1 (C3.1) Role 0 is Unemployed (C3.2) Role 1 is Paired (C3.2.1) Paired state is { side, a u1; loc, a V2D<2> }

Role: Unemployed

Behavior:

if otherLoc == none, then { assert(OddsOf(19,20)); diffuse } else { self.role = Paired self.role.Paired.side = 1 self.role.Paired.loc = otherLoc other.role = Paired other.role.Paired.side = 0 other.role.Paired.loc = -otherLoc Place(self,(0,0)) Place(other,otherLoc) } Done

Role: Employed

Element_Pair other = [self.role.Paired.loc] — or FAIL assert(other.role == Paired) assert(other.role.Paired.side == 1-self.role.Paired.side) assert(other.role.Paired.loc == -otherLoc)

Search for emptyLoc, an empty location less than distance 3 from both self and other

if (emptyLoc

Behavior:

if otherLoc == none, then { if OneIn(20) then destroy self else diffuse } else { self.role = Paired self.role.Paired.side = 1 self.role.Paired.loc = otherLoc other.role = Paired other.role.Paired.side = 0 other.role.Paired.loc = -otherLoc Place(self,(0,0)) Place(other,otherLoc) } Done

 (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


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