Ejemplo n.º 1
0
        // tik strategie urcujici co se ma pri kazdem kroku vykonat
        public override void TickStrategy(StrategyStorage storage)
        {
            SetGoalkeeperStrategy(storage.myRobots[gameSetting.NUMBER_OF_ROBOTS - 1], storage);

            try
            {
                currentRule = FindBestRuleGraph(storage);
            }
            catch (Exception e)
            {
                currentRule = null;
            }

            SharedMutex.getMutex().WaitOne();
            if (currentRule != null)
            {
                int[] mapping = MapRobotsToMoveTo(storage, currentRule);
                for (int i = 0; i < gameSetting.NUMBER_OF_ROBOTS - 1; i++)
                {
                    storage.myRobots[mapping[i]].PositionMove = gStrategy.GridToReal(currentRule.Move[i], gameSetting);
                }
            }
            SharedMutex.getMutex().ReleaseMutex();

            // tactics
            SharedMutex.getMutex().WaitOne();
            tactic.chooseTactic(storage);
            SharedMutex.getMutex().ReleaseMutex();
        }
Ejemplo n.º 2
0
        // tik strategie urcujici co se ma pri kazdem kroku vykonat
        public override void TickStrategy(Storage storage)
        {
            SetGoalkeeperStrategy(storage.LeftRobots[gameSetting.NUMBER_OF_ROBOTS - 1], storage);
            //aa
            // strategie
            //if (RobotsInDesiredGrid(storage) >= gStrategy.RuleException)
            //currentRule = FindBestRule(ref ruleIndex, storage);
            //currentRule = FindBestRule4(storage);

            try
            {
                currentRule = FindBestRuleGraph(storage);
            }
            catch (Exception e)
            {
                currentRule = null;
            }

            SharedMutex.getMutex().WaitOne();
            if (currentRule != null)
            {
                //for (int i = 0; i < gameSetting.NUMBER_OF_ROBOTS - 1; i++)
                //    storage.LeftRobots[ruleIndex[i]].PositionMove = gStrategy.GridToReal(currentRule.Move[i], gameSetting);
                int[] mapping = MapRobotsToMoveTo(storage, currentRule);
                for (int i = 0; i < gameSetting.NUMBER_OF_ROBOTS - 1; i++)
                {
                    storage.LeftRobots[mapping[i]].PositionMove = gStrategy.GridToReal(currentRule.Move[i], gameSetting);
                }
            }
            SharedMutex.getMutex().ReleaseMutex();

            // taktiky
            SharedMutex.getMutex().WaitOne();
            tactic.chooseTactic(storage);
            SharedMutex.getMutex().ReleaseMutex();


            //TACTIC if (currentRule != null)
            //{
            //    for (int i = 0; i < gameSetting.NUMBER_OF_ROBOTS - 1; i++)
            //    {
            //        if (!storage.MyRobots[ruleIndex[i]].tactic &&
            //            gStrategy.RealToGrid(storage.MyRobots[ruleIndex[i]].Position) != currentRule.Move[i]) //najdeš li taktiku pro robata a stoji jinde než by měl
            //        {
            //            storage.MyRobots[ruleIndex[i]].GoTo(storage.MyRobots[ruleIndex[i]].Strat_pos); //Strat_pos nahradit .PositionMove
            //        }
            //    }
            //}
        }