public void Checker_ConvertsTakeCheckerAndActsAsQueen_ShouldTakeSecondChecker() { // Arrange var mainPlayCheckers = new List <CheckerModel>() { new CheckerModel(5, 5, PieceType.Checker, Side.White), }; var secondPlayerCheckers = new List <CheckerModel>() { new CheckerModel(4, 6, PieceType.Checker, Side.Black), new CheckerModel(1, 5, PieceType.Checker, Side.Black), }; DataProvider dataProvider = new DataProvider(mainPlayCheckers, secondPlayerCheckers); var mainPlayer = new MainPlayer(dataProvider, Side.White); var robotPlayer = new RobotPlayer(dataProvider, Side.Black); var emptyPlayer = new EmptyUserPlayer(dataProvider); var game = new RussianCheckers.Core.Game(mainPlayer, robotPlayer, emptyPlayer, dataProvider); // Act game.ReCalculateNeighborsAndPaths(); // Assert var availablePaths = mainPlayer.CalculateAvailablePaths(); Assert.IsTrue(availablePaths.Any(x => x.Last.Value.Column == 0 && x.Last.Value.Row == 4)); }
public void CalculateAvailablePaths_Returns_Paths_MaxIs_9() { // Arrange var mainPlayCheckers = new List <CheckerModel>() { new CheckerModel(4, 2, PieceType.Checker, Side.White), }; var secondPlayerCheckers = new List <CheckerModel>() { new CheckerModel(3, 3, PieceType.Checker, Side.Black), new CheckerModel(5, 3, PieceType.Checker, Side.Black), new CheckerModel(3, 5, PieceType.Checker, Side.Black), new CheckerModel(5, 5, PieceType.Checker, Side.Black), new CheckerModel(1, 5, PieceType.Checker, Side.Black), }; DataProvider dataProvider = new DataProvider(mainPlayCheckers, secondPlayerCheckers); var mainPlayer = new MainPlayer(dataProvider, Side.White); var robotPlayer = new RobotPlayer(dataProvider, Side.Black); var emptyPlayer = new EmptyUserPlayer(dataProvider); // Act var game = new RussianCheckers.Core.Game(mainPlayer, robotPlayer, emptyPlayer, dataProvider); game.ReCalculateNeighborsAndPaths(); var availablePathsForWhite = mainPlayer.CalculateAvailablePaths(); // Assert Assert.AreEqual(9, availablePathsForWhite.Max(x => x.Count)); }
public void CalculateAvailableForQueen_SameBehaviorAsChecker_ShouldBe_23() { // Arrange var mainPlayCheckers = new List <CheckerModel>() { new CheckerModel(4, 2, PieceType.Queen, Side.White), }; var secondPlayerCheckers = new List <CheckerModel>() { new CheckerModel(3, 3, PieceType.Checker, Side.Black), new CheckerModel(5, 3, PieceType.Checker, Side.Black), new CheckerModel(3, 5, PieceType.Checker, Side.Black), new CheckerModel(5, 5, PieceType.Checker, Side.Black), new CheckerModel(1, 5, PieceType.Checker, Side.Black), new CheckerModel(5, 1, PieceType.Checker, Side.Black), }; DataProvider dataProvider = new DataProvider(mainPlayCheckers, secondPlayerCheckers); var mainPlayer = new MainPlayer(dataProvider, Side.White); var robotPlayer = new RobotPlayer(dataProvider, Side.Black); var emptyPlayer = new EmptyUserPlayer(dataProvider); var game = new RussianCheckers.Core.Game(mainPlayer, robotPlayer, emptyPlayer, dataProvider); // Act game.ReCalculateNeighborsAndPaths(); // Assert var availablePaths = mainPlayer.CalculateAvailablePaths(); Assert.AreEqual(23, availablePaths.Count()); }
public void CalculateAvailableForQueen_ThreeBlackCheckers_Should_Have_5_Paths() { // Arrange var mainPlayCheckers = new List <CheckerModel> { new CheckerModel(4, 6, PieceType.Queen, Side.White) }; var secondPlayerCheckers = new List <CheckerModel>() { new CheckerModel(2, 4, PieceType.Checker, Side.Black), new CheckerModel(1, 1, PieceType.Checker, Side.Black), new CheckerModel(6, 4, PieceType.Checker, Side.Black), }; DataProvider dataProvider = new DataProvider(mainPlayCheckers, secondPlayerCheckers); var mainPlayer = new MainPlayer(dataProvider, Side.White); var robotPlayer = new RobotPlayer(dataProvider, Side.Black); var emptyPlayer = new EmptyUserPlayer(dataProvider); var game = new RussianCheckers.Core.Game(mainPlayer, robotPlayer, emptyPlayer, dataProvider); // Act game.ReCalculateNeighborsAndPaths(); // Assert var availablePaths = mainPlayer.CalculateAvailablePaths(); Assert.AreEqual(5, availablePaths.Count()); }
public MainWindow() { InitializeComponent(); var dialogService = new DialogService(this); dialogService.Register <NotificationDialogViewModel, NotificationDialog>(); dialogService.Register <ChooseDialogViewModel, ChooseSideDialog>(); SourceInitialized += (sender, args) => { var chooseDialogViewModel = new ChooseDialogViewModel(); dialogService.ShowDialog(chooseDialogViewModel); Side userSide = chooseDialogViewModel.Side; //// Side userSide = Side.White; // // var mainPlayCheckers = new List<CheckerModel>() // { // new CheckerModel(1, 1, PieceType.Checker, Side.Black), // new CheckerModel(1, 3, PieceType.Checker, Side.Black), // new CheckerModel(3, 3, PieceType.Checker, Side.Black), // new CheckerModel(5, 3, PieceType.Checker, Side.Black), // new CheckerModel(7, 1, PieceType.Checker, Side.Black), // }; // var secondPlayerCheckers = new List<CheckerModel>() // { // new CheckerModel(4, 4, PieceType.Checker, Side.White), // }; // DataProvider dataProvider = new DataProvider(mainPlayCheckers, secondPlayerCheckers); // var mainPlayer = new MainPlayer(dataProvider, Side.Black); // var robotPlayer = new RobotPlayer(dataProvider, Side.White, new MinMaxStrategy()); // var emptyPlayer = new EmptyUserPlayer(dataProvider); var dataProvider = new DataProvider(userSide); var mainPlayer = new MainPlayer(dataProvider, userSide); var robotPlayer = new RobotPlayer(dataProvider, userSide == Side.White? Side.Black:Side.White, new MinMaxStrategy()); var emptyPlayer = new EmptyUserPlayer(dataProvider); var game = new Core.Game(mainPlayer, robotPlayer, emptyPlayer, dataProvider); game.ReCalculateNeighborsAndPaths(); this.DataContext = new GameViewModel(game, dialogService, true); }; }