public void ResetVelocity() { for (int i = 0; i < smoothingFrames.Length; i++) { smoothingFrames[i] = new HistoryFrame(Vector3.zero, Vector3.zero); } _lastVelocity = Vector3.zero; _lastRotation = Quaternion.identity; }
// adds the history to the array private void AddHistory(HistoryFrame newHistory) { for (int i = m_histSize - 1; i > 0; --i) { m_history[i] = m_history[i - 1]; } m_history[0] = newHistory; }
public CrossWordSolver(CrossWordTask task) { _globalHistory = new HistoryFrame(); CreateLineProcessors(); Board = new Board(task.ColumnsTasks.Length, task.RowsTasks.Length); _colsLines = ParseColsLines(task).ToArray(); _rowsLines = ParseRowsLines(task).ToArray(); }
private void ChooseMotive() // picks a motive randomly and does it if posible { if (ReadyToLeave()) { m_currentMotive = Motives.kLeave; m_navAgent.SetDestination(m_motives[(int)m_currentMotive].StartMotive()); HistoryFrame historyFrame = new HistoryFrame((m_motives[(int)Motives.kEat] as EatMotive).Hunger, (m_motives[(int)Motives.kRest] as RestMotive).Energy, (m_motives[(int)Motives.kSocialize] as SocialMotive).Social, (m_motives[(int)Motives.kShop] as ShopMotive).GetItemsToBuy(), 0, 0, 0, 0, 1, GetCurrentMotive()); AddHistory(historyFrame); } else { m_hungerScore = m_motives[(int)Motives.kEat].ScoreMotive(); m_energyScore = m_motives[(int)Motives.kRest].ScoreMotive(); m_shopScore = m_motives[(int)Motives.kShop].ScoreMotive(); m_leaveScore = m_motives[(int)Motives.kLeave].ScoreMotive(); m_socialScore = m_motives[(int)Motives.kSocialize].ScoreMotive(); List <MotiveValuePair> desireOrder = new List <MotiveValuePair> { new MotiveValuePair(Motives.kEat, m_hungerScore), new MotiveValuePair(Motives.kRest, m_energyScore), new MotiveValuePair(Motives.kShop, m_shopScore), new MotiveValuePair(Motives.kLeave, m_leaveScore), new MotiveValuePair(Motives.kSocialize, m_socialScore) }; desireOrder.Sort(); m_currentMotive = desireOrder[desireOrder.Count - 1].mot; float choice = desireOrder[desireOrder.Count - 1].val; if (m_currentMotive == m_previousChoice && (choice - desireOrder[desireOrder.Count - 2].val) <= .1) // if choice is the same as last choice and the desire difference between second best is less then .1 { m_currentMotive = desireOrder[desireOrder.Count - 2].mot; // choose the next best thing } m_previousChoice = m_currentMotive; HistoryFrame historyFrame = new HistoryFrame((m_motives[(int)Motives.kEat] as EatMotive).Hunger, (m_motives[(int)Motives.kRest] as RestMotive).Energy, (m_motives[(int)Motives.kSocialize] as SocialMotive).Social, (m_motives[(int)Motives.kShop] as ShopMotive).GetItemsToBuy(), m_hungerScore, m_energyScore, m_socialScore, m_shopScore, m_leaveScore, GetCurrentMotive()); AddHistory(historyFrame); m_navAgent.SetDestination(m_motives[(int)m_currentMotive].StartMotive()); } }
public bool SolveStep() { var stepHistoryFrame = new HistoryFrame(); foreach (var line in _colsLines) { if (!line.TrySolveStep(stepHistoryFrame)) { return(false); } } foreach (var line in _rowsLines) { if (!line.TrySolveStep(stepHistoryFrame)) { return(false); } } _globalHistory.Push(stepHistoryFrame); return(true); }