当前位置: 首页>>代码示例>>C++>>正文


C++ HISTORY类代码示例

本文整理汇总了C++中HISTORY的典型用法代码示例。如果您正苦于以下问题:C++ HISTORY类的具体用法?C++ HISTORY怎么用?C++ HISTORY使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HISTORY类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GeneratePreferred

void POCMAN::GeneratePreferred(const STATE& state, const HISTORY& history, 
    vector<int>& actions, const STATUS& status) const
{
    const POCMAN_STATE& pocstate = safe_cast<const POCMAN_STATE&>(state);
    if (history.Size())
    {
        int action = history.Back().Action;
        int observation = history.Back().Observation;

        // If power pill and can see a ghost then chase it
        if (pocstate.PowerSteps > 0 && (observation & 15 != 0))
        {
            for (int a = 0; a < 4; ++a)
                if (CheckFlag(observation, a))
                    actions.push_back(a);
        }
        
        // Otherwise avoid observed ghosts and avoid changing directions
        else
        {
            for (int a = 0; a < 4; ++a)
            {
                COORD newpos = NextPos(pocstate.PocmanPos, a);        
                if (newpos.Valid() && !CheckFlag(observation, a)
                    && COORD::Opposite(a) != action)
                    actions.push_back(a);
            }
        }
    }
}
开发者ID:Illykai,项目名称:pomcpghost,代码行数:30,代码来源:pocman.cpp

示例2: DisplayValue

void QNODE::DisplayValue(HISTORY& history, int maxDepth, ostream& ostr, const double *qvalue) const
{
	history.Display(ostr);
	if (qvalue) {
		ostr << "q=" << *qvalue;
	}

	ImmediateReward.Print(": r=", ostr);
	Observation.Print(", o=", ostr);
	ostr << std::endl;

    for (int observation = 0; observation < NumChildren; observation++)
    {
        if (Children[observation])
        {
        	std::stringstream ss;
        	ss << "\t\t\t#" << observation;
//            Children[observation]->GetCumulativeReward().Print(ss.str().c_str(), ostr);
        }
    }

    if (history.Size() >= maxDepth)
        return;

    for (int observation = 0; observation < NumChildren; observation++)
    {
        if (Children[observation])
        {
            history.Back().Observation = observation;
            Children[observation]->DisplayValue(history, maxDepth, ostr);
        }
    }
}
开发者ID:aijunbai,项目名称:thompson-sampling,代码行数:33,代码来源:node.cpp

示例3: LocalMove

bool ROCKSAMPLE::LocalMove(STATE& state, const HISTORY& history,
    int stepObs, const STATUS& status) const
{
    _unused(status);

    ROCKSAMPLE_STATE& rockstate = safe_cast<ROCKSAMPLE_STATE&>(state);
    int rock = Random(NumRocks);
    rockstate.Rocks[rock].Valuable = !rockstate.Rocks[rock].Valuable;

    if (history.Back().Action > E_SAMPLE) // check rock
    {
        rock = history.Back().Action - E_SAMPLE - 1;
        int realObs = history.Back().Observation;

        // Condition new state on real observation
        int newObs = GetObservation(rockstate, rock);
        if (newObs != realObs)
            return false;

        // Update counts to be consistent with real observation
        if (realObs == E_GOOD && stepObs == E_BAD)
            rockstate.Rocks[rock].Count += 2;
        if (realObs == E_BAD && stepObs == E_GOOD)
            rockstate.Rocks[rock].Count -= 2;
    }
    return true;
}
开发者ID:EHadoux,项目名称:HS3MDP,代码行数:27,代码来源:rocksample.cpp

示例4: historyListWndProc

// ---------------------------------------------------------------------------------
LRESULT APIENTRY historyListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	extern HISTORY history;
	switch(msg)
	{
		case WM_CHAR:
		case WM_KEYDOWN:
		case WM_KEYUP:
		case WM_KILLFOCUS:
			return 0;
		case WM_LBUTTONDOWN:
		case WM_LBUTTONDBLCLK:
		{
			if (GetFocus() != hWnd)
				SetFocus(hWnd);
			// perform hit test
			LVHITTESTINFO info;
			info.pt.x = GET_X_LPARAM(lParam);
			info.pt.y = GET_Y_LPARAM(lParam);
			ListView_SubItemHitTest(hWnd, (LPARAM)&info);
			history.handleSingleClick(info.iItem);
			return 0;
		}
		case WM_MBUTTONDOWN:
		case WM_MBUTTONDBLCLK:
		{
			if (GetFocus() != hWnd)
				SetFocus(hWnd);
			playback.handleMiddleButtonClick();
			return 0;
		}
		case WM_RBUTTONDOWN:
		case WM_RBUTTONDBLCLK:
			if (GetFocus() != hWnd)
				SetFocus(hWnd);
			return 0;
		case WM_MOUSEWHEEL:
		{
			if (!history.isCursorOverHistoryList())
				return SendMessage(pianoRoll.hwndList, msg, wParam, lParam);
			break;
		}
		case WM_MOUSEWHEEL_RESENT:
		{
			// this is message from Piano Roll
			// it means that cursor is currently over History List, and user scrolls the wheel (although focus may be on some other window)
			// ensure that wParam's low-order word is 0 (so fwKeys = 0)
			CallWindowProc(hwndHistoryList_oldWndProc, hWnd, WM_MOUSEWHEEL, wParam & ~(LOWORD(-1)), lParam);
			return 0;
		}
        case WM_MOUSEACTIVATE:
			if (GetFocus() != hWnd)
				SetFocus(hWnd);
            break;

	}
	return CallWindowProc(hwndHistoryList_oldWndProc, hWnd, msg, wParam, lParam);
}
开发者ID:sashavolv2,项目名称:tasbot,代码行数:59,代码来源:history.cpp

示例5: DisplayValue

void VNODE::DisplayValue(HISTORY& history, int maxDepth, ostream& ostr) const
{
    if (history.Size() >= (uint) maxDepth)
        return;

    for (int action = 0; action < NumChildren; action++)
    {
        history.Add(action,-1);
        Children[action].DisplayValue(history, maxDepth, ostr);
        history.Pop();
    }
}
开发者ID:caomw,项目名称:BBRL,代码行数:12,代码来源:node.cpp

示例6: DisplayPolicy

void QNODE::DisplayPolicy(HISTORY& history, int maxDepth, ostream& ostr) const
{
    history.Display(ostr);
    ostr << ": " << Value.GetValue() << " (" << Value.GetCount() << ")\n";
    if (history.Size() >= (uint) maxDepth)
        return;

    for (int observation = 0; observation < NumChildren; observation++)
    {
        if (Children[observation])
        {
            history.Back().Observation = observation;
            Children[observation]->DisplayPolicy(history, maxDepth, ostr);
        }
    }
}
开发者ID:caomw,项目名称:BBRL,代码行数:16,代码来源:node.cpp

示例7: LocalMove

bool ROOMS::LocalMove(STATE &state, const HISTORY &history, int) const
{
    ROOMS_STATE rstate = safe_cast<ROOMS_STATE &>(state);
    if (GetObservation(rstate) == history.Back().Observation) {
        return true;
    }
    return false;
}
开发者ID:aijunbai,项目名称:hplanning,代码行数:8,代码来源:rooms.cpp

示例8: DisplayPolicy

void QNODE::DisplayPolicy(HISTORY& history, int maxDepth, ostream& ostr) const
{
    history.Display(ostr);

    ImmediateReward.Print("r=", ostr);
	Observation.Print(", o=", ostr);
	ostr << std::endl;

    if (history.Size() >= maxDepth)
        return;

    for (int observation = 0; observation < NumChildren; observation++)
    {
        if (Children[observation])
        {
            history.Back().Observation = observation;
            Children[observation]->DisplayPolicy(history, maxDepth, ostr);
        }
    }
}
开发者ID:aijunbai,项目名称:thompson-sampling,代码行数:20,代码来源:node.cpp

示例9: LocalMove

bool POCMAN::LocalMove(STATE& state, const HISTORY& history,
    int stepObs, const STATUS& status) const
{
    _unused(stepObs);
    _unused(status);

    POCMAN_STATE& pocstate = safe_cast<POCMAN_STATE&>(state);
    
    int numGhosts = Random(1, 3); // Change 1 or 2 ghosts at a time
    for (int i = 0; i < numGhosts; ++i)
    {
        int g = Random(NumGhosts);
        pocstate.GhostPos[g] = COORD(
            Random(Maze.GetXSize()),
            Random(Maze.GetYSize()));
        if (!Passable(pocstate.GhostPos[g]) 
            || pocstate.GhostPos[g] == pocstate.PocmanPos)
            return false;
    }

    COORD smellPos;
    for (smellPos.X = -SmellRange; smellPos.X <= SmellRange; smellPos.X++)
    {
        for (smellPos.Y = -SmellRange; smellPos.Y <= SmellRange; smellPos.Y++)
        {
            COORD pos = pocstate.PocmanPos + smellPos;
            if (smellPos != COORD(0, 0) &&
                Maze.Inside(pos) && 
                CheckFlag(Maze(pos), E_SEED))
                pocstate.Food[Maze.Index(pos)] = Bernoulli(FoodProb * 0.5);
        }
    }

    // Just check the last time-step, don't check for full consistency
    if (history.Size() == 0)
        return true;
    int observation = MakeObservations(pocstate);
    return history.Back().Observation == observation;
}
开发者ID:EHadoux,项目名称:HS3MDP,代码行数:39,代码来源:pocman.cpp

示例10: toggleInput

// ----------------------------------------------------------------------------------------------
// following functions use function parameters to determine range of frames
void EDITOR::toggleInput(int start, int end, int joy, int button, int consecutivenessTag)
{
	if (joy < 0 || joy >= joysticksPerFrame[getInputType(currMovieData)]) return;

	int check_frame = end;
	if (start > end)
	{
		// swap
		int temp_start = start;
		start = end;
		end = temp_start;
	}
	if (start < 0) start = end;
	if (end >= currMovieData.getNumRecords())
		return;

	if (currMovieData.records[check_frame].checkBit(joy, button))
	{
		// clear range
		for (int i = start; i <= end; ++i)
			currMovieData.records[i].clearBit(joy, button);
		greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_UNSET, start, end, 0, NULL, consecutivenessTag));
	} else
	{
		// set range
		for (int i = start; i <= end; ++i)
			currMovieData.records[i].setBit(joy, button);
		greenzone.invalidateAndUpdatePlayback(history.registerChanges(MODTYPE_SET, start, end, 0, NULL, consecutivenessTag));
	}
}
开发者ID:CharlexH,项目名称:Provenance,代码行数:32,代码来源:editor.cpp

示例11: handleColumnSet

// following functions use current Selection to determine range of frames
bool EDITOR::handleColumnSet()
{
	RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
	if (current_selection->size() == 0) return false;
	RowsSelection::iterator current_selection_begin(current_selection->begin());
	RowsSelection::iterator current_selection_end(current_selection->end());

	// inspect the selected frames, if they are all set, then unset all, else set all
	bool unset_found = false, changes_made = false;
	for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
	{
		if (!markersManager.getMarkerAtFrame(*it))
		{
			unset_found = true;
			break;
		}
	}
	if (unset_found)
	{
		// set all
		for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
		{
			if (!markersManager.getMarkerAtFrame(*it))
			{
				if (markersManager.setMarkerAtFrame(*it))
				{
					changes_made = true;
					pianoRoll.redrawRow(*it);
				}
			}
		}
		if (changes_made)
			history.registerMarkersChange(MODTYPE_MARKER_SET, *current_selection_begin, *current_selection->rbegin());
	} else
	{
		// unset all
		for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
		{
			if (markersManager.getMarkerAtFrame(*it))
			{
				markersManager.removeMarkerFromFrame(*it);
				changes_made = true;
				pianoRoll.redrawRow(*it);
			}
		}
		if (changes_made)
			history.registerMarkersChange(MODTYPE_MARKER_REMOVE, *current_selection_begin, *current_selection->rbegin());
	}
	if (changes_made)
		selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
	return changes_made;
}
开发者ID:CharlexH,项目名称:Provenance,代码行数:53,代码来源:editor.cpp

示例12: update

void GREENZONE::update()
{
	// keep collecting savestates, this code must be executed at the end of every frame
	if (taseditorConfig.enableGreenzoning)
	{
		collectCurrentState();
	} else
	{
		// just update Greenzone upper limit
		if (greenzoneSize <= currFrameCounter)
			greenzoneSize = currFrameCounter + 1;
	}

	// run cleaning from time to time
	if (clock() > nextCleaningTime)
		runGreenzoneCleaning();

	// also log lag frames
	if (currFrameCounter > 0)
	{
		// lagFlag indicates that lag was in previous frame
		int old_lagFlag = lagLog.getLagInfoAtFrame(currFrameCounter - 1);
		// Auto-adjust Input according to lag
		if (taseditorConfig.autoAdjustInputAccordingToLag && old_lagFlag != LAGGED_UNKNOWN)
		{
			if ((old_lagFlag == LAGGED_YES) && !lagFlag)
			{
				// there's no more lag on previous frame - shift Input up 1 or more frames
				adjustUp();
			} else if ((old_lagFlag == LAGGED_NO) && lagFlag)
			{
				// there's new lag on previous frame - shift Input down 1 frame
				adjustDown();
			}
		} else
		{
			if (lagFlag && (old_lagFlag != LAGGED_YES))
			{
				lagLog.setLagInfo(currFrameCounter - 1, true);
				// keep current snapshot laglog in touch
				history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, true);
			} else if (!lagFlag && old_lagFlag != LAGGED_NO)
			{
				lagLog.setLagInfo(currFrameCounter - 1, false);
				// keep current snapshot laglog in touch
				history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, false);
			}
		}
	}
}
开发者ID:BigMacStorm,项目名称:NES_machine,代码行数:50,代码来源:greenzone.cpp

示例13: exitTASEditor

bool exitTASEditor()
{
	if (!askToSaveProject()) return false;

	// destroy window
	taseditorWindow.exit();
	disableGeneralKeyboardInput();
	// release memory
	editor.free();
	pianoRoll.free();
	markersManager.free();
	greenzone.free();
	bookmarks.free();
	branches.free();
	popupDisplay.free();
	history.free();
	playback.stopSeeking();
	selection.free();

	// restore "eoptions"
	eoptions = saved_eoptions;
	// restore autosaves
	EnableAutosave = saved_EnableAutosave;
	DoPriority();
	// restore frame_display
	frame_display = saved_frame_display;
	UpdateCheckedMenuItems();
	// switch off TAS Editor mode
	movieMode = MOVIEMODE_INACTIVE;
	FCEU_DispMessage("TAS Editor disengaged", 0);
	FCEUMOV_CreateCleanMovie();
	return true;
}
开发者ID:Plombo,项目名称:fceux,代码行数:33,代码来源:taseditor.cpp

示例14: setMarkers

void EDITOR::setMarkers()
{
	RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
	if (current_selection->size())
	{
		RowsSelection::iterator current_selection_begin(current_selection->begin());
		RowsSelection::iterator current_selection_end(current_selection->end());
		bool changes_made = false;
		for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
		{
			if (!markersManager.getMarkerAtFrame(*it))
			{
				if (markersManager.setMarkerAtFrame(*it))
				{
					changes_made = true;
					pianoRoll.redrawRow(*it);
				}
			}
		}
		if (changes_made)
		{
			selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true;
			history.registerMarkersChange(MODTYPE_MARKER_SET, *current_selection_begin, *current_selection->rbegin());
		}
	}
}
开发者ID:CharlexH,项目名称:Provenance,代码行数:26,代码来源:editor.cpp

示例15: handleInputColumnSetUsingPattern

bool EDITOR::handleInputColumnSetUsingPattern(int joy, int button)
{
	if (joy < 0 || joy >= joysticksPerFrame[getInputType(currMovieData)]) return false;

	RowsSelection* current_selection = selection.getCopyOfCurrentRowsSelection();
	if (current_selection->size() == 0) return false;
	RowsSelection::iterator current_selection_begin(current_selection->begin());
	RowsSelection::iterator current_selection_end(current_selection->end());
	int pattern_offset = 0, current_pattern = taseditorConfig.currentPattern;

	for(RowsSelection::iterator it(current_selection_begin); it != current_selection_end; it++)
	{
		// skip lag frames
		if (taseditorConfig.autofirePatternSkipsLag && greenzone.lagLog.getLagInfoAtFrame(*it) == LAGGED_YES)
			continue;
		currMovieData.records[*it].setBitValue(joy, button, patterns[current_pattern][pattern_offset] != 0);
		pattern_offset++;
		if (pattern_offset >= (int)patterns[current_pattern].size())
			pattern_offset -= patterns[current_pattern].size();
	}
	int first_changes = history.registerChanges(MODTYPE_PATTERN, *current_selection_begin, *current_selection->rbegin(), 0, patternsNames[current_pattern].c_str());
	if (first_changes >= 0)
	{
		greenzone.invalidateAndUpdatePlayback(first_changes);
		return true;
	} else
		return false;
}
开发者ID:CharlexH,项目名称:Provenance,代码行数:28,代码来源:editor.cpp


注:本文中的HISTORY类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。