void Environment::Step() { std::vector<Action *> actions(0); unsigned int i; for(i = 0; i < agents.size(); i++) { Percept *percept = GetPercept(agents[i]); Action *action = agents[i]->Program(percept); if(action) { actions.push_back(action); } delete percept; } for(i = 0; i < agents.size(); i++) { ApplyAction(agents[i], actions[i]); } for(i = 0; i < agents.size(); i++) { delete actions[i]; } for(i = 0; i < agents.size(); i++) { CalculatePerformance(agents[i]); } UpdateDisplays(); }
void TextDocument::Redo(GCursor &c) { if (UndoPos < Queue.GetItems()) { ApplyAction(Queue.ItemAt(UndoPos), c, true); UndoPos++; } }
void TextDocument::Undo(GCursor &c) { if (UndoPos > 0) { ApplyAction(Queue.ItemAt(UndoPos - 1), c, false); UndoPos--; } }
void NQueens::GetNextState(const NQueenState &s, NQueenAction a, NQueenState &s2) const { s2 = s; ApplyAction(s2, a); }
void RubiksCube::GetNextState(const RubiksState &s1, RubiksAction a, RubiksState &s2) const { s2 = s1; ApplyAction(s2, a); }