示例#1
0
static int   do_reset(int argc, const char* const* argv)
{
	console_printf("Reverting to default env..");
	env_reset();
	console_printf(".DONE!\n");
	return 0;
}
示例#2
0
static struct closure *compile_code(struct global_state *gstate, clist b)
{
  struct code *cc;
  u8 nb_locals;
  fncode top;
  location topl;
  struct string *afilename;

  /* Code strings must be allocated before code (immutability restriction) */
  afilename = make_filename(lexloc.filename);
  GCPRO1(afilename);

  erred = FALSE;
  env_reset();
  topl.filename = NULL;
  topl.lineno = 0;
  top = new_fncode(gstate, topl, TRUE, 0);
  env_push(NULL, top);		/* Environment must not be totally empty */
  generate_clist(b, FALSE, top);
  ins0(OPmreturn, top);
  env_pop(&nb_locals);
  cc = generate_fncode(top, nb_locals, NULL, NULL, afilename, 0);
  delete_fncode(top);

  GCPOP(1);

  if (erred) return NULL;
  else return alloc_closure0(cc);
}
示例#3
0
void env_init(uint32_t flashaddr, uint32_t envsize)
{
	current_env = os_malloc(envsize);
	current_env_flash_addr = flashaddr;
	current_env_size=envsize - sizeof(struct environment);
#if defined(CONFIG_ENABLE_BANNER)
	console_printf("env: Environment @ %p size %d bytes (%d real) \n", 
		       (void*)flashaddr, (int)envsize, (int)current_env_size);
#endif
	spi_flash_read(flashaddr, (uint32*)current_env, envsize);
	uint16_t crc = crc16((const unsigned char*)&current_env->occupied, envsize - sizeof(uint16_t));
	if ((current_env->occupied == 0) || (crc != current_env->crc)) { 
		console_printf("env: Bad CRC (%x vs %x) using defaults\n", crc, current_env->crc);
		env_reset();
	}
#if defined(CONFIG_ENABLE_BANNER)
	env_dump();
#endif
}
示例#4
0
void SimulationLoop()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	test->SetTextLine(30);
	settings.hz = settingsHz;
////////////////////////////////////////////////////////////////////////////////////////////
	if(start==0){
		last_state_main = env_start();
		last_action_main = agent_start(last_state_main);
		start = 1;
	}else{
		env_step1(last_action_main);
		test->Step(&settings);
		ro_main=env_step2();
		
		if(ro_main->terminal == 1){
			agent_end(ro_main->reward);
			start = 0;
			env_reset();
			if(ro_main->reward==100){
				success++;
				printf("success %d\tfail %d\tprob %lf\n",success,fail,(double)success/(double)(success+fail)*100);
			}else{
				fail++;
			}
			//test->Step(&settings);
		}else{
			last_action_main = agent_step(ro_main->reward, ro_main->observation);
		}

	}
////////////////////////////////////////////////////////////////////////////////////////////
	/*test->Step(&settings);*/
////////////////////////////////////////////////////////////////////////////////////////////
	/*ro = env_step2();
	this_reward = ro->reward;
	last_state = ro->observation;
	roa.reward = ro->reward;
	roa.observation = ro->observation;
	roa.terminal = ro->terminal;*/

	
////////////////////////////////////////////////////////////////////////////////////////////
	test->DrawTitle(5, 15, entry->name);

	glutSwapBuffers();

	if (testSelection != testIndex)
	{
		testIndex = testSelection;
		delete test;
		entry = g_testEntries + testIndex;
		test = entry->createFcn();
		viewZoom = 1.0f;
		viewCenter.Set(0.0f, 20.0f);
		Resize(width, height);
	}
}