00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Goal.h"
00010
00011 #include "Cube.h"
00012
00013
00014 Goal::Goal(eSATISFY out, eSATISFY alive)
00015 {
00016 m_out = out;
00017 m_alive = alive;
00018 }
00019
00020 Goal
00021 Goal::noGoal()
00022 {
00023 return Goal(SATISFY_IGNORE, SATISFY_IGNORE);
00024 }
00025
00026 Goal
00027 Goal::outGoal()
00028 {
00029 return Goal(SATISFY_TRUE, SATISFY_IGNORE);
00030 }
00031
00032 Goal
00033 Goal::escapeGoal()
00034 {
00035 return Goal(SATISFY_TRUE, SATISFY_TRUE);
00036 }
00037
00038 Goal
00039 Goal::aliveGoal()
00040 {
00041 return Goal(SATISFY_IGNORE, SATISFY_TRUE);
00042 }
00043
00044 bool
00045 Goal::isSatisfy(const Cube *model) const
00046 {
00047 bool result = true;
00048 if (SATISFY_TRUE == m_out) {
00049 result &= model->isOut();
00050 }
00051 else if (SATISFY_FALSE == m_out) {
00052 result &= (!model->isOut());
00053 }
00054
00055 if (SATISFY_TRUE == m_alive) {
00056 result &= model->isAlive();
00057 }
00058 else if (SATISFY_FALSE == m_alive) {
00059 result &= (!model->isAlive());
00060 }
00061
00062 return result;
00063 }
00064
00065
00066
00067
00068
00069
00070 bool
00071 Goal::isWrong(const Cube *model) const
00072 {
00073 bool wrong = false;
00074 if (SATISFY_TRUE == m_alive) {
00075 wrong |= !model->isAlive();
00076 }
00077
00078 if (SATISFY_FALSE == m_out) {
00079 wrong |= model->isOut();
00080 }
00081 return wrong;
00082 }
00083
00084 bool
00085 Goal::shouldGoOut() const
00086 {
00087 return SATISFY_TRUE == m_out;
00088 }
00089
00090