Ca.h File Reference


Detailed Description

Basic type definitions, classes CaState, CaEvalParams and interfaces ICaRules, IGate and IGateBinding.

Definition in file Ca.h.

#include <boost/dynamic_bitset.hpp>

Include dependency graph for Ca.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Pos
 CA cell position. More...
class  CaState
 Simple CA state representation. More...
class  IGate
 The most generic interface of designed (and/or simulated) circuit, most commonly a logical gate. More...
class  IGateBinding
 Interface to define a binding between simulated gate and designed CA. More...
class  ICaRules
 Interface to define rules of non-uniform CA. More...
struct  CaEvalParams
 CA evaluation parameters. More...
class  CaEvaluator
 CA evaluator runs the given CA and evaluates its fitness for the desired purpose. More...

Defines

#define RULE_WIDTH   (1 << 5)
 Common state space for cell and neighbors size (Von Neuman's neighborhood).

Typedefs

typedef signed long TCoord
 Type used for CA's cells addressing.
typedef unsigned long TBus
 Type used for in/out signals of gate.
typedef std::bitset< (1<< 5) > TRule5N
 Type for one-cell rule definition (32bit bitset).

Enumerations

enum  EDirection {
  D_NULL = 0, D_TOP, D_RIGHT, D_BOTTOM,
  D_LEFT, D_ONE_AFTER_LAST
}
 Possible direction enumeration. More...

Functions

void writeRule (std::ostream &str, const TRule5N &rule)
 Write CA rule in human-readable (colorized if possible) format.
Pos neighbor (Pos pos, EDirection dir)
 Return position of cell's neighbor.
std::ostream & operator<< (std::ostream &str, const CaState &state)
 Write CA state in human-readable (colorized if possible) format.
bool applyRule (const CaState &ca, Pos pos, const TRule5N &rule)
 Return the result of applied rule.
bool applyRules (CaState &state, const ICaRules *rules)
 Apply the given rule set on given CA state synchronously and check if anything is changed.


Define Documentation

#define RULE_WIDTH   (1 << 5)

Common state space for cell and neighbors size (Von Neuman's neighborhood).

Definition at line 50 of file Ca.h.

Referenced by CaDesigner::CaDesigner(), GaCaRules::GaCaRules(), GaCaRules::getRuleAtPos(), main(), and writeRule().


Typedef Documentation

typedef unsigned long TBus

Type used for in/out signals of gate.

Consider use of std::bitset if machine does not provide long enough integer.

Definition at line 45 of file Ca.h.

typedef signed long TCoord

Type used for CA's cells addressing.

Definition at line 39 of file Ca.h.

typedef std::bitset< (1 << 5) > TRule5N

Type for one-cell rule definition (32bit bitset).

Definition at line 55 of file Ca.h.


Enumeration Type Documentation

enum EDirection

Possible direction enumeration.

D_NULL is commonly used for the cell self.

Enumerator:
D_NULL 
D_TOP 
D_RIGHT 
D_BOTTOM 
D_LEFT 
D_ONE_AFTER_LAST 

Definition at line 61 of file Ca.h.


Function Documentation

bool applyRule ( const CaState ca,
Pos  pos,
const TRule5N rule 
)

Return the result of applied rule.

The given CA is not changed at all.

Parameters:
ca The CA's state to compute new value for.
pos Position of the cell to compute the new value for.
rule The rule ought to be applied.

Definition at line 97 of file Ca.cpp.

References D_BOTTOM, D_LEFT, D_RIGHT, D_TOP, CaState::getCellAtPos(), and neighbor().

Referenced by applyRules().

Here is the call graph for this function:

Here is the caller graph for this function:

bool applyRules ( CaState state,
const ICaRules rules 
)

Apply the given rule set on given CA state synchronously and check if anything is changed.

Parameters:
state CA state to apply the rule set on.
rules The set of rules ought to be applied.

Definition at line 123 of file Ca.cpp.

References applyRule(), ICaRules::getRuleAtPos(), CaState::setCellAtPos(), and CaState::size().

Referenced by CaEvaluator::cntSteps(), CaEvaluator::eval(), and CaEvaluator::simulate().

Here is the call graph for this function:

Here is the caller graph for this function:

Pos neighbor ( Pos  pos,
EDirection  dir 
) [inline]

Return position of cell's neighbor.

Note:
There is no range check, no extra and/or intelligent behavior.
Parameters:
pos Self position of the cell.
dir Direction to look for neighbor.

Definition at line 98 of file Ca.h.

References Pos::col, D_BOTTOM, D_LEFT, D_RIGHT, D_TOP, and Pos::row.

Referenced by applyRule().

Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  str,
const CaState state 
)

Write CA state in human-readable (colorized if possible) format.

Parameters:
str Standard output stream to write to.
state The CA state ought to be write.

Definition at line 37 of file Ca.cpp.

References CaState::getCellAtPos(), and CaState::size().

Here is the call graph for this function:

void writeRule ( std::ostream &  str,
const TRule5N rule 
)

Write CA rule in human-readable (colorized if possible) format.

Parameters:
str Standard output stream to write to.
rule The CA rule ought to be write.

Definition at line 46 of file Ca.cpp.

References C_LIGHT_GREEN, C_LIGHT_RED, C_NO_COLOR, and RULE_WIDTH.

Referenced by writeRules().

Here is the caller graph for this function:


Generated on Sat May 2 16:39:32 2009 for nucad by  doxygen 1.5.4