Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduGenerators.cc

Go to the documentation of this file.
00001 #include "Kodu/Generators/KoduGenerators.h"
00002 
00003 namespace Kodu {
00004     
00005     const std::string& LiteralGenerator::getLiteralString() {
00006         switch (order) {
00007             case RO_SEQUENTIAL:
00008                 vecIndex = (vecIndex + 1) % literalStrings.size();
00009                 break;
00010 
00011             case RO_RANDOM:
00012                 vecIndex = rand() % literalStrings.size();
00013                 break;
00014         }
00015         return literalStrings[vecIndex];
00016     }
00017 
00018     void LiteralGenerator::printAttrs() const {
00019         std::cout << "Literal Generator:\n";
00020         std::cout << "Literal generator string count: " << literalStrings.size() << std::endl;
00021         std::cout << "Spoken order: ";
00022         switch (order) {
00023             case RO_SEQUENTIAL:
00024                 std::cout << "sequential";
00025                 break;
00026 
00027             case RO_RANDOM:
00028                 std::cout << "random";
00029                 break;
00030         }
00031         std::cout << std::endl;
00032         for (std::size_t i = 0; i < literalStrings.size(); i++)
00033             std::cout << "\tString [" << i << "]: " << literalStrings[i] << std::endl;
00034     }
00035 
00036     void LiteralGenerator::setLiteralStrings(const std::vector<std::string>& kLiteralStrings) {
00037         literalStrings = kLiteralStrings;
00038         vecIndex = literalStrings.size() - 1;
00039     }
00040 
00041     float NumericGenerator::getNumericValue() {
00042         if (moduloDivisor >= 2.0f) {
00043             float randVal = static_cast<float>(rand() % static_cast<int>(moduloDivisor));
00044             return (randVal + constant);
00045         } else {
00046             return constant;
00047         }
00048     }
00049 
00050     void NumericGenerator::printAttrs() const {
00051         std::cout << "Numeric Generator:\n";
00052         std::cout << "Constant: " << constant << std::endl;
00053         std::cout << "Upper bound: " << moduloDivisor << std::endl;
00054         std::cout << "Performing random numeric selection: " << (moduloDivisor >= 2 ? "yes" : "no") << std::endl;
00055     }
00056 
00057     void NumericGenerator::setNumericValues(float constantVal, float upperBoundVal) {
00058         constant = constantVal;
00059         moduloDivisor = upperBoundVal;
00060     }
00061     
00062     /*
00063     float TimerGenerator::getNumericValue() {
00064         if (moduloDivisor >= 2.0f) {
00065             int randIntVal = (rand() % (int)(moduloDivisor * 4));
00066             return (constant + ((float)(randIntVal) / 4.0f));
00067         } else {
00068             return constant;
00069         }
00070     }
00071 
00072     void TimerGenerator::printAttrs() const {
00073         std::cout << "Numeric Generator:\n";
00074         std::cout << "Constant: " << constant << std::endl;
00075         std::cout << "Upper bound: " << moduloDivisor << std::endl;
00076         std::cout << "Performing random numeric selection: " << (moduloDivisor >= 2 ? "yes" : "no") << std::endl;
00077     }
00078     */
00079 }

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