public GraphicMatchController(IMatchView view)
 {
     myObservers     = new List <IControllerObserver>();
     this.myView     = view;
     view.Controller = this;
     myFeedbackForm  = new FeedbackForm();
 }
 private void initPlayer1Form()
 {
     if (!isRunning)
     {
         if (myView == null)
         {
             myView = new MatchForm(this);
         }
         myView.start();
     }
 }
Exemplo n.º 3
0
 public static ITaskEngine CreateTaskEngine(IMatchView matchEngine, ITaskRunner taskRunner, IPathFinder pathFinder)
 {
     return(new TaskEngine(matchEngine, taskRunner, pathFinder, true));
 }
Exemplo n.º 4
0
        public TaskEngine(IMatchView match, ITaskRunner taskRunner, IPathFinder pathFinder, bool isClient)
        {
            m_isClient        = isClient;
            m_match           = match;
            m_taskRunner      = taskRunner;
            m_pathFinder      = pathFinder;
            m_activeTasks     = new List <TaskBase>();
            m_idToActiveTask  = new Dictionary <long, TaskBase>();
            m_timeoutRequests = new List <PendingClientRequest>();
            m_requests        = new Dictionary <long, PendingClientRequest>();
            m_mem             = new TaskMemory();

            m_expressions = new Dictionary <int, IExpression>
            {
                { ExpressionCode.Value, new ValueExpression() },
                { ExpressionCode.Assign, new AssignmentExpression() },
                { ExpressionCode.Itertate, new IterateExpression() },
                { ExpressionCode.Get, new GetExpression() },
                { ExpressionCode.And, new AndExpression() },
                { ExpressionCode.Or, new OrExpression() },
                { ExpressionCode.Not, new NotExpression() },
                { ExpressionCode.Eq, new EqExpression() },
                { ExpressionCode.NotEq, new NotEqExpression() },
                { ExpressionCode.Lt, new LtExpression() },
                { ExpressionCode.Lte, new LteExpression() },
                { ExpressionCode.Gt, new GtExpression() },
                { ExpressionCode.Gte, new GteExpression() },
                { ExpressionCode.Add, new AddExpression() },
                { ExpressionCode.Sub, new SubExpression() },
                { ExpressionCode.UnitExists, new UnitExistsExpression() },
                { ExpressionCode.UnitState, new UnitStateExpression() },
                { ExpressionCode.UnitCoordinate, new UnitCoordinateExpression() },
                { ExpressionCode.UnitCanGrow, new UnitCanGrowImmediateExpression() },
                { ExpressionCode.UnitCanSplit4, new UnitCanSplit4ImmediateExpression() },
                { ExpressionCode.UnitCanConvert, new UnitCanConvertImmediateExpression() },
                { ExpressionCode.TaskStatusCode, new TaskStatusExpression() },
                { ExpressionCode.TaskSucceded, new TaskSuccededExpression() },
                { ExpressionCode.TaskFailed, new TaskFailedExpression() },
                { ExpressionCode.CmdSucceded, new CmdSuccededExpression() },
                { ExpressionCode.CmdHardFailed, new CmdHardFailedExpression() },
                { ExpressionCode.CmdResultCode, new CmdResultCodeExpression() },
            };

            const int taskPoolSize = 10;

            m_taskPools = new Dictionary <TaskType, ITaskPool>
            {
                { TaskType.Sequence, new TaskPool <SequentialTask>(taskPoolSize) },
                { TaskType.Repeat, new TaskPool <RepeatTask>(taskPoolSize) },
                { TaskType.Branch, new TaskPool <BranchTask>(taskPoolSize) },
                { TaskType.Procedure, new TaskPool <ProcedureTask>(taskPoolSize) },
                { TaskType.Break, new TaskPool <BreakTask>(taskPoolSize) },
                { TaskType.Continue, new TaskPool <ContinueTask>(taskPoolSize) },
                { TaskType.Return, new TaskPool <ReturnTask>(taskPoolSize) },
                { TaskType.Nop, new TaskPool <NopTask>(taskPoolSize) },
                { TaskType.EvalExpression, new TaskPool <EvaluateExpressionTask>(taskPoolSize) },
                { TaskType.FindPath, new TaskPool <FindPathTask>(taskPoolSize) },
                { TaskType.FindPathToRandomLocation, new TaskPool <FindPathToRandLocationPath>(taskPoolSize) },
                { TaskType.SearchForFood, new TaskPool <SearchAroundForFood>(taskPoolSize) },
                { TaskType.SearchForGrowLocation, new TaskPool <SearchAroundForGrowLocation>(taskPoolSize) },
                { TaskType.SearchForSplit4Location, new TaskPool <SearchAroundForSplit4Location>(taskPoolSize) },
                //For testing purposes
                { TaskType.TEST_Mock, new TaskPool <MockTask>(taskPoolSize) },
                { TaskType.TEST_MockImmediate, new TaskPool <MockImmediateTask>(taskPoolSize) },
                { TaskType.TEST_Fail, new TaskPool <TestFailTask>(taskPoolSize) },
                { TaskType.TEST_Pass, new TaskPool <TestPassTask>(taskPoolSize) },
                { TaskType.TEST_Assert, new TaskPool <TestAssertTask>(taskPoolSize) },
                { TaskType.TEST_SearchForWall, new TaskPool <TestSearchAroundForWallTask>(taskPoolSize) },
                { TaskType.DEBUG_Log, new TaskPool <LogTask>(taskPoolSize) },
                { TaskType.DEBUG_LogWarning, new TaskPool <LogWarningTask>(taskPoolSize) },
                { TaskType.DEBUG_LogError, new TaskPool <LogErrorTask>(taskPoolSize) },
            };

            m_cmdExpressionTaskPool = new TaskPool <ExecuteCmdTaskWithExpression>(taskPoolSize);
            m_cmdMoveTaskPool       = new TaskPool <ExecuteMoveTask>(taskPoolSize);
            m_cmdGenericTaskPool    = new TaskPool <ExecuteCmdTask>(taskPoolSize);
        }