Пример #1
0
void CFDE_TxtEdtEngine::SetTextByStream(IFX_Stream* pStream) {
  ResetEngine();
  int32_t nIndex = 0;
  if (pStream && pStream->GetLength()) {
    int32_t nStreamLength = pStream->GetLength();
    FX_BOOL bValid = TRUE;
    if (m_nLimit > 0 && nStreamLength > m_nLimit) {
      bValid = FALSE;
    }
    FX_BOOL bPreIsCR = FALSE;
    if (bValid) {
      uint8_t bom[4];
      int32_t nPos = pStream->GetBOM(bom);
      pStream->Seek(FX_STREAMSEEK_Begin, nPos);
      int32_t nPlateSize = std::min(nStreamLength, m_pTxtBuf->GetChunkSize());
      FX_WCHAR* lpwstr = FX_Alloc(FX_WCHAR, nPlateSize);
      FX_BOOL bEos = false;
      while (!bEos) {
        int32_t nRead = pStream->ReadString(lpwstr, nPlateSize, bEos);
        bPreIsCR = ReplaceParagEnd(lpwstr, nRead, bPreIsCR);
        m_pTxtBuf->Insert(nIndex, lpwstr, nRead);
        nIndex += nRead;
      }
      FX_Free(lpwstr);
    }
  }
  m_pTxtBuf->Insert(nIndex, &m_wLineEnd, 1);
  RebuildParagraphs();
}
Пример #2
0
int NV1SetupGraphicsEngine(int width,int height,int bpp)
{
  graphicsEngineOk=1;

  WaitForIdle();
  /* Possibly enable the hardware engines here. Should already be on though */
 
  DisableFifo();

  EnableFlowThru(); 

  ResetEngine();

  EnableOptimisations();

  InitDMAInstance();

  ClearAndEnableInterrupts();

  ClearOutContext();

  ClearOutHashTables();

  LoadChannelContext();

  SetUpObjects(bpp);

  EnableChannel();

  EnableFifo();

  return graphicsEngineOk;

}
Пример #3
0
// constructor
ASSDrawEngine::ASSDrawEngine( wxWindow *parent, int extraflags )
 : GUI::AGGWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
        wxNO_FULL_REPAINT_ON_RESIZE | extraflags )
{
	pointsys = new PointSystem(1, 0, 0) ;
	refresh_called = false;
	fitviewpoint_hmargin = 10;
	fitviewpoint_vmargin = 10;
	setfitviewpoint = false;
	rgba_shape = agg::rgba(0,0,1);
	color_bg = PixelFormat::AGGType::color_type(255, 255, 255);
	drawcmdset = _T("m n l b s p c _"); //the spaces and underscore are in there for a reason, guess?
	ResetEngine();
}
Пример #4
0
// ----------------------------------------------------------------------
// CRainfall::ConstructL
// 2nd phase constructor
// Initializes a CRainfall object:
//   raindrops are released from within
//   the rectangle (aPosition.iX-aWidth/2, aPosition.iY, aPosition.iX-aWidth/2)
//                 (aPosition.iX+aWidth/2, aPosition.iY, aPosition.iX+aWidth/2).
//   Once their height is < iGroundLevel, they are reset.
// ----------------------------------------------------------------------
//
void CRainfall::ConstructL(GLint aParticlesCount, TVector aPosition,
						   GLfloat aWidth, GLfloat aDepth, GLfloat aGroundLevel)
	{
	CParticleEngine::ConstructL(aParticlesCount, aPosition);

	iWidth = aWidth;
	iDepth = aDepth;
	iGroundLevel = aGroundLevel;

	TTime now;
	now.HomeTime();
	iSeed = now.Int64();

	ResetEngine();
	}
Пример #5
0
void Bench(int depth) {

  POS p[1];
  int pv[MAX_PLY];
  char *test[] = {
    "r1bqkbnr/pp1ppppp/2n5/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq -",
    "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -",
    "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -",
    "4rrk1/pp1n3p/3q2pQ/2p1pb2/2PP4/2P3N1/P2B2PP/4RRK1 b - - 7 19",
    "rq3rk1/ppp2ppp/1bnpb3/3N2B1/3NP3/7P/PPPQ1PP1/2KR3R w - - 7 14",
    "r1bq1r1k/1pp1n1pp/1p1p4/4p2Q/4Pp2/1BNP4/PPP2PPP/3R1RK1 w - - 2 14",
    "r3r1k1/2p2ppp/p1p1bn2/8/1q2P3/2NPQN2/PPP3PP/R4RK1 b - - 2 15",
    "r1bbk1nr/pp3p1p/2n5/1N4p1/2Np1B2/8/PPP2PPP/2KR1B1R w kq - 0 13",
    "r1bq1rk1/ppp1nppp/4n3/3p3Q/3P4/1BP1B3/PP1N2PP/R4RK1 w - - 1 16",
    "4r1k1/r1q2ppp/ppp2n2/4P3/5Rb1/1N1BQ3/PPP3PP/R5K1 w - - 1 17",
    "2rqkb1r/ppp2p2/2npb1p1/1N1Nn2p/2P1PP2/8/PP2B1PP/R1BQK2R b KQ - 0 11",
    "r1bq1r1k/b1p1npp1/p2p3p/1p6/3PP3/1B2NN2/PP3PPP/R2Q1RK1 w - - 1 16",
    "3r1rk1/p5pp/bpp1pp2/8/q1PP1P2/b3P3/P2NQRPP/1R2B1K1 b - - 6 22",
    "r1q2rk1/2p1bppp/2Pp4/p6b/Q1PNp3/4B3/PP1R1PPP/2K4R w - - 2 18",
    "4k2r/1pb2ppp/1p2p3/1R1p4/3P4/2r1PN2/P4PPP/1R4K1 b - - 3 22",
    "3q2k1/pb3p1p/4pbp1/2r5/PpN2N2/1P2P2P/5PP1/Q2R2K1 b - - 4 26",
    NULL
  }; // test positions taken from DiscoCheck by Lucas Braesch

  if (depth == 0) depth = 8; // so that you can call bench without parameters

  printf("Bench test started (depth %d): \n", depth);

  ResetEngine();
  nodes = 0;
  verbose = 0;
  Timer.SetData(MAX_DEPTH, depth);
  Timer.SetData(FLAG_INFINITE, 1);
  Timer.SetStartTime();

  for (int i = 0; test[i]; ++i) {
    printf(test[i]);
    SetPosition(p, test[i]);
    printf("\n");
    Iterate(p, pv);
  }

  int end_time = Timer.GetElapsedTime();
  int nps = (nodes * 1000) / (end_time + 1);

  printf("%llu nodes searched in %d, speed %u nps (Score: %.3f)\n", nodes, end_time, nps, (float)nps / 430914.0);
}
Пример #6
0
void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
  ResetEngine();
  int32_t nLength = wsText.GetLength();
  if (nLength > 0) {
    CFX_WideString wsTemp;
    FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength);
    FXSYS_memcpy(lpBuffer, wsText.c_str(), nLength * sizeof(FX_WCHAR));
    ReplaceParagEnd(lpBuffer, nLength, FALSE);
    wsTemp.ReleaseBuffer(nLength);
    if (m_nLimit > 0 && nLength > m_nLimit) {
      wsTemp.Delete(m_nLimit, nLength - m_nLimit);
      nLength = m_nLimit;
    }
    m_pTxtBuf->SetText(wsTemp);
  }
  m_pTxtBuf->Insert(nLength, &m_wLineEnd, 1);
  RebuildParagraphs();
}
Пример #7
0
void SetWeight(int weight_name, int value) {

  weights[weight_name] = value;
  ResetEngine();
}
Пример #8
0
void ParseSetoption(char *ptr) {

  char token[180], name[180], value[180] = "";

  ptr = ParseToken(ptr, token);
  name[0] = '\0';
  for (;;) {
    ptr = ParseToken(ptr, token);
    if (*token == '\0' || strcmp(token, "value") == 0)
      break;
    strcat(name, token);
    strcat(name, " ");
  }
  name[strlen(name) - 1] = '\0';
  if (strcmp(token, "value") == 0) {
    value[0] = '\0';

    for (;;) {
      ptr = ParseToken(ptr, token);
      if (*token == '\0')
        break;
      strcat(value, token);
      strcat(value, " ");
    }
    value[strlen(value) - 1] = '\0';
  }

  if (strcmp(name, "Hash") == 0) {
    AllocTrans(atoi(value));
  } else if (strcmp(name, "Clear Hash") == 0 || strcmp(name, "clear hash") == 0) {
    ResetEngine();
  } else if (strcmp(name, "Material") == 0 || strcmp(name, "material") == 0) {
    Param.mat_perc = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "PiecePlacement") == 0 || strcmp(name, "pieceplacement") == 0) {
    Param.pst_perc = (pst_default_perc[Param.pst_style] * atoi(value)) / 100; // scaling takes into account internal weight
    Param.DynamicInit();
  } else if (strcmp(name, "PawnValue") == 0   || strcmp(name, "pawnvalue") == 0) {
    Param.pc_value[P] = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "KnightValue") == 0       || strcmp(name, "knightvalue") == 0) {
    Param.pc_value[N] = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "BishopValue") == 0       || strcmp(name, "bishopvalue") == 0) {
    Param.pc_value[B] = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "RookValue") == 0         || strcmp(name, "rookvalue") == 0) {
    Param.pc_value[R] = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "QueenValue") == 0        || strcmp(name, "queenvalue") == 0) {
    Param.pc_value[Q] = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "KeepQueen") == 0         || strcmp(name, "keepqueen") == 0) {
    Param.keep_pc[Q] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "KeepRook") == 0          || strcmp(name, "keeprook") == 0) {
    Param.keep_pc[R] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "KeepBishop") == 0        || strcmp(name, "keepbishop") == 0) {
    Param.keep_pc[B] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "KeepKnight") == 0        || strcmp(name, "keepknight") == 0) {
    Param.keep_pc[N] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "KeepPawn") == 0          || strcmp(name, "keeppawn") == 0) {
    Param.keep_pc[P] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "KnightLikesClosed") == 0 || strcmp(name, "knightlikesclosed") == 0) {
    Param.np_bonus = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "RookLikesOpen") == 0     || strcmp(name, "rooklikesopen") == 0) {
    Param.rp_malus = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "OwnAttack") == 0         || strcmp(name, "ownattack") == 0) {
    dyn_weights[DF_OWN_ATT] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "OppAttack") == 0         || strcmp(name, "oppattack") == 0) {
    dyn_weights[DF_OPP_ATT] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "OwnMobility") == 0       || strcmp(name, "ownmobility") == 0) {
    dyn_weights[DF_OWN_MOB] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "OppMobility") == 0       || strcmp(name, "oppmobility") == 0) {
    dyn_weights[DF_OPP_MOB] = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "KingTropism") == 0       || strcmp(name, "kingtropism") == 0) {
    SetWeight(F_TROPISM, atoi(value));
  } else if (strcmp(name, "PiecePressure") == 0     || strcmp(name, "piecepressure") == 0) {
    SetWeight(F_PRESSURE, atoi(value));
  } else if (strcmp(name, "PassedPawns") == 0       || strcmp(name, "passedpawns") == 0) {
    SetWeight(F_PASSERS, atoi(value));
  } else if (strcmp(name, "PawnStructure") == 0     || strcmp(name, "pawnstructure") == 0) {
    SetWeight(F_PAWNS, atoi(value));
  } else if (strcmp(name, "Lines") == 0             || strcmp(name, "lines") == 0) {
   SetWeight(F_LINES, atoi(value));
  } else if (strcmp(name, "Outposts") == 0          || strcmp(name, "outposts") == 0) {
    SetWeight(F_OUTPOST, atoi(value));
  } else if (strcmp(name, "PstStyle") == 0          || strcmp(name, "pststyle") == 0) {
    Param.pst_style = atoi(value);
    Param.DynamicInit();
 } else if (strcmp(name, "MobilityStyle") == 0      || strcmp(name, "mobilitystyle") == 0) {
    Param.mob_style = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "ExchangeImbalance") == 0 || strcmp(name, "exchangeimbalance") == 0) {
    Param.exchange_imbalance = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "BishopPair") == 0        || strcmp(name, "bishoppair") == 0) {
    Param.bish_pair = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "DoubledPawnMg") == 0     || strcmp(name, "doubledpawnmg") == 0) {
    Param.doubled_malus_mg = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "DoubledPawnEg") == 0     || strcmp(name, "doubledpawneg") == 0) {
    Param.doubled_malus_eg = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "IsolatedPawnMg") == 0    || strcmp(name, "isolatedpawnmg") == 0) {
    Param.isolated_malus_mg = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "IsolatedPawnEg") == 0    || strcmp(name, "isolatedpawneg") == 0) {
    Param.isolated_malus_eg = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "IsolatedOnOpenMg") == 0  || strcmp(name, "isolatedonopenmg") == 0) {
    Param.isolated_open_malus = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "BackwardPawnMg") == 0    || strcmp(name, "backwardpawnmg") == 0) {
    Param.backward_malus_base = atoi(value);
    Param.DynamicInit();
  } else if (strcmp(name, "BackwardPawnEg") == 0    || strcmp(name, "backwardpawneg") == 0) {
    Param.backward_malus_eg = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "BackwardOnOpenMg") == 0  || strcmp(name, "backwardonopenmg") == 0) {
    Param.backward_open_malus = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "PawnShield") == 0        || strcmp(name, "pawnshield") == 0) {
    Param.shield_perc = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "PawnStorm") == 0         || strcmp(name, "pawnstorm") == 0) {
    Param.storm_perc = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "NpsLimit") == 0          || strcmp(name, "npslimit") == 0) {
    Timer.nps_limit = atoi(value);
    ResetEngine();
    if (Timer.nps_limit != 0) Param.fl_weakening = 1;
  } else if (strcmp(name, "EvalBlur") == 0          || strcmp(name, "evalblur") == 0) {
    Param.eval_blur = atoi(value);
    ResetEngine();
    if (Param.eval_blur != 0) Param.fl_weakening = 1;
  } else if (strcmp(name, "Contempt") == 0          || strcmp(name, "contempt") == 0) {
    Param.draw_score = atoi(value);
    ResetEngine();
  } else if (strcmp(name, "SlowMover") == 0         || strcmp(name, "slowmover") == 0) {
    time_percentage = atoi(value);
  } else if (strcmp(name, "UCI_Elo") == 0           || strcmp(name, "uci_elo") == 0) {
    Param.elo = atoi(value);
    Timer.SetSpeed(Param.elo);
  } else if (strcmp(name, "Selectivity") == 0       || strcmp(name, "selectivity") == 0) {
    hist_perc = atoi(value);
    hist_limit = -HIST_LIMIT + ((HIST_LIMIT * hist_perc) / 100);
  } else if (strcmp(name, "GuideBookFile") == 0     || strcmp(name, "guidebookfile") == 0) {
    if (!fl_separate_books || !fl_reading_personality) {
      GuideBook.ClosePolyglot();
      GuideBook.bookName = value;
      GuideBook.OpenPolyglot();
    }
  } else if (strcmp(name, "MainBookFile") == 0      || strcmp(name, "mainbookfile") == 0) {
    if (!fl_separate_books || !fl_reading_personality) {
      MainBook.ClosePolyglot();
      MainBook.bookName = value;
      MainBook.OpenPolyglot();
    }
  } else if (strcmp(name, "PersonalityFile") == 0   || strcmp(name, "personalityfile") == 0) {
    printf("info string reading ");
    printf(value);
    printf("\n");
    ReadPersonality(value);
  } else if (strcmp(name, "BookFilter") == 0        || strcmp(name, "bookfilter") == 0) {
    Param.book_filter = atoi(value);
  }
}
bool CCheckpointSystem::LoadGame(const char* fileName)
{
	//make sure not not save/load recursively or multiple times at once
	if(CHECKPOINT_SAVE_XML_NODE || CHECKPOINT_LOAD_XML_NODE)
		return false;

	//set extension
	FixedCheckpointString file(fileName);
	SetFilenameExtension(file);

	CHECKPOINT_LOAD_XML_NODE = ReadXML(file.c_str());
	if(!CHECKPOINT_LOAD_XML_NODE)
		return false;

	CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_COMMENT, "Loading checkpoint %s", file.c_str());

	//check for EntityId errors
	CHECKPOINT_RESAVE_NECESSARY = false;

	//process meta data
	SCheckpointData metaData;
	if(!ReadMetaData(CHECKPOINT_LOAD_XML_NODE, metaData))
		return false;

	//check version number
	if(metaData.m_versionNumber != CHECKPOINT_VERSION_NUMBER)
	{
		CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Checkpoint version number (%i) does not match current version (%i). Please reexport all checkpoints of this level to prevent errors!", metaData.m_versionNumber, CHECKPOINT_VERSION_NUMBER);
	}
 
	//check for level mismatch
	CryFixedStringT<32> curlevelName = CCryAction::GetCryAction()->GetLevelName();
	RepairLevelName(curlevelName);
	if(curlevelName.empty() || stricmp(metaData.m_levelName.c_str(), curlevelName.c_str()))
	{
		if(!LoadCheckpointMap(metaData, curlevelName))
			return false;
	}
	else
	{
		//reset the dynamic parts of the engine
		ResetEngine();
	}

	//read actor data and respawn AI
	// TODO For now, not restoring actor info (AI) - If this happens later, support needs to be added for entity pools
	//RespawnAI(CHECKPOINT_LOAD_XML_NODE);

	//load gametokens again
	ReadGameTokens(CHECKPOINT_LOAD_XML_NODE);

	//let game read
	if (m_pGameHandler)
	{
		m_pGameHandler->OnReadData(CHECKPOINT_LOAD_XML_NODE);
	}

	//resets some gameplay data like action filters etc.
	RestartGameplay();

	//load external entities, that are controlled by flowgraph
	LoadExternalEntities(CHECKPOINT_LOAD_XML_NODE);

	//inform listeners
	UpdateListener(metaData, false);

	//trigger flowgraph node
	OnCheckpointLoaded(metaData);

	//draw text message on screen
	//static const ColorF color (0.0f, 0.85f, 0.2f, 1.0f);
	//g_pGame->GetIGameFramework()->GetIPersistantDebug()->Add2DText("Checkpoint loaded", 2.5f, color, 2.0f);

	//checkpoint file sanity check
	if(CHECKPOINT_RESAVE_NECESSARY)
	{
		CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Checkpoint file contained obsolete or wrong data, trying to re-save checkpoint.");
		//resave checkpoint to fix changed entity Ids
		SaveGame(metaData.m_checkPointId, fileName);
		//make sure the script entity is aware of the activity
		OnCheckpointLoaded(metaData);
	}

	CHECKPOINT_LOAD_XML_NODE = NULL;

	//when a checkpoint was loaded, it becomes the most recent checkpoint
	g_lastSavedCheckpoint = fileName;

	//make sure the scripts are clean
	//CXP : this caused a crash after some reloads, which hints to problems in the gamerules script
	//gEnv->pScriptSystem->ForceGarbageCollection();

	return true;
}
Пример #10
0
// reset; delete all points and add a new M(0,0)
void ASSDrawEngine::ResetEngine()
{
     ResetEngine(true);
}
Пример #11
0
// parse ASS draw commands; returns the number of parsed commands
int ASSDrawEngine::ParseASS ( wxString str )
{
	ResetEngine( false );
	str.Replace(_T("\t"), _T(""));
	str.Replace(_T("\r"), _T(""));
	str.Replace(_T("\n"), _T(""));
	str = str.Lower() + _T(" _ _");
	// we don't use regex because the pattern is too simple
	wxStringTokenizer tkz( str, _T(" ") );
	wxString currcmd(_T(""));
	std::vector<int> val;
	wxString token;
	long tmp_int;
	
	bool n_collected = false;
	DrawCmd_S *s_command = NULL;
	wxPoint tmp_n_pnt;
	
	while ( tkz.HasMoreTokens() )
	{
		token = tkz.GetNextToken();
		
		if ( drawcmdset.Find(token) > -1 )
		{
			bool done;
			
			do {
				done = true;
				
				// N
				if (currcmd.IsSameAs(_T("n")) && val.size() >= 2)
				{
					tmp_n_pnt.x = val[0], tmp_n_pnt.y = val[1];
					n_collected = true;
				}
				else if(n_collected)
				{
					AppendCmd ( L, tmp_n_pnt.x, tmp_n_pnt.y );
					n_collected = false;
				}
				
				if (s_command != NULL)
				{
					bool ends = true;
					if (currcmd.IsSameAs(_T("p"))&& val.size() >= 2)
					{
						s_command->m_point->type = CP;
						s_command->m_point->num = s_command->controlpoints.size() + 1;
						s_command->controlpoints.push_back(s_command->m_point);
						s_command->m_point = new Point(val[0], val[1], pointsys, MP, s_command);
						ends = false;
					}
					else if (currcmd.IsSameAs(_T("c")))
						s_command->closed = true;

					if (ends)
					{
						AppendCmd(s_command);
						s_command = NULL;	
					}
				}
				
				// M
				if (currcmd.IsSameAs(_T("m")) && val.size() >= 2)
					AppendCmd ( M, val[0], val[1] );
				
				// L
				if (currcmd.IsSameAs(_T("l")) && val.size() >= 2)
				{
					AppendCmd ( L, val[0], val[1] );
					val.erase(val.begin(), val.begin()+2);
					// L is greedy
					if (val.size() >= 2)
						done = false;
				}
				
				// B
				if (currcmd.IsSameAs(_T("b")) && val.size() >= 6)
				{
					AppendCmd ( new DrawCmd_B(val[4], val[5], val[0], val[1],
					val[2], val[3], pointsys, LastCmd()) );
					val.erase(val.begin(), val.begin()+6);
					// so is B
					if (val.size() >= 6)
						done = false;
				}
				
				// S
				if (currcmd.IsSameAs(_T("s")) && val.size() >= 6)
				{
					int num = (val.size() / 2) * 2;
					std::vector<int> val2;
					int i = 0;
					for (; i < num - 2; i++)
						val2.push_back(val[i]);

					s_command = new DrawCmd_S(val[num - 2], val[num - 1], val2, pointsys, LastCmd());
				}
				// more to come later
			} while (!done);
			
			val.clear();
			currcmd = token;
		}
		else if (token.ToLong( &tmp_int ))
		{
			val.push_back( (int) tmp_int );
		}	
	}
	
	return (int) cmds.size();
}
Пример #12
0
ASSDrawEngine::~ASSDrawEngine()
{
    ResetEngine ( false );
    //delete pointsys;
}
Пример #13
0
void cParam::DynamicInit(void) {

  Eval.prog_side = NO_CL;
  ResetEngine();

  // Init piece/square values together with material value of the pieces.

  for (int sq = 0; sq < 64; sq++) {
    for (int sd = 0; sd < 2; sd++) {
 
      mg_pst[sd][P][REL_SQ(sq, sd)] = SCALE(pc_value[P], mat_perc) + SCALE(pstPawnMg[pst_style][sq], pst_perc);
      eg_pst[sd][P][REL_SQ(sq, sd)] = SCALE(pc_value[P], mat_perc) + SCALE(pstPawnEg[pst_style][sq], pst_perc);
      mg_pst[sd][N][REL_SQ(sq, sd)] = SCALE(pc_value[N], mat_perc) + SCALE(pstKnightMg[pst_style][sq], pst_perc);
      eg_pst[sd][N][REL_SQ(sq, sd)] = SCALE(pc_value[N], mat_perc) + SCALE(pstKnightEg[pst_style][sq], pst_perc);
      mg_pst[sd][B][REL_SQ(sq, sd)] = SCALE(pc_value[B], mat_perc) + SCALE(pstBishopMg[pst_style][sq], pst_perc);
      eg_pst[sd][B][REL_SQ(sq, sd)] = SCALE(pc_value[B], mat_perc) + SCALE(pstBishopEg[pst_style][sq], pst_perc);
      mg_pst[sd][R][REL_SQ(sq, sd)] = SCALE(pc_value[R], mat_perc) + SCALE(pstRookMg[pst_style][sq], pst_perc);
      eg_pst[sd][R][REL_SQ(sq, sd)] = SCALE(pc_value[R], mat_perc) + SCALE(pstRookEg[pst_style][sq], pst_perc);
      mg_pst[sd][Q][REL_SQ(sq, sd)] = SCALE(pc_value[Q], mat_perc) + SCALE(pstQueenMg[pst_style][sq], pst_perc);
      eg_pst[sd][Q][REL_SQ(sq, sd)] = SCALE(pc_value[Q], mat_perc) + SCALE(pstQueenEg[pst_style][sq], pst_perc);
      mg_pst[sd][K][REL_SQ(sq, sd)] = pstKingMg[pst_style][sq];
      eg_pst[sd][K][REL_SQ(sq, sd)] = pstKingEg[pst_style][sq];

      phalanx[sd][REL_SQ(sq, sd)] = pstPhalanxPawn[sq];
      defended[sd][REL_SQ(sq, sd)] = pstDefendedPawn[sq];

      sp_pst_data[sd][N][REL_SQ(sq, sd)] = pstKnightOutpost[sq];
      sp_pst_data[sd][B][REL_SQ(sq, sd)] = pstBishopOutpost[sq];
    }
  }

  // Init tables for adjusting piece values 
  // according to the number of own pawns

  for (int i = 0; i < 9; i++) {
    np_table[i] = adj[i] * np_bonus;
    rp_table[i] = adj[i] * rp_malus;
  }

  // Init backward pawns table, adding file offset to base value

  for (int i = 0; i < 8; i++) {
    backward_malus_mg[i] = backward_malus_base + file_adj[i];
  }

  // Init imbalance table, so that we can expose option for exchange delta

  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {

      // insert original values
      imbalance[i][j] = imbalance_data[i][j];

      // insert value defined by the user
      if (imbalance[i][j] == Ex) imbalance[i][j] = exchange_imbalance;
      if (imbalance[i][j] == -Ex) imbalance[i][j] = -exchange_imbalance;
    }
  }

  // Init mobility tables

  if (mob_style == 0) {
    for (int i = 0; i < 9; i++) {
      n_mob_mg[i] = 4 * (i-4);
      n_mob_eg[i] = 4 * (i-4);
    }

    for (int i = 0; i < 14; i++) {
      b_mob_mg[i] = 5 * (i-7);
      b_mob_eg[i] = 5 * (i-7);
    }

    for (int i = 0; i < 15; i++) {
      r_mob_mg[i] = 2 * (i-7);
      r_mob_eg[i] = 4 * (i-7);
    }

    for (int i = 0; i < 28; i++) {
      q_mob_mg[i] = 1 * (i-14);
      q_mob_eg[i] = 2 * (i-14);
    }

  }

  if (mob_style == 1) {
    for (int i = 0; i < 9; i++) {
      n_mob_mg[i] = n_mob_mg_decreasing[i];
      n_mob_eg[i] = n_mob_eg_decreasing[i];
    }

    for (int i = 0; i < 14; i++) {
      b_mob_mg[i] = b_mob_mg_decreasing[i];
      b_mob_eg[i] = b_mob_eg_decreasing[i];
    }

    for (int i = 0; i < 15; i++) {
      r_mob_mg[i] = r_mob_mg_decreasing[i];
      r_mob_eg[i] = r_mob_eg_decreasing[i];
    }

    for (int i = 0; i < 28; i++) {
      q_mob_mg[i] = q_mob_mg_decreasing[i];
      q_mob_eg[i] = q_mob_eg_decreasing[i];
    }

  }

  // Init king attack table

  for (int t = 0, i = 1; i < 512; ++i) {
    t = Min(maxAttScore, Min(int(attCurveMult * i * i), t + maxAttStep));
    danger[i] = (t * 100) / 256; // rescale to centipawns
    // TODO: init separately for Black and White in SetAsymmetricEval() to gain some speed
  }
}