27 #ifndef ELEMENT_ANTIFORKBOMB_H
28 #define ELEMENT_ANTIFORKBOMB_H
40 #define ANTIFORKBOMB_VERSION 1
46 typedef typename CC::ATOM_TYPE T;
47 typedef typename CC::PARAM_CONFIG P;
49 R = P::EVENT_WINDOW_RADIUS,
50 BITS = P::BITS_PER_ATOM,
55 INFLAMMATION_POS = T::ATOM_FIRST_STATE_BIT,
95 const u32 LEVEL_INCREMENT = 50;
96 return ((level*LEVEL_INCREMENT + (255-3*LEVEL_INCREMENT))<<8) | 0xff000000;
102 const u32 ourType = THE_INSTANCE.
GetType();
112 u32 maxInflammation = 0;
117 for (u32 i = loIdx; i <= hiIdx; ++i)
119 const SPoint rel = md.GetPoint(i);
125 const u32 type = atom.GetType();
129 if (random.
OneIn(++emptyCount))
133 }
else if (type == ourType)
136 if (level > maxInflammation)
138 maxInflammation = level;
140 if (random.
OneIn(++usCount))
152 if (maxInflammation >= 3)
154 u32 inflammationLevel = maxInflammation - 1;
161 for (u32 i = loIdx; i <= hiIdx; ++i)
163 const SPoint rel = md.GetPoint(i);
165 const u32 type = atom.GetType();
172 else if (myInflammationLevel > 0)
177 else if (usCount < m_minDensity)
184 }
else if (usCount > m_maxDensity)
196 const T& me,
const SPoint& offset)
const
210 Element_AntiForkBomb<CC> Element_AntiForkBomb<CC>::THE_INSTANCE;
u32 GetFirstIndex(const u32 radius) const
Definition: MDist.h:112
static void Write(BV &bv, u32 val)
Definition: BitField.h:84
void Diffuse(EventWindow< CC > &window) const
Definition: Element.tcc:73
virtual u32 PercentMovable(const T &you, const T &me, const SPoint &offset) const
Definition: Element_AntiForkBomb.h:195
u32 GetType() const
Definition: Element.h:290
Definition: Element_Empty.h:41
static u32 Read(const BV &bv)
Definition: BitField.h:73
Definition: AbstractElement_ForkBomb.h:41
Definition: Element_AntiForkBomb.h:43
u32 GetLastIndex(const u32 radius) const
Definition: MDist.h:129
virtual void Behavior(EventWindow< CC > &window) const
Definition: Element_AntiForkBomb.h:99
virtual u32 DefaultPhysicsColor() const
Definition: Element_AntiForkBomb.h:201
void SetCenterAtom(const T &atom)
Definition: EventWindow.h:220
Tile< CC > & GetTile()
Definition: EventWindow.h:132
void SetName(const char *name)
Definition: Element.h:209
void SetAtomicSymbol(const char *symbol)
Definition: Element.h:193
bool IsLiveSite(const SPoint &location) const
Definition: EventWindow.h:148
bool OneIn(u32 odds)
Definition: Random.h:96
Random & GetRandom()
Definition: EventWindow.h:122
const T & GetRelativeAtom(const SPoint &offset) const
Definition: EventWindow.tcc:26
const T & GetCenterAtom() const
Definition: EventWindow.h:209
virtual const T & GetDefaultAtom() const
Definition: Element.h:382
static MDist< R > & get()
Definition: MDist.tcc:193
Definition: ElementTable.h:43
bool SetRelativeAtom(const SPoint &offset, const T &atom)
Definition: EventWindow.tcc:15
virtual u32 LocalPhysicsColor(const T &atom, u32 selector) const
Definition: Element_AntiForkBomb.h:87