Exemplo n.º 1
0
void RegExpCachedResult::setInput(ExecState* exec, JSObject* owner, JSString* input)
{
    // Make sure we're reified, otherwise m_reifiedInput will be ignored.
    lastResult(exec, owner);
    ASSERT(m_reified);
    m_reifiedInput.set(exec->vm(), owner, input);
}
Exemplo n.º 2
0
JSString* RegExpCachedResult::leftContext(ExecState* exec, JSObject* owner)
{
    // Make sure we're reified.
    lastResult(exec, owner);
    if (!m_reifiedLeftContext)
        m_reifiedLeftContext.set(exec->vm(), owner, m_result.start ? jsSubstring(exec, m_reifiedInput.get(), 0, m_result.start) : jsEmptyString(exec));
    return m_reifiedLeftContext.get();
}
Exemplo n.º 3
0
JSString* RegExpCachedResult::rightContext(ExecState* exec, JSObject* owner)
{
    // Make sure we're reified.
    lastResult(exec, owner);
    if (!m_reifiedRightContext) {
        unsigned length = m_reifiedInput->length();
        m_reifiedRightContext.set(exec->vm(), owner, m_result.end != length ? jsSubstring(exec, m_reifiedInput.get(), m_result.end, length - m_result.end) : jsEmptyString(exec));
    }
    return m_reifiedRightContext.get();
}
Exemplo n.º 4
0
pair<TMove, TPoint> CSearchEngine::optimalMove(TBlock board[], const TPos&_p1, const TPos&_p2, const TPlayer next, const vector<TMove> &history)
{
	static CMyAI *pAI = CMyAI::getInstance();
	pair<TMove, TPoint> result;
	pair<TMove, TPoint> lastResult(0, 0);
	int d;
	if (pAI->inEnemyTurn)
		d = pAI->lastReachedDepth > 0 ? pAI->lastReachedDepth - 1 : MIN_DEPTH;
	else
	{
		d = pAI->lastReachedDepth > 0 ? pAI->lastReachedDepth - 2 : MIN_DEPTH;
	}
	cout << "started with d = " << d << endl;
	for (; d <= MAX_DEPTH; d++){
		result = getOptimalMoveByAB(board, _p1, _p2, next, history, d);
		if (result.second == TIMEOUT_POINTS)
		{
			if (pAI->foundAnEnd)
				if (pAI->isCalculatingInEnemyTurn)
					pAI->foundAnEnd = false; // if this is an enemy's turn then in the next turn (our turn, do it normal)
				else 
					d++;// if this is our turn, in the enemy turn, reach to this depth right!
			break;
		}
		else
		{
			TPoint p = abs(result.second);
			if (p > POINTS / 2){
				pAI->foundAnEnd = true;
				if (abs(lastResult.second) <= POINTS / 2)
					d--;
			}
			else {
				pAI->foundAnEnd = false;
			}
			lastResult = result;
			cout << lastResult.second << endl;
		}
	}
	pAI->lastReachedDepth = d - 1;
	if (!pAI->isCalculatingInEnemyTurn)
		cout << "Reached depth = " << pAI->lastReachedDepth << endl;

	CTranspositionTable::getInstance()->printStatic();
	return lastResult;
}