private void WriteStateToTrace(MapsVertex vertex, MapsAgent agent, string context, int parentID, int iparentID, int stateID, int senderID, int cost, int heuristic, Dictionary <string, int> newIParents)
        {
            int        agentID    = agent.GetID();
            List <int> privateIDs = GetPrivateIDs(vertex);
            List <int> values     = GetValues(vertex, agent);

            TraceState writtenTraceState = new TraceState(agentID, senderID, stateID, parentID, iparentID, cost, heuristic, privateIDs, values, context);

            traces[agent.regularAgent].AddState(writtenTraceState);
            vertex.traceStateForPublicRevealedState = writtenTraceState;
            vertex.agent2iparent = newIParents;

            if (TraceState.TimeToFlashStates())
            {
                FlashStates();
            }
        }
Ejemplo n.º 2
0
        public void EnterDependenciesToTrace(Agent agent, Tuple <Action, Predicate> chosen, List <Action> actionsAffected)
        {
            if (!Program.creatingTracesAfterSolutionWasFound)
            {
                return;
            }
            //if (Program.alreadySolved[Program.currentProblemName])
            //    return;
            if (actionsAffected.Count == 0)
            {
                return;
            }
            Predicate predicate;
            bool      negation = false;
            int       val      = 0;

            if (chosen.Item2.Negation)
            {
                //if it is a "not Predicate"
                predicate = chosen.Item2.Negate();
                negation  = true;
                val       = 1;
                return;
            }
            else
            {
                predicate = chosen.Item2;
            }
            Predicate privatePredicate = agent.ArtificialToPrivate[(GroundedPredicate)predicate];

            Dictionary <Predicate, int> publicEffectsOfChosen = getPublicEffects(chosen.Item1.HashEffects);
            int recievedStateID = TraceState.GetNextStateID();

            TraceState recievedState = getRevealerRecievedState(agent, privatePredicate, val, publicEffectsOfChosen, recievedStateID);

            List <TraceState> sentStates = getRevealerSentStates(agent, actionsAffected, val, recievedStateID);

            traces[agent].AddStates(recievedState, sentStates);

            CopyTraceStatesForAllAgents(agents, agent, recievedState, sentStates, val);

            if (TraceState.TimeToFlashStates())
            {
                FlashStates();
            }
        }