Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduConditionSee.cc

Go to the documentation of this file.
00001 // Kodu Library
00002 #include "Kodu/KoduWorld.h"
00003 #include "Kodu/Primitives/KoduConditionSee.h"
00004 #include "Kodu/General/GeneralMacros.h"
00005 
00006 namespace Kodu {
00007 
00008     bool KoduConditionSee::evaluate(const KoduWorld& kWorldState) {
00009         bool rv = false;
00010         DualCoding::ShapeRoot _refdObject;
00011         
00012         // get the closest object that matches what this condition is searching for
00013         _refdObject = getClosestObjectMatching(objColor, objType, searchLocation, kWorldState.thisAgent.gripperObject);
00014         
00015         // If there is one valid remaining, the robot will react to that object
00016         if (_refdObject.isValid()) {
00017           // std::cout << "Saw a(n) " << getObjectColor() << " " << getObjectType() << "!\n";
00018             ObjectKeeper::tempObject = _refdObject;
00019             ObjectKeeper::isValid = true;
00020             rv = true;
00021         }
00022         
00023         // check if the not modifier is enabled
00024         if (notModifierEnabled)
00025             return (!rv);
00026         else
00027             return rv;
00028     }
00029 
00030     const std::string& KoduConditionSee::getObjectColor() const {
00031         return objColor;
00032     }
00033 
00034     const std::string& KoduConditionSee::getObjectType() const {
00035         return objType;
00036     }
00037 
00038     const DualCoding::ShapeRoot KoduConditionSee::getTargetObject() {
00039         return refdObject;
00040     }
00041 
00042     bool KoduConditionSee::isSameTypeAs(const KoduPrimitive* kPrimitive) {
00043         return (dynamic_cast<const KoduConditionSee*>(kPrimitive) != NULL);
00044     }
00045 
00046     void KoduConditionSee::reinitialize() {
00047         KoduCondition::reinitialize();
00048     }
00049     
00050     void KoduConditionSee::printAttrs() const {
00051         KoduCondition::printAttrs();
00052         // not enabled?
00053         PRINT_ATTRS("Not enabled", notModifierEnabled);
00054         // object color and type
00055         std::cout << "Object color and type: " << objColor << " " << objType << std::endl;
00056         // search region
00057         /*
00058         std::cout << "Search region:";
00059         if (searchRegion == SR_UNRESTRICTED) {
00060             std::cout << " unrestricted\n";
00061         } else {
00062             if (searchRegion & SR_TO_LEFT) {
00063                 std::cout << " to_left";
00064             } else if (searchRegion & SR_TO_RIGHT) {
00065                 std::cout << " to_right";
00066             }
00067 
00068             if (searchRegion & SR_IN_FRONT) {
00069                 std::cout << " in_front";
00070             } else if (searchRegion & SR_BEHIND) {
00071                 std::cout << " behind";
00072             }
00073             std::cout << std::endl;
00074         }
00075         // search radius
00076         std::cout << "Search distance: ";
00077         switch (searchDistance) {
00078             case SD_UNRESTRICTED:
00079                 std::cout << "unrestricted\n";
00080                 break;
00081 
00082             case SD_CLOSE_BY:
00083                 std::cout << "close_by\n";
00084                 break;
00085 
00086             case SD_FAR_AWAY:
00087                 std::cout << "far_away\n";
00088                 break;
00089         }
00090         */
00091         // referenced object...
00092     }
00093 }

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:43 2016 by Doxygen 1.6.3