コード例 #1
0
//--------------------------------------
void ofShowCursor(){
	mainLoop()->getCurrentWindow()->showCursor();
}
コード例 #2
0
HGLRC ofGetWGLContext(){
	return mainLoop()->getCurrentWindow()->getWGLContext();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: gitter-badger/AIXI
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;
}
コード例 #4
0
EGLContext ofGetEGLContext(){
	return mainLoop()->getCurrentWindow()->getEGLContext();
}
コード例 #5
0
void * ofGetNSGLContext(){
	return mainLoop()->getCurrentWindow()->getNSGLContext();
}
コード例 #6
0
//--------------------------------------
void ofSetVerticalSync(bool bSync){
	mainLoop()->getCurrentWindow()->setVerticalSync(bSync);
}
コード例 #7
0
Window  ofGetX11Window(){
	return mainLoop()->getCurrentWindow()->getX11Window();
}
コード例 #8
0
//--------------------------------------------------
int ofGetHeight(){
	return (int)mainLoop()->getCurrentWindow()->getHeight();
}
コード例 #9
0
//--------------------------------------------------
int ofGetWindowWidth(){
	return (int)mainLoop()->getCurrentWindow()->getWindowSize().x;
}
コード例 #10
0
//--------------------------------------
int ofGetWindowPositionY(){
	return (int)mainLoop()->getCurrentWindow()->getWindowPosition().y;
}
コード例 #11
0
//--------------------------------------------------
int ofGetWidth(){
	return (int)mainLoop()->getCurrentWindow()->getWidth();
}
コード例 #12
0
//--------------------------------------
void ofSetWindowShape(int width, int height){
	mainLoop()->getCurrentWindow()->setWindowShape(width, height);
}
コード例 #13
0
//--------------------------------------
void ofSetWindowPosition(int x, int y){
	mainLoop()->getCurrentWindow()->setWindowPosition(x,y);
}
コード例 #14
0
//--------------------------------------
ofOrientation ofGetOrientation(){
	return mainLoop()->getCurrentWindow()->getOrientation();
}
コード例 #15
0
//--------------------------------------
void ofSetFullscreen(bool fullscreen){
	mainLoop()->getCurrentWindow()->setFullscreen(fullscreen);
}
コード例 #16
0
//--------------------------------------------------
int ofGetWindowHeight(){
	return (int)mainLoop()->getCurrentWindow()->getWindowSize().y;
}
コード例 #17
0
//--------------------------------------
int ofGetWindowMode(){
	return mainLoop()->getCurrentWindow()->getWindowMode();
}
コード例 #18
0
//--------------------------------------------------
bool ofDoesHWOrientation(){
	return mainLoop()->getCurrentWindow()->doesHWOrientation();
}
コード例 #19
0
Display* ofGetX11Display(){
	return mainLoop()->getCurrentWindow()->getX11Display();
}
コード例 #20
0
//--------------------------------------------------
ofPoint	ofGetWindowSize() {
	//this can't be return ofPoint(ofGetWidth(), ofGetHeight()) as width and height change based on orientation.
	return mainLoop()->getCurrentWindow()->getWindowSize();
}
コード例 #21
0
EGLDisplay ofGetEGLDisplay(){
	return mainLoop()->getCurrentWindow()->getEGLDisplay();
}
コード例 #22
0
//--------------------------------------
void ofSetWindowTitle(string title){
	mainLoop()->getCurrentWindow()->setWindowTitle(title);
}
コード例 #23
0
EGLSurface ofGetEGLSurface(){
	return mainLoop()->getCurrentWindow()->getEGLSurface();
}
コード例 #24
0
//----------------------------------------------------------
void ofEnableSetupScreen(){
	mainLoop()->getCurrentWindow()->enableSetupScreen();
}
コード例 #25
0
void * ofGetCocoaWindow(){
	return mainLoop()->getCurrentWindow()->getCocoaWindow();
}
コード例 #26
0
//----------------------------------------------------------
void ofDisableSetupScreen(){
	mainLoop()->getCurrentWindow()->disableSetupScreen();
}
コード例 #27
0
HWND ofGetWin32Window(){
	return mainLoop()->getCurrentWindow()->getWin32Window();
}
コード例 #28
0
//--------------------------------------
void ofToggleFullscreen(){
	mainLoop()->getCurrentWindow()->toggleFullscreen();
}
コード例 #29
0
ファイル: LDViewMain.cpp プロジェクト: HazenBabcock/LDView
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
コード例 #30
0
//--------------------------------------
void ofHideCursor(){
	mainLoop()->getCurrentWindow()->hideCursor();
}