Example #1
0
        public void BeginMatch(IProject project)
        {
            if (project.EngineOptions.EngineMode != EngineMode.Match)
                throw new InvalidOperationException("This engine mode is supported only by method run");

            InitializeMatch(project);
            InitializeRound();

            results = new MatchResult(project);
            lastStepResult = StepResult.Start;
            initBefore = Project.EngineOptions.InitRoundBefore;
            rounds = rules.Rounds;
        }
Example #2
0
 public MatchResult(MatchResult source)
 {
     warriorsCount = source.warriorsCount;
     rounds = source.rounds;
     formula = source.formula;
     results = new RoundResult[warriorsCount,rounds];
     for (int w = 0; w < warriorsCount; w++)
     {
         for (int r = 0; r < rounds; r++)
         {
             results[w, r] = source.results[w, r];
         }
     }
 }
Example #3
0
        public override bool Equals(object obj)
        {
            MatchResult res = obj as MatchResult;

            /*
             * if (project.Rules != res.project.Rules)
             *  throw new InvalidOperationException("Cannot compare different results with rules");
             */
            for (int w = 0; w < warriorsCount; w++)
            {
                /*
                 * for (int r = 0; r < rules.Rounds; r++)
                 * {
                 *  if (results[w, r] != res.results[w, r])
                 *      return false;
                 * }
                 */
                if (score[w] != res.score[w])
                {
                    return(false);
                }
            }
            return(true);
        }
Example #4
0
        private void CompareEngines(Check check)
        {
            engineSbOne = engineOne as IStepBackEngine;
            engineSbTwo = engineTwo as IStepBackEngine;
            engineOne.BeginMatch(project);
            engineTwo.BeginMatch(project);

            try
            {
                CheckWarriors(project.Rules, engineOne.Warriors, engineTwo.Warriors);
                ExpensiveCheck(false);
                while (Step(check))
                {
                }
                ExpensiveCheck(false);
            }
            finally
            {
                matchOne = engineOne.EndMatch(null);
                matchTwo = engineTwo.EndMatch(null);
            }

            if (matchOne != matchTwo)
            {
                throw new EngineDifferException("Score", Check.Optimistic);
            }
        }
Example #5
0
        public void BeginMatch(IProject aProject)
        {
            if (aProject.EngineOptions.EngineMode != EngineMode.Match)
                throw new NotSupportedException("This engine mode is not supported by pMars");

            project = aProject;
            cycle = 0;
            rules = project.Rules;
            results = new MatchResult(project);
            string[] names = new string[project.Warriors.Count];
            for (int w = 0; w < project.Warriors.Count; w++)
            {
                names[w] = project.Warriors[w].FileName;
            }
            List<string> r = pMarsDll.BuildParams(rules, false, project.EngineOptions.ForcedAddresses, names);

            errFile = Path.GetTempFileName();
            int res = pMarsDll.pMarsBeginMatch(r.Count, r.ToArray(), errFile);
            if (res != 0)
            {
                string errors = "";
                try
                {
                    errors = File.ReadAllText(errFile);
                    File.Delete(errFile);
                }
                catch (Exception)
                {
                    //swalow
                }
                throw new ParserException(errors);
            }
            pMarsDll.pMarsWatchMatch(out dllCore, out dllCoreSize, out dllCyclesLeft, out dllRound, out dllWarriors,
                                     out dllWarriorsCout, out dllPSpaces, out dllWarrirorsLeft, out dllNextWarrior,
                                     out dllTasksStart, out dllTasksEnd);
            dllDataLinked = true;
        }