static void Main(string[] args) { BoardPrinter printer = new BoardPrinter(); var othello = new Othello(); othello.Start(Color.White); othello.Set(3, 3); othello.Set(3, 4); othello.Set(4, 4); othello.Set(4, 3); printer.Print("オリジナル", othello); var snapshot = othello.Save(); // 適当に石を追加しておく othello.Set(1, 1); othello.Set(5, 5); othello.Set(7, 7); printer.Print("オリジナル(追加後)", othello); // 復元 var replay = new Othello(); replay.Load(snapshot); printer.Print("復元", replay); }
static void Main(string[] args) { var placements = GameHard(); var board = new GameBoard(placements); var printer = new BoardPrinter(); printer.Print(board); var solver = new Solver(); board = solver.Solve(board); printer.Print(board); }
public void Into_ShouldWriteInto() { string rn = Environment.NewLine; //Arrange CellCollection cellCollection = new CellCollection(new ICell[] { new UnselectedCell(new Glyph('0')), new UnselectedCell(new Glyph('1')), new UnselectedCell(new Glyph('2')), new UnselectedCell(new Glyph('3')), new UnselectedCell(new Glyph('4')), new UnselectedCell(new Glyph('5')), new UnselectedCell(new Glyph('6')), new UnselectedCell(new Glyph('7')), new UnselectedCell(new Glyph('8')) }); FakeWriter fakeWriter = new FakeWriter(); BoardPrinter subject = new BoardPrinter(cellCollection, fakeWriter); //Act subject.Print(); //Assert fakeWriter.AssertLinesWritten($" 0 | 1 | 2{rn}===+===+==={rn} 3 | 4 | 5{rn}===+===+==={rn} 6 | 7 | 8{rn}"); }
static void PrintBoardAfterMove(IPlayerMove move, string playerName, BoardPrinter board) { var piece = board.Get(move.Move.StartPosition.ToTuple()); if (move.Move.PromotionResult != PromotionPieceType.NoPromotion) { if (piece.Contains("w")) { piece = "wQ "; } else { piece = "bQ "; } } // Clear previous move for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (board.Get((i, j)) == BoardPrinter.PreviousTileValue) { board.Set((i, j), " "); break; } } } board.Set(move.Move.StartPosition.ToTuple(), BoardPrinter.PreviousTileValue); board.Set(move.Move.EndPosition.ToTuple(), piece); board.Print(); }
public void ShouldPrintBoard() { const string board = "board"; A.CallTo(() => _boardPrinterDouble.Print(A <Board> ._)).Returns(board); StubBoardIsConquered(); _subject.Start(); A.CallTo(() => _consoleWrapperDouble.Print(board)).MustHaveHappened(); }
public void PrintBoard() { BoardPrinter.Print(Fields); }
public void HandleMessage(Data message) { if (message.PlayerLocation != null) { Player.game.Location = message.PlayerLocation; ConsoleDebug.Message($"My location: ({message.PlayerLocation.x}, {message.PlayerLocation.y})"); } if (message.TaskFields != null) { Common.SchemaWrapper.TaskField[] taskFields = new Common.SchemaWrapper.TaskField[message.TaskFields.Length]; for (int i = 0; i < taskFields.Length; i++) taskFields[i] = new Common.SchemaWrapper.TaskField(message.TaskFields[i]); Player.game.UpdateFields(taskFields); ; } if (message.GoalFields != null) { Common.SchemaWrapper.GoalField[] goalFields = new Common.SchemaWrapper.GoalField[message.GoalFields.Length]; for (int i = 0; i < goalFields.Length; i++) goalFields[i] = new Common.SchemaWrapper.GoalField(message.GoalFields[i]); Player.game.UpdateFields(goalFields); } if (message.Pieces != null) { foreach (Piece piece in message.Pieces) { lock (pieceLock) { if (piece.playerIdSpecified) { Player.game.Pieces = Player.game.Pieces.Where(piece1 => piece1.playerId != piece.playerId).ToList(); } if (Player.game.Pieces.Count(p => p.id == piece.id) == 0) Player.game.Pieces.Add(piece); else { var pp = Player.game.Pieces.Single(p => p.id == piece.id); pp.playerId = piece.playerId; pp.playerIdSpecified = piece.playerIdSpecified; pp.timestamp = piece.timestamp; if (pp.type == PieceType.unknown) pp.type = piece.type; } } } //args.PlayerClient.Pieces.Clear(); //foreach (var piece in message.Pieces) //{ // args.PlayerClient.Pieces.Add(piece); //} } if (message.gameFinished == true) { ConsoleDebug.Good("\nGame just ended\n"); BoardPrinter.Print(Player.game.Fields); Player.RegisterForNextGameAfterGameEnd(); return; } Player.ReadyForAction?.Invoke(); }
public void ShouldPrintBoardHeaderAsFirstRow() { var boardDouble = CreateDummyBoard(); _subject.Print(boardDouble).Should().StartWith(" A B C D E F G H I J"); }
static void Main(string[] args) { RandomGoalBoardGenerator bg = new RandomGoalBoardGenerator(30, 20, 5, 123); BoardPrinter.Print(bg.CreateBoard()); }