Britbot
static Dictionary<Pirate, Direction> Britbot.Fallback.FallbackBot.GetFallbackTurns ( CancellationToken  cToken) [inline, static]

Generates the fallback moves This is basically the weaker sister of Commander.Play()

Returns:

Definition at line 47 of file FallbackBot.cs.

        {
            try
            {
                FallbackBot.FallbackGroups.RemoveAll(g => g.Pirates.Count == 0);

                // Update all groups
                FallbackBot.FallbackGroups.ForEach(g => g.Update());

                //A list with all the moves from all groups
                List<KeyValuePair<Pirate, Direction>> allMoves =
                    new List<KeyValuePair<Pirate, Direction>>(Bot.Game.AllMyPirates().Count);

                //Get the moves from each group we have
                foreach (Group group in FallbackBot.FallbackGroups)
                {
                    List<KeyValuePair<Pirate, Direction>> mvs = group.GetGroupMoves(cToken).ToList();
                    allMoves.AddRange(mvs);
                }

                Logger.Write("===============FALLBACK READY=================");

                //Convert the moves list to dictionary
                return allMoves.ToDictionary(pair => pair.Key, pair => pair.Value);
            }
            catch (Exception ex)
            {
                Logger.Write("======FALLBACK EXCEPTION=======",true);
                Logger.Write("Fallback almost crashed because of exception: " + ex.Message, true);
                
                StackTrace exTrace = new StackTrace(ex, true);
                StackFrame frame = exTrace.GetFrame(0);
                Logger.Write(
                    string.Format("The exception was thrown from method {0} at file {1} at line #{2}", frame.GetMethod(),
                        frame.GetFileName(), frame.GetFileLineNumber()), true);
                Logger.Write("======FALLBACK EXCEPTION=======", true);

                return FallbackBot.SuperFuckedFallback();
            }
        }