Example #1
0
        public bool DeadEndsControl(PlanAction action,
                                    WorldDynamic currentState,
                                    KeyValuePair <AgentStateStatic, AgentStateDynamic> player,
                                    bool succsessControl)
        {
            if (player.Key.GetRole() == AgentRole.PLAYER)
            {
                WorldDynamic worldForTest = (WorldDynamic)currentState.Clone();
                if (!succsessControl)
                {
                    action.Fail(ref worldForTest);
                }
                else
                {
                    action.ApplyEffects(ref worldForTest);
                }

                worldForTest.GetAgentByRole(AgentRole.PLAYER).Value.CalculatePlan(worldForTest.GetAgentByRole(AgentRole.PLAYER), worldForTest);

                if (worldForTest.GetAgentByRole(AgentRole.PLAYER).Value.GetPlanStatus())
                {
                    // Cleaning
                    worldForTest = null;
                    GC.Collect();

                    // Return result
                    return(true);
                }
                else
                {
                    // Cleaning
                    worldForTest = null;
                    GC.Collect();

                    // Return result
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
 /// <summary>
 /// A method that defines the constraints imposed on the story.
 /// </summary>
 public void CreateConstraints()
 {
     if (manualInput) // Constraints for demo-story
     {
         // The killer must be alive for the first 5 turns.
         ConstraintAlive killerMustBeAliveFiveTurns = new ConstraintAlive(true, false, currentStoryState.GetAgentByRole(AgentRole.KILLER), 1);
         storyworldConvergence.AddConstraint(killerMustBeAliveFiveTurns);
     }
 }