コード例 #1
0
        static void Main(string[] args)
        {
            AllianceScenario allianceScenario = AllianceScenario.GetRandomAllianceScenario();
            Board            board            = Board.GetInitialBoard();
            BoardMove        moves            = new BoardMove();

            moves.Add(board.GetMove("ber", "kie"));
            moves.Add(board.GetMove("bud", "rum"));
            moves.Add(board.GetMove("con", "bul"));
            moves.Add(board.GetMove("lvp", "edi"));
            moves.Add(board.GetMove("mar", "pie"));
            moves.Add(board.GetMove("mos", "stp"));
            moves.Add(board.GetMove("mun", "ruh"));
            moves.Add(board.GetMove("par", "gas"));
            moves.Add(board.GetMove("rom", "nap"));
            moves.Add(board.GetMove("ven", "tyr"));
            moves.Add(board.GetMove("vie", "tri"));
            moves.Add(board.GetMove("war", "sil"));
            moves.Add(board.GetMove("ank", "con"));
            moves.Add(board.GetMove("bre", "mao"));
            moves.Add(board.GetMove("edi", "nth"));
            moves.Add(board.GetMove("kie", "den"));
            moves.Add(board.GetMove("lon", "eng"));
            moves.Add(board.GetMove("nap", "tys"));
            moves.Add(board.GetMove("sev", "bla"));
            moves.Add(board.GetMove("stp_sc", "bot"));
            moves.Add(board.GetMove("tri", "alb"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();


            moves.Clear();
            moves.Add(board.GetMove("bul", "gre"));
            moves.Add(board.GetMove("gas", "spa"));
            moves.Add(board.GetMove("kie", "hol"));
            moves.Add(board.GetMove("ruh", "bel"));
            moves.Add(board.GetMove("smy", "arm"));
            moves.Add(board.GetMove("stp", "nwy"));
            moves.Add(board.GetMove("tri", "ser"));
            moves.Add(board.GetMove("bot", "swe"));
            moves.Add(board.GetMove("con", "bul_ec"));
            moves.Add(board.GetMove("mao", "por"));
            moves.Add(board.GetMove("tys", "tun"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();

            //var boardMoves = BoardFutures.GetAllBoardMovesWinter(board);
            var          probabilisticFuturesAlgorithm = new ProbabilisticFuturesAlgorithm();
            int          limit        = 20;
            List <Board> futureBoards = board.GetFutures(allianceScenario, probabilisticFuturesAlgorithm);

            while (futureBoards.Any() && limit > 0)
            {
                limit--;
                board        = futureBoards[0];
                futureBoards = board.GetFutures(allianceScenario, probabilisticFuturesAlgorithm);
            }
        }
コード例 #2
0
ファイル: BoardTests.cs プロジェクト: vfridell/Diplomacy
        public void BoardCloneTest()
        {
            Board board = Board.GetInitialBoard();
            Board clone = board.Clone();

            Assert.AreEqual(clone.OwnedSupplyCenters[Powers.Germany].Count, board.OwnedSupplyCenters[Powers.Germany].Count);

            BoardMove moves = new BoardMove();

            moves.Add(clone.GetMove("kie", "den"));
            moves.Add(clone.GetMove("ber", "kie"));
            moves.FillHolds(clone);
            clone.ApplyMoves(moves);
            clone.EndTurn();

            Assert.AreNotEqual(clone.Turn, board.Turn);

            moves.Clear();
            moves.Add(clone.GetMove("kie", "hol"));
            moves.FillHolds(clone);
            clone.ApplyMoves(moves);
            clone.EndTurn();

            Assert.AreNotEqual(clone.OwnedSupplyCenters[Powers.Germany].Count, board.OwnedSupplyCenters[Powers.Germany].Count);
        }
コード例 #3
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void DisbandWinterUnitMoves()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("tri", "ven"));
            moves.Add(board.GetMove("ven", "pie"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();


            moves.Clear();
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();

            Assert.AreEqual(2, board.OwnedSupplyCenters[Powers.Italy].Count);
            Assert.AreEqual(4, board.OwnedSupplyCenters[Powers.Austria].Count);
            Assert.AreEqual(22, board.OwnedSupplyCenters.Where(kvp => kvp.Key != Powers.None).SelectMany(kvp => kvp.Value).Count());

            var unitMoves = board.GetUnitMoves();

            Assert.AreEqual(2, unitMoves.Count(um => um.IsBuild));
            Assert.AreEqual(3, unitMoves.Count(um => um.IsDisband));
        }
コード例 #4
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void BuildUnitMoves()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("kie", "den"));
            moves.Add(board.GetMove("ber", "kie"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.Germany].Count);
            board.EndTurn();

            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.Germany].Count);

            moves.Clear();
            moves.Add(board.GetMove("kie", "hol"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.Germany].Count);
            board.EndTurn();

            Assert.AreEqual(5, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(24, board.OwnedSupplyCenters.Where(kvp => kvp.Key != Powers.None).SelectMany(kvp => kvp.Value).Count());

            var unitMoves = board.GetUnitMoves();

            Assert.AreEqual(4, unitMoves.Count(um => um.IsBuild));
        }
コード例 #5
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void OwnedSupplyCentersOwnershipSwitch()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("par", "pic"));
            moves.Add(board.GetMove("mun", "bur"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.France].Count);
            board.EndTurn();

            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.France].Count);

            moves.Clear();
            moves.Add(board.GetMove("bur", "par"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.France].Count);
            board.EndTurn();

            Assert.AreEqual(4, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(2, board.OwnedSupplyCenters[Powers.France].Count);
            Assert.AreEqual(22, board.OwnedSupplyCenters.Where(kvp => kvp.Key != Powers.None).SelectMany(kvp => kvp.Value).Count());
        }
コード例 #6
0
        public void BoardMoveEqualityInitial()
        {
            Board     board      = Board.GetInitialBoard();
            BoardMove boardMove1 = new BoardMove();

            boardMove1.FillHolds(board);
            BoardMove boardMove2 = new BoardMove();

            boardMove2.FillHolds(board);
            Assert.AreEqual(boardMove1, boardMove2);
        }
コード例 #7
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void AllHoldsFilled()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            Assert.AreEqual(0, moves.Count);

            moves.FillHolds(board);

            Assert.AreEqual(board.OccupiedMapNodes.Count, moves.Count);
            Assert.IsFalse(moves.Any(m => !m.IsHold));
        }
コード例 #8
0
        public void GenerateWinterMovesNoEmptyBuilds()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("tri", "ven"));
            moves.Add(board.GetMove("ven", "pie"));
            moves.Add(board.GetMove("ber", "kie"));
            moves.Add(board.GetMove("kie", "den"));
            moves.Add(board.GetMove("mun", "ruh"));
            moves.Add(board.GetMove("stp_sc", "bot"));
            moves.Add(board.GetMove("sev", "rum"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();


            moves.Clear();
            moves.Add(board.GetMove("bot", "swe"));
            moves.Add(board.GetMove("kie", "hol"));
            moves.Add(board.GetMove("ruh", "bel"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();

            Assert.AreEqual(6, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(6, board.OwnedSupplyCenters[Powers.Russia].Count);
            Assert.AreEqual(2, board.OwnedSupplyCenters[Powers.Italy].Count);
            Assert.AreEqual(4, board.OwnedSupplyCenters[Powers.Austria].Count);

            var boardMoves = BoardFutures.GetAllBoardMovesWinter(board);

            Assert.IsTrue(boardMoves.All(bm => null != bm.FirstOrDefault(um => um.Edge.Target == MapNodes.Get("mun"))));
            Assert.AreEqual(144, boardMoves.Count());

            //this is the total for when empty builds are included
            //Assert.AreEqual(1944, boardMoves.Count());
        }
コード例 #9
0
        public void GenerateWinterMovesAustriaOut1902()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("mun", "boh"));
            moves.Add(board.GetMove("ven", "tri"));
            moves.Add(board.GetMove("vie", "tyr"));
            moves.Add(board.GetMove("bud", "gal"));
            moves.Add(board.GetMove("tri", "alb"));
            moves.Add(board.GetMove("rom", "ven"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();


            moves.Clear();
            moves.Add(board.GetMove("ven", "tri"));
            moves.Add(board.GetMove("tri", "bud"));
            moves.Add(board.GetMove("boh", "vie"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();

            Assert.AreEqual(4, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(4, board.OwnedSupplyCenters[Powers.Russia].Count);
            Assert.AreEqual(5, board.OwnedSupplyCenters[Powers.Italy].Count);
            Assert.AreEqual(0, board.OwnedSupplyCenters[Powers.Austria].Count);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.Turkey].Count);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.England].Count);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.France].Count);

            var boardMoves = BoardFutures.GetAllBoardMovesWinter(board);

            Assert.IsTrue(boardMoves.All(bm => null != bm.FirstOrDefault(um => um.Edge.Target == MapNodes.Get("mun"))));
            Assert.IsTrue(boardMoves.All(bm => bm.Where(um => um.Unit.Power == Powers.Austria).All(um => um.IsDisband)));
            Assert.AreEqual(4, boardMoves.Count());
        }
コード例 #10
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void DisbandUnitMoveCount()
        {
            Board     board  = Board.GetInitialBoard();
            BoardMove moves1 = new BoardMove();

            moves1.Add(board.GetMove("ven", "tyr"));
            moves1.Add(board.GetMove("vie", "boh"));
            moves1.FillHolds(board);
            board.ApplyMoves(moves1);

            var moves = BoardFutures.GetFallSpringUnitMoves(board);

            Assert.AreEqual(3, moves.Count(m => m.IsDisband));
        }
コード例 #11
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void PreConvoyUnitMove()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("edi", "nth"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);

            Map map = board.GetCurrentConvoyMap();

            Assert.AreEqual(7, map.EdgeCount);
            Assert.AreEqual(94 - 18, map.VertexCount);
        }
コード例 #12
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void UnitMove()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();
            Unit      fleet = board.OccupiedMapNodes[MapNodes.Get("edi")];
            var       edge  = fleet.MyMap.GetEdge("edi", "nth");

            moves.Add(new UnitMove(fleet, edge));
            moves.FillHolds(board);
            board.ApplyMoves(moves);

            Assert.IsTrue(board.OccupiedMapNodes.ContainsKey(MapNodes.Get("nth")));
            Assert.IsFalse(board.OccupiedMapNodes.ContainsKey(MapNodes.Get("edi")));
            Assert.AreEqual(board.OccupiedMapNodes.Count, moves.Count);
        }
コード例 #13
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void BuildUnitMovesArmyNoNcSc()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("tri", "ven"));
            moves.Add(board.GetMove("ven", "pie"));
            moves.Add(board.GetMove("ber", "kie"));
            moves.Add(board.GetMove("kie", "den"));
            moves.Add(board.GetMove("mun", "ruh"));
            moves.Add(board.GetMove("stp_sc", "bot"));
            moves.Add(board.GetMove("sev", "rum"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();


            moves.Clear();
            moves.Add(board.GetMove("bot", "swe"));
            moves.Add(board.GetMove("kie", "hol"));
            moves.Add(board.GetMove("ruh", "bel"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();

            Assert.AreEqual(6, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(6, board.OwnedSupplyCenters[Powers.Russia].Count);
            Assert.AreEqual(2, board.OwnedSupplyCenters[Powers.Italy].Count);
            Assert.AreEqual(4, board.OwnedSupplyCenters[Powers.Austria].Count);

            var unitMoves = BoardFutures.GetWinterUnitMoves(board);

            Assert.IsFalse(unitMoves.Any(um => um.IsBuild &&
                                         um.Unit.UnitType == UnitType.Army &&
                                         um.Edge.Target.ShortName.Contains("_nc")));
        }
コード例 #14
0
ファイル: MoveTests.cs プロジェクト: vfridell/Diplomacy
        public void ConvoyUnitMoveCount()
        {
            Board     board  = Board.GetInitialBoard();
            BoardMove moves1 = new BoardMove();

            moves1.Add(board.GetMove("edi", "nwg"));
            moves1.Add(board.GetMove("lon", "nth"));
            moves1.Add(board.GetMove("lvp", "yor"));
            moves1.FillHolds(board);
            board.ApplyMoves(moves1);

            var moves = BoardFutures.GetFallSpringUnitMoves(board);

            Assert.AreEqual(9, moves.Count(m => m.IsConvoy));
        }
コード例 #15
0
        public IEnumerable <BoardMove> GetBoardMovesWinter(Board board, AllianceScenario allianceScenario)
        {
            if (!(board.Season is Winter))
            {
                throw new Exception($"Bad season {board.Season}");
            }
            List <UnitMove> winterUnitMoves = board.GetUnitMoves();

            if (!winterUnitMoves.Any())
            {
                return(Enumerable.Empty <BoardMove>());
            }

            var           buildDisbandCounts = board.GetBuildAndDisbandCounts();
            BoardMove     workingMove        = new BoardMove();
            List <Powers> completedPowers    = new List <Powers>();

            foreach (UnitMove unitMove in winterUnitMoves.Where(um => !completedPowers.Contains(um.Unit.Power)))
            {
                Powers currentPower = unitMove.Unit.Power;
                if (workingMove.CurrentlyAllowsWinter(unitMove, buildDisbandCounts[currentPower]))
                {
                    workingMove.Add(unitMove);
                    if (workingMove.Count(um => um.Unit.Power == currentPower) == Math.Abs(buildDisbandCounts[currentPower]))
                    {
                        completedPowers.Add(currentPower);
                    }
                }
            }
            if (buildDisbandCounts.Count(kvp => kvp.Value != 0) != completedPowers.Count)
            {
                throw new Exception("Looks like I created an incomplete move");
            }

            workingMove.FillHolds(board);
            return(new List <BoardMove>()
            {
                workingMove
            });
        }
コード例 #16
0
ファイル: MainWindow.xaml.cs プロジェクト: vfridell/Diplomacy
        public MainWindow()
        {
            InitializeComponent();

            Board board = Board.GetInitialBoard();
            //1901 Spring
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("bud", "ser"));
            moves.Add(board.GetMove("edi", "nth"));
            moves.Add(board.GetMove("lvp", "wal"));
            moves.Add(board.GetMove("mar", "spa"));
            moves.Add(board.GetMove("par", "bur"));
            moves.Add(board.GetMove("ber", "kie"));
            moves.Add(board.GetMove("kie", "den"));
            moves.Add(board.GetMove("mun", "ruh"));
            moves.Add(board.GetMove("nap", "ion"));
            moves.Add(board.GetMove("rom", "apu"));
            //A Ven H ? SUCCEEDS
            moves.Add(board.GetMove("mos", "stp"));
            moves.Add(board.GetMove("sev", "rum"));
            moves.Add(board.GetMove("stp_sc", "fin"));
            moves.Add(board.GetMove("war", "lvn"));
            moves.Add(board.GetMove("ank", "con"));
            moves.Add(board.GetMove("con", "bul"));
            //A Smy H ? SUCCEEDS
            moves.FillHolds(board);
            board.ApplyMoves(moves, true);
            board.EndTurn();

            //1901 Fall
            moves = new BoardMove();
            moves.Add(board.GetMove("bul", "gre"));
            moves.Add(board.GetMove("tri", "adr"));
            moves.Add(board.GetMove("vie", "tri"));
            moves.Add(board.GetMove("lon", "nth"));
            moves.Add(board.GetMove("nth", "nwg"));
            moves.Add(board.GetMove("wal", "yor"));
            moves.Add(board.GetMove("bre", "mao"));
            moves.Add(board.GetMove("bur", "bel"));
            //A Spa H ? SUCCEEDS
            moves.Add(board.GetMove("den", "swe"));
            moves.Add(board.GetMove("kie", "mun"));
            moves.Add(board.GetMove("ruh", "hol"));
            moves.Add(board.GetConvoyMove("apu", "tun", "ion"));
            //A Ven H ? SUCCEEDS
            moves.Add(board.GetMove("fin", "bot"));
            //A Lvn H ? SUCCEEDS
            //F Rum H ? SUCCEEDS
            moves.Add(board.GetMove("stp", "nwy"));
            moves.Add(board.GetMove("con", "bul_sc"));
            moves.Add(board.GetMove("smy", "ank"));
            moves.FillHolds(board);
            board.ApplyMoves(moves, true);
            board.EndTurn();

            // 1901 Winter
            moves = new BoardMove();
            moves.Add(board.GetBuildMove("vie", UnitType.Army));
            moves.Add(board.GetBuildMove("bre", UnitType.Fleet));
            moves.Add(board.GetBuildMove("mar", UnitType.Fleet));
            moves.Add(board.GetBuildMove("ber", UnitType.Fleet));
            moves.Add(board.GetBuildMove("kie", UnitType.Fleet));
            moves.Add(board.GetBuildMove("nap", UnitType.Fleet));
            moves.Add(board.GetBuildMove("mos", UnitType.Army));
            moves.Add(board.GetBuildMove("stp_nc", UnitType.Fleet));
            moves.Add(board.GetBuildMove("smy", UnitType.Fleet));
            moves.Add(board.GetBuildMove("con", UnitType.Fleet));
            moves.FillHolds(board);
            board.ApplyMoves(moves, true);
            board.EndTurn();

            //moves.Clear();
            //moves.Add(board.GetMove("bot", "swe"));
            //moves.Add(board.GetMove("kie", "hol"));
            //moves.Add(board.GetMove("ruh", "bel"));
            //moves.FillHolds(board);
            //board.ApplyMoves(moves);
            //board.EndTurn();

            FeatureToolCollection toolCollection = new FeatureToolCollection();

            toolCollection.Add(new RelativeTerritoryStrengths());
            FeatureMeasurementCollection measurements = toolCollection.GetMeasurements(board);

            BoardViewer.Draw(board, measurements);
        }
コード例 #17
0
ファイル: MainWindow.xaml.cs プロジェクト: vfridell/Diplomacy
        private void SetupBoard()
        {
            initialBoard = Board.GetInitialBoard();
            //1901 Spring
            BoardMove moves = new BoardMove();

            moves.Add(initialBoard.GetMove("bud", "ser"));
            moves.Add(initialBoard.GetMove("edi", "nth"));
            moves.Add(initialBoard.GetMove("lvp", "wal"));
            moves.Add(initialBoard.GetMove("mar", "spa"));
            moves.Add(initialBoard.GetMove("par", "bur"));
            moves.Add(initialBoard.GetMove("ber", "kie"));
            moves.Add(initialBoard.GetMove("kie", "den"));
            moves.Add(initialBoard.GetMove("mun", "ruh"));
            moves.Add(initialBoard.GetMove("nap", "ion"));
            moves.Add(initialBoard.GetMove("rom", "apu"));
            //A Ven H ? SUCCEEDS
            moves.Add(initialBoard.GetMove("mos", "stp"));
            moves.Add(initialBoard.GetMove("sev", "rum"));
            moves.Add(initialBoard.GetMove("stp_sc", "fin"));
            moves.Add(initialBoard.GetMove("war", "lvn"));
            moves.Add(initialBoard.GetMove("ank", "con"));
            moves.Add(initialBoard.GetMove("con", "bul"));
            //A Smy H ? SUCCEEDS
            moves.FillHolds(initialBoard);
            initialBoard.ApplyMoves(moves, true);
            initialBoard.EndTurn();

            //1901 Fall
            moves = new BoardMove();
            moves.Add(initialBoard.GetMove("bul", "gre"));
            moves.Add(initialBoard.GetMove("tri", "adr"));
            moves.Add(initialBoard.GetMove("vie", "tri"));
            moves.Add(initialBoard.GetMove("lon", "nth"));
            moves.Add(initialBoard.GetMove("nth", "nwg"));
            moves.Add(initialBoard.GetMove("wal", "yor"));
            moves.Add(initialBoard.GetMove("bre", "mao"));
            moves.Add(initialBoard.GetMove("bur", "bel"));
            //A Spa H ? SUCCEEDS
            moves.Add(initialBoard.GetMove("den", "swe"));
            moves.Add(initialBoard.GetMove("kie", "mun"));
            moves.Add(initialBoard.GetMove("ruh", "hol"));
            moves.Add(initialBoard.GetConvoyMove("apu", "tun", "ion"));
            //A Ven H ? SUCCEEDS
            moves.Add(initialBoard.GetMove("fin", "bot"));
            //A Lvn H ? SUCCEEDS
            //F Rum H ? SUCCEEDS
            moves.Add(initialBoard.GetMove("stp", "nwy"));
            moves.Add(initialBoard.GetMove("con", "bul_sc"));
            moves.Add(initialBoard.GetMove("smy", "ank"));
            moves.FillHolds(initialBoard);
            initialBoard.ApplyMoves(moves, true);
            initialBoard.EndTurn();

            // 1901 Winter
            moves = new BoardMove();
            moves.Add(initialBoard.GetBuildMove("vie", UnitType.Army));
            moves.Add(initialBoard.GetBuildMove("bre", UnitType.Fleet));
            moves.Add(initialBoard.GetBuildMove("mar", UnitType.Fleet));
            moves.Add(initialBoard.GetBuildMove("ber", UnitType.Fleet));
            moves.Add(initialBoard.GetBuildMove("kie", UnitType.Fleet));
            moves.Add(initialBoard.GetBuildMove("nap", UnitType.Fleet));
            moves.Add(initialBoard.GetBuildMove("mos", UnitType.Army));
            moves.Add(initialBoard.GetBuildMove("stp_nc", UnitType.Fleet));
            moves.Add(initialBoard.GetBuildMove("smy", UnitType.Fleet));
            moves.Add(initialBoard.GetBuildMove("con", UnitType.Fleet));
            moves.FillHolds(initialBoard);
            initialBoard.ApplyMoves(moves, true);
            initialBoard.EndTurn();
        }
コード例 #18
0
        public void GenerateWinterMovesCorrectNumberOfBuildsPerPower()
        {
            Board     board = Board.GetInitialBoard();
            BoardMove moves = new BoardMove();

            moves.Add(board.GetMove("ber", "kie"));
            moves.Add(board.GetMove("bud", "rum"));
            moves.Add(board.GetMove("con", "bul"));
            moves.Add(board.GetMove("lvp", "edi"));
            moves.Add(board.GetMove("mar", "pie"));
            moves.Add(board.GetMove("mos", "stp"));
            moves.Add(board.GetMove("mun", "ruh"));
            moves.Add(board.GetMove("par", "gas"));
            moves.Add(board.GetMove("rom", "nap"));
            moves.Add(board.GetMove("ven", "tyr"));
            moves.Add(board.GetMove("vie", "tri"));
            moves.Add(board.GetMove("war", "sil"));
            moves.Add(board.GetMove("ank", "con"));
            moves.Add(board.GetMove("bre", "mao"));
            moves.Add(board.GetMove("edi", "nth"));
            moves.Add(board.GetMove("kie", "den"));
            moves.Add(board.GetMove("lon", "eng"));
            moves.Add(board.GetMove("nap", "tys"));
            moves.Add(board.GetMove("sev", "bla"));
            moves.Add(board.GetMove("stp_sc", "bot"));
            moves.Add(board.GetMove("tri", "alb"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();


            moves.Clear();
            moves.Add(board.GetMove("bul", "gre"));
            moves.Add(board.GetMove("gas", "spa"));
            moves.Add(board.GetMove("kie", "hol"));
            moves.Add(board.GetMove("ruh", "bel"));
            moves.Add(board.GetMove("smy", "arm"));
            moves.Add(board.GetMove("stp", "nwy"));
            moves.Add(board.GetMove("tri", "ser"));
            moves.Add(board.GetMove("bot", "swe"));
            moves.Add(board.GetMove("con", "bul_ec"));
            moves.Add(board.GetMove("mao", "por"));
            moves.Add(board.GetMove("tys", "tun"));
            moves.FillHolds(board);
            board.ApplyMoves(moves);
            board.EndTurn();

            Assert.AreEqual(6, board.OwnedSupplyCenters[Powers.Germany].Count);
            Assert.AreEqual(6, board.OwnedSupplyCenters[Powers.Russia].Count);
            Assert.AreEqual(4, board.OwnedSupplyCenters[Powers.Italy].Count);
            Assert.AreEqual(5, board.OwnedSupplyCenters[Powers.Austria].Count);
            Assert.AreEqual(5, board.OwnedSupplyCenters[Powers.Turkey].Count);
            Assert.AreEqual(3, board.OwnedSupplyCenters[Powers.England].Count);
            Assert.AreEqual(5, board.OwnedSupplyCenters[Powers.France].Count);

            var boardMoves = BoardFutures.GetAllBoardMovesWinter(board);

            Assert.IsTrue(boardMoves.All(bm => bm.Count(um => um.Unit.Power == Powers.Germany) == 6));
            Assert.IsTrue(boardMoves.All(bm => bm.Count(um => um.Unit.Power == Powers.Russia) == 6));
            Assert.IsTrue(boardMoves.All(bm => bm.Count(um => um.Unit.Power == Powers.Italy) == 4));
            Assert.IsTrue(boardMoves.All(bm => bm.Count(um => um.Unit.Power == Powers.Austria) == 5));
            Assert.IsTrue(boardMoves.All(bm => bm.Count(um => um.Unit.Power == Powers.Turkey) == 5));
            Assert.IsTrue(boardMoves.All(bm => bm.Count(um => um.Unit.Power == Powers.England) == 3));
            Assert.IsTrue(boardMoves.All(bm => bm.Count(um => um.Unit.Power == Powers.France) == 5));

            //this is the total for when empty builds are included
            //Assert.AreEqual(1944, boardMoves.Count());
        }