Ca.cpp File Reference


Detailed Description

Implementation of CaState, CaEvaluator and ICaRules helper functions.

Definition in file Ca.cpp.

#include "config.h"
#include "Ca.h"
#include "Color.h"

Include dependency graph for Ca.cpp:

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &str, const CaState &ca)
 Write CA state in human-readable (colorized if possible) format.
void writeRule (std::ostream &str, const TRule5N &rule)
 Write CA rule 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 &ca, const ICaRules *rules)
 Apply the given rule set on given CA state synchronously and check if anything is changed.
void writeCaState (std::ostream &str, const CaState &state, const CaState &inputs, const CaState &outputs, const CaState &desiredOutputs, const CaState &lastState, bool preferInput=false)


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:

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 @0::writeCaState ( std::ostream &  str,
const CaState state,
const CaState inputs,
const CaState outputs,
const CaState desiredOutputs,
const CaState lastState,
bool  preferInput = false 
) [static]

Definition at line 330 of file Ca.cpp.

References C_LIGHT_BLUE, C_LIGHT_GREEN, C_LIGHT_RED, C_NO_COLOR, C_YELLOW, CaState::getCellAtPos(), and CaState::size().

Referenced by CaEvaluator::simulate().

Here is the call graph for this function:

Here is the caller 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