//-------------------------------------- void ofShowCursor(){ mainLoop()->getCurrentWindow()->showCursor(); }
HGLRC ofGetWGLContext(){ return mainLoop()->getCurrentWindow()->getWGLContext(); }
int main(int argc, char *argv[]) { if (argc < 2 || argc > 3) { std::cerr << "ERROR: Incorrect number of arguments" << std::endl; std::cerr << "The first argument should indicate the location of the configuration file and the second (optional) argument should indicate the file to log to." << std::endl; return -1; } // Set up logging std::string log_file = argc < 3 ? "log" : argv[2]; log.open((log_file + ".log").c_str()); compactLog.open((log_file + ".csv").c_str()); // Print header to compactLog compactLog << "cycle, observation, reward, action, explored, explore_rate, total reward, average reward" << std::endl; // Load configuration options options_t options; // Default configuration values options["ct-depth"] = "3"; options["agent-horizon"] = "16"; options["exploration"] = "0"; // do not explore options["explore-decay"] = "1.0"; // exploration rate does not decay // Read configuration options std::ifstream conf(argv[1]); if (!conf.is_open()) { std::cerr << "ERROR: Could not open file '" << argv[1] << "' now exiting" << std::endl; return -1; } processOptions(conf, options); conf.close(); // Set up the environment Environment *env; // TODO: instantiate the environment based on the "environment-name" // option. For any environment you do not implement you may delete the // corresponding if statement. // NOTE: you may modify the options map in order to set quantities such as // the reward-bits for each particular environment. See the coin-flip // experiment for an example. std::string environment_name = options["environment"]; if (environment_name == "coin-flip") { env = new CoinFlip(options); options["agent-actions"] = "2"; options["observation-bits"] = "1"; options["reward-bits"] = "1"; } else if (environment_name == "1d-maze") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "cheese-maze") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "tiger") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "extended-tiger") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "4x4-grid") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "tictactoe") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "biased-rock-paper-scissor") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "kuhn-poker") { // TODO: instantiate "env" (if appropriate) } else if (environment_name == "pacman") { // TODO: instantiate "env" (if appropriate) } else { std::cerr << "ERROR: unknown environment '" << environment_name << "'" << std::endl; return -1; } // Set up the agent Agent ai(options); // Run the main agent/environment interaction loop mainLoop(ai, *env, options); log.close(); compactLog.close(); return 0; }
EGLContext ofGetEGLContext(){ return mainLoop()->getCurrentWindow()->getEGLContext(); }
void * ofGetNSGLContext(){ return mainLoop()->getCurrentWindow()->getNSGLContext(); }
//-------------------------------------- void ofSetVerticalSync(bool bSync){ mainLoop()->getCurrentWindow()->setVerticalSync(bSync); }
Window ofGetX11Window(){ return mainLoop()->getCurrentWindow()->getX11Window(); }
//-------------------------------------------------- int ofGetHeight(){ return (int)mainLoop()->getCurrentWindow()->getHeight(); }
//-------------------------------------------------- int ofGetWindowWidth(){ return (int)mainLoop()->getCurrentWindow()->getWindowSize().x; }
//-------------------------------------- int ofGetWindowPositionY(){ return (int)mainLoop()->getCurrentWindow()->getWindowPosition().y; }
//-------------------------------------------------- int ofGetWidth(){ return (int)mainLoop()->getCurrentWindow()->getWidth(); }
//-------------------------------------- void ofSetWindowShape(int width, int height){ mainLoop()->getCurrentWindow()->setWindowShape(width, height); }
//-------------------------------------- void ofSetWindowPosition(int x, int y){ mainLoop()->getCurrentWindow()->setWindowPosition(x,y); }
//-------------------------------------- ofOrientation ofGetOrientation(){ return mainLoop()->getCurrentWindow()->getOrientation(); }
//-------------------------------------- void ofSetFullscreen(bool fullscreen){ mainLoop()->getCurrentWindow()->setFullscreen(fullscreen); }
//-------------------------------------------------- int ofGetWindowHeight(){ return (int)mainLoop()->getCurrentWindow()->getWindowSize().y; }
//-------------------------------------- int ofGetWindowMode(){ return mainLoop()->getCurrentWindow()->getWindowMode(); }
//-------------------------------------------------- bool ofDoesHWOrientation(){ return mainLoop()->getCurrentWindow()->doesHWOrientation(); }
Display* ofGetX11Display(){ return mainLoop()->getCurrentWindow()->getX11Display(); }
//-------------------------------------------------- ofPoint ofGetWindowSize() { //this can't be return ofPoint(ofGetWidth(), ofGetHeight()) as width and height change based on orientation. return mainLoop()->getCurrentWindow()->getWindowSize(); }
EGLDisplay ofGetEGLDisplay(){ return mainLoop()->getCurrentWindow()->getEGLDisplay(); }
//-------------------------------------- void ofSetWindowTitle(string title){ mainLoop()->getCurrentWindow()->setWindowTitle(title); }
EGLSurface ofGetEGLSurface(){ return mainLoop()->getCurrentWindow()->getEGLSurface(); }
//---------------------------------------------------------- void ofEnableSetupScreen(){ mainLoop()->getCurrentWindow()->enableSetupScreen(); }
void * ofGetCocoaWindow(){ return mainLoop()->getCurrentWindow()->getCocoaWindow(); }
//---------------------------------------------------------- void ofDisableSetupScreen(){ mainLoop()->getCurrentWindow()->disableSetupScreen(); }
HWND ofGetWin32Window(){ return mainLoop()->getCurrentWindow()->getWin32Window(); }
//-------------------------------------- void ofToggleFullscreen(){ mainLoop()->getCurrentWindow()->toggleFullscreen(); }
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nCmdShow) { ModelLoader* modelLoader; bool screenSaver = isScreenSaver(); int retValue; STARTUPINFO startupInfo; bool fromConsole = false; //HMODULE hThumbs = LoadLibrary("LDViewThumbs.dll"); //if (hThumbs != NULL) //{ // PFNDLLREGISTERSERVER pDllRegisterServer = // (PFNDLLREGISTERSERVER)GetProcAddress(hThumbs, "DllRegisterServer"); // CoInitialize(NULL); // if (pDllRegisterServer != NULL) // { // pDllRegisterServer(); // } //} memset(&startupInfo, 0, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); GetStartupInfo(&startupInfo); if (startupInfo.lpTitle != NULL && stringHasCaseInsensitivePrefix(startupInfo.lpTitle, "command line ") && strcasestr(startupInfo.lpTitle, "ldview") != NULL) { runningWithConsole(); fromConsole = true; } #ifdef _DEBUG int _debugFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); _debugFlag |= _CRTDBG_LEAK_CHECK_DF; _CrtSetDbgFlag(_debugFlag); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); if (!fromConsole) { createConsole(); } // MessageBox(NULL, "Attach a debugger now...", "Debug", MB_OK); #endif // _DEBUG bool udok = setupUserDefaults(lpCmdLine, screenSaver, isRemovableDrive(hInstance)); setupLocalStrings(); if (TCUserDefaults::boolForKey(DEBUG_COMMAND_LINE_KEY, false, false)) { std::string message = "Command Line:\n"; message += lpCmdLine; MessageBox(NULL, message.c_str(), "LDView", MB_OK); } if (!udok && !TCUserDefaults::longForKey("IniFailureShown", 0, 0)) { UCCHAR message[2048]; UCSTR iniPath = mbstoucstring(TCUserDefaults::getIniPath()); sucprintf(message, COUNT_OF(message), TCLocalStrings::get(_UC("IniFailure")), iniPath); CUIWindow::messageBoxUC(NULL, message, _UC("LDView"), MB_OK); delete iniPath; TCUserDefaults::setLongForKey(1, "IniFailureShown", false); } if (screenSaver) { if (strncasecmp(lpCmdLine, "/p", 2) == 0 || strncasecmp(lpCmdLine, "-p", 2) == 0 || strncasecmp(lpCmdLine, "p", 1) == 0) { // preview mode return doPreview(hInstance, lpCmdLine); } if (strncasecmp(lpCmdLine, "/c", 2) == 0 || strncasecmp(lpCmdLine, "-c", 2) == 0 || strncasecmp(lpCmdLine, "c", 1) == 0 || strlen(lpCmdLine) == 0) { SSConfigure *configure; configure = new SSConfigure(hInstance); #ifdef _DEBUG _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); createConsole(); #endif // _DEBUG configure->run(); // configure mode return 1; } // This shouldn't be necessary, but I've received a report of a whole // bunch of copies of the LDView screensaver running at once. This // might not fix things entirely, but it will at least prevent it // from launching multiple times concurrently. CreateMutex(NULL, FALSE, "LDView Screensaver"); if (GetLastError() == ERROR_ALREADY_EXISTS) { return 0; } } #ifdef _LOG_PERFORMANCE LARGE_INTEGER frequency; if (QueryPerformanceFrequency(&frequency)) { debugPrintf("Frequency: %I64d\n", frequency.QuadPart); } #endif // _LOG_PERFORMANCE OleInitialize(NULL); //Win7JumpListStuff(); modelLoader = new ModelLoader(CUIWindow::getLanguageModule(), nCmdShow, screenSaver); retValue = mainLoop(); modelLoader->release(); return retValue; } // WinMain
//-------------------------------------- void ofHideCursor(){ mainLoop()->getCurrentWindow()->hideCursor(); }