Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Goal.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
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  * Return whether goal cannot by solved any more.
00067  * Dead fish cannot be revived.
00068  * Object out of room cannot go back.
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 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2