Beispiel #1
0
void PuzzleWidget::resetGame()
{
	puzzle_->setState(start_state_);
	current_state_ = cloneState(start_state_);
	started_ = true;
	has_arrived_ = false;
	state_changed_ = false;
	answer_path_ = puzzle_->readPath();
	path_.clear();
	update();
}
DepthFirstStateAction::ResultE
DepthFirstStateAction::apply(NodePtr pRoot)
{
    ResultE result = NewActionTypes::Continue;

    startEvent();

    result = startActors();

    if(result & NewActionTypes::Quit)
        return result;

    _itInitialState = getState  ();
    _itActiveState  = cloneState();

    // gained refs: active, root
    incRefCount(_itActiveState, 2);

    _nodeStack.push_back(NodeStackEntry(pRoot, _itActiveState, 1));

    if((_extendLeaveActors.empty() == true) &&
       (_basicLeaveActors .empty() == true)    )
    {
        result = traverseEnter();
    }
    else
    {
        result = traverseEnterLeave();
    }

    setState(_itInitialState);

    // lost refs: active, current node
    decRefCount(_itActiveState, 2);

    _itActiveState   = _itInitialState;
    _stateClonedFlag = true;

    _nodeStack         .clear();
#ifndef OSG_NEWACTION_STATESLOTINTERFACE
    _stateStore        .clear();
#endif
    _stateRefCountStore.clear();

    if(result & NewActionTypes::Quit)
        return result;

    result = stopActors();

    stopEvent();

    return result;
}
Beispiel #3
0
void PuzzleWidget::startNewGame(const int num, const int initial_distance)
{
	num_ = num;
	num_rows_ = sqrt((float)num_);
	initial_distance_ = initial_distance;
	puzzle_ = new Puzzle(num_, initial_distance_);
	start_state_ = puzzle_->readState();
	current_state_ = cloneState(start_state_);
	started_ = true;
	has_arrived_ = false;
	state_changed_ = false;
	answer_path_ = puzzle_->readPath();
	shortest_path_length_ = answer_path_.size();
	path_.clear();
	update();
}
Beispiel #4
0
bool ompl::base::SpaceInformation::searchValidNearby(const ValidStateSamplerPtr &sampler, State *state, const State *near, double distance) const
{
    if (state != near)
        copyState(state, near);

    // fix bounds, if needed
    if (!satisfiesBounds(state))
        enforceBounds(state);

    bool result = isValid(state);

    if (!result)
    {
        // try to find a valid state nearby
        State *temp = cloneState(state);
        result = sampler->sampleNear(state, temp, distance);
        freeState(temp);
    }

    return result;
}
void
DepthFirstStateAction::beginEditStateEvent(ActorBase *pActor, UInt32 actorId)
{
    if(_stateClonedFlag == false)
    {
#ifdef OSG_NEWACTION_STATISTICS
        getStatistics()->getElem(statStateClones)->inc();
#endif /* OSG_NEWACTION_STATISTICS */

        _stateClonedFlag = true;

        StateRefCountStoreIt itClonedState = cloneState();

        // gained refs: active and current node
        incRefCount(itClonedState, 2);

        // lost refs: active and current node
        decRefCount(_itActiveState, 2);

        _nodeStack.back().setStateRefCount(itClonedState);

        _itActiveState = itClonedState;
    }
}
/** Save/restore the environment state. */
void StellaEnvironment::save() {
    // Store the current state into a new object
    ALEState new_state = cloneState();
    m_saved_states.push(new_state);
}