Пример #1
0
        public static IEnumerable <GameAction> GetBestActions(Game game)
        {
            var allActions = new List <GameActionsBatch>();

            ResolveActions(0, game, null, allActions);

            CgPlayer.D($"actions: {allActions.Count}");

            allActions = allActions.OrderByDescending(x => x.Score).ToList();

            CgTimer.Log("my finished");

            IEnumerable <GameAction> actions = GameAction.PassActions;

            //if (allActions.Count > 0)
            //{
            //    var top = allActions.First();
            //    actions = top.Actions;
            //}

            foreach (var a in allActions)
            {
                if (CgTimer.IsTimeout())
                {
                    break;
                }
                var oppActions = new List <GameActionsBatch>();
                ResolveActions(1, a.Game, null, oppActions);
                var best = oppActions.OrderByDescending(x => x.Score).FirstOrDefault();
                if (best != null)
                {
                    a.Score1   = best.Score;
                    a.Actions1 = best.Actions;
                }
                else
                {
                    a.Score1   = double.MaxValue;
                    a.Actions1 = GameAction.PassActions;
                }
            }

            if (allActions.Count > 0)
            {
                var top = allActions.First();
                actions = top.Actions;
                CgPlayer.D($"top: {top.Score}/{top.Score1} {string.Join(";", actions)}");

                var top1 = allActions.Where(x => x.Score1 > double.MinValue).OrderByDescending(x => x.Score1).FirstOrDefault();
                if (top1 != null)
                {
                    CgPlayer.D($"top1: {top1?.Score}/{top1?.Score1} {string.Join(";", top1?.Actions)} / {string.Join(";", top1?.Actions1)}");
                    actions = top1.Actions;
                }
            }

            CgTimer.Log("op finished");

            return(actions);
        }
Пример #2
0
 public static void Log(string message)
 {
     CgPlayer.D($"{message}. {ticks} ticks in {turnTimer.ElapsedMilliseconds} ms");
 }