コード例 #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);
        }
コード例 #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);
        }
コード例 #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,
     });
 }
コード例 #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; }
 }
コード例 #5
0
ファイル: State.cs プロジェクト: Corniel/Vindinium
        /// <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);
        }
コード例 #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());
        }
コード例 #7
0
 public bool Equals(IMineOwnership other)
 {
     return(Equals((MineOwnership20)other));
 }
コード例 #8
0
        /// <summary>Creates mine ownership from tiles.</summary>
        public IMineOwnership UpdateFromTiles(string tiles)
        {
            IMineOwnership mines = MineOwnership20.Empty;

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