Ejemplo n.º 1
0
        public static IMineOwnership UpdateFromTiles(IMineOwnership mines, string tiles)
        {
            var index = 0;

            for (int p = 0; p < tiles.Length; p += 2)
            {
                if (tiles[p] == '$')
                {
                    switch (tiles[p + 1])
                    {
                    case '1': mines = mines.Set(index, PlayerType.Hero1); break;

                    case '2': mines = mines.Set(index, PlayerType.Hero2); break;

                    case '3': mines = mines.Set(index, PlayerType.Hero3); break;

                    case '4': mines = mines.Set(index, PlayerType.Hero4); break;

                    case '-':
                    default: break;
                    }
                    index++;
                }
            }
            return(mines);
        }
Ejemplo n.º 2
0
        public static IMineOwnership Create(params PlayerType[] mines)
        {
            IMineOwnership ownership = MineOwnership20.Empty;

            for (int index = 0; index < mines.Length; index++)
            {
                if (mines[index] != PlayerType.None)
                {
                    ownership = ownership.Set(index, mines[index]);
                }
            }
            return(ownership);
        }
Ejemplo n.º 3
0
 public PotentialPath CreateFollowUp(Tile source, int health, IMineOwnership mines, MoveDirections directions, int turns, int profit)
 {
     return(new PotentialPath()
     {
         Opponents = this.Opponents,
         Source = source,
         Health = health,
         Mines = mines,
         Directions = directions,
         Turns = turns,
         Profit = profit,
     });
 }
Ejemplo n.º 4
0
 public static void AreEqual(
     int expTurns,
     Tile expSource,
     int expHealth,
     IMineOwnership expMines,
     MoveDirections expDirections,
     int expProfit,
     PotentialPath actual)
 {
     Assert.IsNotNull(actual);
     Assert.AreEqual(expTurns, actual.Turns, "Turns, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expSource, actual.Source, "Sources, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expHealth, actual.Health, "Health, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expMines, actual.Mines, "Mines, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expDirections, actual.Directions, "Directions, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expProfit, actual.Profit, "Profit, {0}", actual.DebuggerDisplay);
     //public List<PotentialOpponent> Opponents { get; set; }
 }
Ejemplo n.º 5
0
        /// <summary>Creates a state.</summary>
        public static State Create(
            int turn,
            Hero hero1,
            Hero hero2,
            Hero hero3,
            Hero hero4,
            IMineOwnership ownership)
        {
            var state = new State()
            {
                hash      = GetHash(turn, hero1, hero2, hero3, hero4),
                hero1     = hero1,
                hero2     = hero2,
                hero3     = hero3,
                hero4     = hero4,
                ownership = ownership
            };

            return(state);
        }
Ejemplo n.º 6
0
        public static string ToString(IMineOwnership ownership, int length)
        {
            var sb = new StringBuilder();

            for (int index = 0; index < length; index++)
            {
                switch (ownership[index])
                {
                default:
                case PlayerType.None: sb.Append('.'); break;

                case PlayerType.Hero1: sb.Append('1'); break;

                case PlayerType.Hero2: sb.Append('2'); break;

                case PlayerType.Hero3: sb.Append('3'); break;

                case PlayerType.Hero4: sb.Append('4'); break;
                }
            }
            return(sb.ToString());
        }
Ejemplo n.º 7
0
 public bool Equals(IMineOwnership other)
 {
     return(Equals((MineOwnership20)other));
 }
Ejemplo n.º 8
0
        /// <summary>Creates mine ownership from tiles.</summary>
        public IMineOwnership UpdateFromTiles(string tiles)
        {
            IMineOwnership mines = MineOwnership20.Empty;

            return(MineOwnership.UpdateFromTiles(mines, tiles));
        }