Ejemplo n.º 1
0
        private AgentAction NextCachedAction()
        {
            //do {

            //}
            //while (extender.SkipAction(cached_actions[current_action_dex]));
            AgentAction resp = cached_actions[current_action_dex];

            current_action_dex++;
            if (current_action_dex >= cached_actions.Count)
            {
                Debug.Log("Out of actions on this user moving to next");
                current_user_dex++;
                if (current_user_dex == cached_users.Count)
                {
                    Debug.Log("Out of actions.");
                    requestStatus = ActionRequestStatus.OutOfActions;
                    return(AgentAction.NullAction);
                }
                else
                {
                    CacheUserLogs();
                }
            }
            return(resp);
        }
Ejemplo n.º 2
0
        public override IEnumerator RequestNextAction()
        {
            ready         = false;
            requestStatus = ActionRequestStatus.Requesting;
            switch (orientation)
            {
            case AgentOrientation.Watching:
                yield return(StartCoroutine(NextAPIAction()));

                while (waitingOnAPI)
                {
                    yield return(0);
                }
                if (orientation == AgentOrientation.Watching)
                {
                    lastAction = currAction;
                    currAction = NextCachedAction();
                }
                break;

            case AgentOrientation.Trying:
                yield return(StartCoroutine(NextAPIAction()));

                while (waitingOnAPI)
                {
                    yield return(0);
                }
                break;

            case AgentOrientation.Listening:
                lastAction = currAction;
                //TODO - Might need to cache a state here?
                currAction = NextCachedAction();
                break;

            default:
                Debug.LogErrorFormat("Not sure what to do with Agent Orientation:{0}", orientation);
                break;
            }
            requestStatus = ActionRequestStatus.ActionFound;
            //Debug.LogFormat("Returning Action - {0}", currAction.ToLongString());
            BackUpState();
            ready = true;
        }
        public override IEnumerator RequestNextAction()
        {
            state = ActionRequestStatus.Requesting;
            prev  = curr;
            curr  = next;
            count++;
            try {
                if (reader.Read())
                {
                    //Debug.Log("Selection: " + reader["selection"]);
                    next = new AgentAction(
                        reader["selection"].ToString(),
                        reader["action"].ToString(),
                        reader["input"].ToString(),
                        reader["state"].ToString(),
                        reader["eventTime"].ToString(),
                        reader["userID"].ToString(),
                        reader["levelName"].ToString(),
                        reader["attemptNumber"].ToString(),
                        reader["sessionID"].ToString(),
                        reader["transactionID"].ToString(),
                        reader["attemptID"].ToString()
                        );
                }
                else
                {
                    next  = AgentAction.NullAction;
                    state = ActionRequestStatus.NoAction;
                    yield break;
                }
            }
            catch (System.Exception e) {
                Debug.LogError(string.Format("Error on line {0}: {1}", count, reader.ToString()));
                Debug.LogException(e);
                next  = AgentAction.NullAction;
                state = ActionRequestStatus.NoAction;
                yield break;
            }

            //Debug.Log("GetNextAction: " + curr);
            state = ActionRequestStatus.ActionFound;
            yield break;
        }