本文整理匯總了C#中Board.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Board.ToString方法的具體用法?C# Board.ToString怎麽用?C# Board.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Board
的用法示例。
在下文中一共展示了Board.ToString方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Start
void Start()
{
var save = SaveManager.GetLatestSave();
if (save != null) {
SaveManager.SetCurrentSave(save);
}
Board board = new Board();
Debug.Log(board.ToString(StringOpts.Pretty));
board.Fetch("{9A69826B-5BC5-4F89-9066-6D52D598979B}");
Debug.Log(board.ToString(StringOpts.Pretty));
if (save == null) {
board.Name = "changedName";
board.Save();
save = SaveManager.CreateSave();
GameState.Save(save);
Debug.Log("Saving to " + save.Filename);
} else {
GameState.Load(save);
board.Fetch("{9A69826B-5BC5-4F89-9066-6D52D598979B}");
Debug.Log(board.ToString(StringOpts.Pretty));
Debug.Log(board.ToString(StringOpts.Identifier));
}
}
示例2: TestBoardToString_BoardSize1
public void TestBoardToString_BoardSize1()
{
Board gameBoard = new Board(1);
StringBuilder expectedBoardToString = new StringBuilder();
expectedBoardToString.AppendLine(" 0");
expectedBoardToString.AppendLine(" -");
expectedBoardToString.AppendLine("0|" + gameBoard.GameBoard[0, 0] + " ");
string boardToString = gameBoard.ToString();
Assert.AreEqual(expectedBoardToString.ToString(), boardToString);
}
示例3: _002_Can_Display_Board
public void _002_Can_Display_Board()
{
var board = new Board();
const string expected = "_Y_Y_Y_Y\r\n" +
"Y_Y_Y_Y_\r\n" +
"_Y_Y_Y_Y\r\n" +
"Y_Y_Y_Y_\r\n" +
"_Y_Y_Y_Y\r\n" +
"Y_Y_Y_Y_\r\n" +
"_Y_Y_Y_Y\r\n" +
"Y_Y_Y_Y_\r\n";
//const string expected =
//"\r\n A B C D E F G H \r\n" +
//"\r\n" +
//" \r\n" +
//" 8 8 \r\n" +
//" \r\n" +
//" \r\n" +
//" 7 7 \r\n" +
//" \r\n" +
//" \r\n" +
//" 6 6 \r\n" +
//" \r\n" +
//" \r\n" +
//" 5 5 \r\n" +
//" \r\n" +
//" \r\n" +
//" 4 4 \r\n" +
//" \r\n" +
//" \r\n" +
//" 3 3 \r\n" +
//" \r\n" +
//" \r\n" +
//" 2 2 \r\n" +
//" \r\n" +
//" \r\n" +
//" 1 1 \r\n" +
//" \r\n" +
//"\r\n" +
//" A B C D E F G H \r\n";
Assert.AreEqual(expected, board.ToString());
}
示例4: TestBoard
public void TestBoard()
{
Console.WriteLine("TestBoard");
Board b = new Board();
Console.WriteLine("Board created");
Console.Write(b.GetBoardPic());
Assert.AreEqual(b.GetSpace(4, 4).GetSpaceState(), 'T');
Assert.AreNotEqual(b.GetSpace(3, 3).GetSpaceState(), 'T');
Console.WriteLine("Spaces adjacent to " + b.ToString());
foreach (CoordinatePair c in b.GetAdjacentList(3, 3))
{
Console.Write(c.ToString());
}
Assert.AreEqual(b.GetAdjacentList(2, 2).Count, 8);
Assert.AreEqual(b.GetAdjacentList(4, 4).Count, 3);
Assert.AreNotEqual(b.GetAdjacentList(0, 2).Count, 4);
}
示例5: FindSolutions
public void FindSolutions()
{
Console.WriteLine("Finding next solution...");
board = board ?? new Board();
while (!board.IsSolution && !board.IsFinished)
{
if (!board.HasAttacks)
{
Console.WriteLine(board.ToString());
}
board.Increment();
}
if (!board.IsFinished)
{
Console.WriteLine("Solution #{0} Found!", SolutionsFound);
board.Increment();
FindSolutions();
}
}
示例6: ToString_EqualsName
public void ToString_EqualsName()
{
var board = new Board { Name = "a name" };
Assert.That(board.ToString(), Is.EqualTo("a name"));
}
示例7: checkDevice
private void checkDevice()
{
send(Code.GET_DEVICE);
send(Code.EOC);
id = (Board)recv();
freq = (Frequency)recv();
log("Connected to board "+ id+ " freq "+ freq);
// XXX should be getting valid board/frequency data from firmware file
if ((id != Board.DEVICE_ID_HM_TRP) && (id != Board.DEVICE_ID_RF50) && (id != Board.DEVICE_ID_RFD900) && (id != Board.DEVICE_ID_RFD900A))
throw new Exception("bootloader device ID mismatch - device:" + id.ToString());
getSync();
}
示例8: TestMove
public void TestMove( string boardStr, Move move, bool expectedValid, string expected )
{
var board = new Board();
board.Load( boardStr );
bool valid = board.MakeMove( move );
Assert.AreEqual( expectedValid, valid );
if ( valid )
{
Assert.AreEqual( expected, board.ToString() );
}
else
{
// Make sure it hasn't changed
Assert.AreEqual( boardStr, board.ToString() );
}
}
示例9: TestLoadRunLengthEncodedBoards
public void TestLoadRunLengthEncodedBoards( string rleBoard, string expected )
{
var board = new Board();
board.Load( rleBoard );
Assert.AreEqual( expected, board.ToString() );
}
示例10: TestLoad
public void TestLoad( string boardStr, string expected )
{
var board = new Board();
board.Load( boardStr );
Assert.AreEqual( expected, board.ToString() );
}
示例11: SimpleBoardAsString
public void SimpleBoardAsString()
{
Board b = new Board();
Console.WriteLine(b.ToString());
Assert.IsNotNull(b.ToString());
}
示例12: TestBoardToString_BoardSize10
public void TestBoardToString_BoardSize10()
{
Board gameBoard = new Board(10);
StringBuilder expectedBoardToString = new StringBuilder();
expectedBoardToString.AppendLine(" 0 1 2 3 4 5 6 7 8 9");
expectedBoardToString.AppendLine(" -------------------");
expectedBoardToString.AppendLine("0|" + gameBoard.GameBoard[0, 0] + " " + gameBoard.GameBoard[0, 1] + " " +
gameBoard.GameBoard[0, 2] + " " +
gameBoard.GameBoard[0, 3] + " " + gameBoard.GameBoard[0, 4] + " " +
gameBoard.GameBoard[0, 5] + " " +
gameBoard.GameBoard[0, 6] + " " + gameBoard.GameBoard[0, 7] + " " +
gameBoard.GameBoard[0, 8] + " " +
gameBoard.GameBoard[0, 9] + " ");
expectedBoardToString.AppendLine("1|" + gameBoard.GameBoard[1, 0] + " " + gameBoard.GameBoard[1, 1] + " " +
gameBoard.GameBoard[1, 2] + " " +
gameBoard.GameBoard[1, 3] + " " + gameBoard.GameBoard[1, 4] + " " +
gameBoard.GameBoard[1, 5] + " " +
gameBoard.GameBoard[1, 6] + " " + gameBoard.GameBoard[1, 7] + " " +
gameBoard.GameBoard[1, 8] + " " +
gameBoard.GameBoard[1, 9] + " ");
expectedBoardToString.AppendLine("2|" + gameBoard.GameBoard[2, 0] + " " + gameBoard.GameBoard[2, 1] + " " +
gameBoard.GameBoard[2, 2] + " " +
gameBoard.GameBoard[2, 3] + " " + gameBoard.GameBoard[2, 4] + " " +
gameBoard.GameBoard[2, 5] + " " +
gameBoard.GameBoard[2, 6] + " " + gameBoard.GameBoard[2, 7] + " " +
gameBoard.GameBoard[2, 8] + " " +
gameBoard.GameBoard[2, 9] + " ");
expectedBoardToString.AppendLine("3|" + gameBoard.GameBoard[3, 0] + " " + gameBoard.GameBoard[3, 1] + " " +
gameBoard.GameBoard[3, 2] + " " +
gameBoard.GameBoard[3, 3] + " " + gameBoard.GameBoard[3, 4] + " " +
gameBoard.GameBoard[3, 5] + " " +
gameBoard.GameBoard[3, 6] + " " + gameBoard.GameBoard[3, 7] + " " +
gameBoard.GameBoard[3, 8] + " " +
gameBoard.GameBoard[3, 9] + " ");
expectedBoardToString.AppendLine("4|" + gameBoard.GameBoard[4, 0] + " " + gameBoard.GameBoard[4, 1] + " " +
gameBoard.GameBoard[4, 2] + " " +
gameBoard.GameBoard[4, 3] + " " + gameBoard.GameBoard[4, 4] + " " +
gameBoard.GameBoard[4, 5] + " " +
gameBoard.GameBoard[4, 6] + " " + gameBoard.GameBoard[4, 7] + " " +
gameBoard.GameBoard[4, 8] + " " +
gameBoard.GameBoard[4, 9] + " ");
expectedBoardToString.AppendLine("5|" + gameBoard.GameBoard[5, 0] + " " + gameBoard.GameBoard[5, 1] + " " +
gameBoard.GameBoard[5, 2] + " " +
gameBoard.GameBoard[5, 3] + " " + gameBoard.GameBoard[5, 4] + " " +
gameBoard.GameBoard[5, 5] + " " +
gameBoard.GameBoard[5, 6] + " " + gameBoard.GameBoard[5, 7] + " " +
gameBoard.GameBoard[5, 8] + " " +
gameBoard.GameBoard[5, 9] + " ");
expectedBoardToString.AppendLine("6|" + gameBoard.GameBoard[6, 0] + " " + gameBoard.GameBoard[6, 1] + " " +
gameBoard.GameBoard[6, 2] + " " +
gameBoard.GameBoard[6, 3] + " " + gameBoard.GameBoard[6, 4] + " " +
gameBoard.GameBoard[6, 5] + " " +
gameBoard.GameBoard[6, 6] + " " + gameBoard.GameBoard[6, 7] + " " +
gameBoard.GameBoard[6, 8] + " " +
gameBoard.GameBoard[6, 9] + " ");
expectedBoardToString.AppendLine("7|" + gameBoard.GameBoard[7, 0] + " " + gameBoard.GameBoard[7, 1] + " " +
gameBoard.GameBoard[7, 2] + " " +
gameBoard.GameBoard[7, 3] + " " + gameBoard.GameBoard[7, 4] + " " +
gameBoard.GameBoard[7, 5] + " " +
gameBoard.GameBoard[7, 6] + " " + gameBoard.GameBoard[7, 7] + " " +
gameBoard.GameBoard[7, 8] + " " +
gameBoard.GameBoard[7, 9] + " ");
expectedBoardToString.AppendLine("8|" + gameBoard.GameBoard[8, 0] + " " + gameBoard.GameBoard[8, 1] + " " +
gameBoard.GameBoard[8, 2] + " " +
gameBoard.GameBoard[8, 3] + " " + gameBoard.GameBoard[8, 4] + " " +
gameBoard.GameBoard[8, 5] + " " +
gameBoard.GameBoard[8, 6] + " " + gameBoard.GameBoard[8, 7] + " " +
gameBoard.GameBoard[8, 8] + " " +
gameBoard.GameBoard[8, 9] + " ");
expectedBoardToString.AppendLine("9|" + gameBoard.GameBoard[9, 0] + " " + gameBoard.GameBoard[9, 1] + " " +
gameBoard.GameBoard[9, 2] + " " +
gameBoard.GameBoard[9, 3] + " " + gameBoard.GameBoard[9, 4] + " " +
gameBoard.GameBoard[9, 5] + " " +
gameBoard.GameBoard[9, 6] + " " + gameBoard.GameBoard[9, 7] + " " +
gameBoard.GameBoard[9, 8] + " " +
gameBoard.GameBoard[9, 9] + " ");
string boardToString = gameBoard.ToString();
Assert.AreEqual(expectedBoardToString.ToString(), boardToString);
}
示例13: TestBoardToString_BoardSize3
public void TestBoardToString_BoardSize3()
{
Board gameBoard = new Board(3);
StringBuilder expectedBoardToString = new StringBuilder();
expectedBoardToString.AppendLine(" 0 1 2");
expectedBoardToString.AppendLine(" -----");
expectedBoardToString.AppendLine("0|" + gameBoard.GameBoard[0, 0] + " " + gameBoard.GameBoard[0, 1] + " " +
gameBoard.GameBoard[0, 2] + " ");
expectedBoardToString.AppendLine("1|" + gameBoard.GameBoard[1, 0] + " " + gameBoard.GameBoard[1, 1] + " " +
gameBoard.GameBoard[1, 2] + " ");
expectedBoardToString.AppendLine("2|" + gameBoard.GameBoard[2, 0] + " " + gameBoard.GameBoard[2, 1] + " " +
gameBoard.GameBoard[2, 2] + " ");
string boardToString = gameBoard.ToString();
Assert.AreEqual(expectedBoardToString.ToString(), boardToString);
}
示例14: AddMissingChequers
/// <summary>
/// Add missing chequers so that all we need is to know if a slot has 5 chequers and the total pip count.
/// </summary>
/// <param name="board"></param>
/// <param name="pips">pips[0] should contain total pip count for board[0].</param>
public static void AddMissingChequers(ref Board board, int[] pips)
{
List<int> bulk_points = new List<int>();
int total_count, missing, missing_pips, count;
Console.WriteLine(board.ToString());
for (int p = 0; p < 2; p++)
{
bulk_points.Clear();
total_count = 0;
// Assumes we always get the right finished counts.
total_count += board.FinishedCount(p);
// But not captured.
total_count += board.CapturedCount(p);
if (board.CapturedCount(p) == 5)
bulk_points.Add(24);
for (int point = 0; point < 24; point++)
{
count = board.PointCount(p, point);
//Console.WriteLine(count);
if (count > 0)
total_count += count;
if (count == 5)
bulk_points.Add(point);
}
missing = 15 - total_count;
if (missing > 0)
{
if (bulk_points.Count == 1)
{
Console.WriteLine("bulk points = 1");
if (bulk_points[0] == 24)
board.IncreaseCaptured(p, missing);
else
board.AddToPoint(p, bulk_points[0], missing);
continue;
}
if (bulk_points.Count == 2)
{
Console.WriteLine("bulk points = 2");
missing_pips = pips[p] - board.PipCount(p);
int slot1 = bulk_points[0] + 1;
int slot2 = bulk_points[1] + 1;
int slot1_missing = (missing_pips - slot2 * missing) / (slot1 - slot2);
int slot2_missing = (missing_pips - slot1 * slot1_missing) / slot2;
if ((missing_pips - slot2 * missing) % (slot1 - slot2) != 0 ||
(missing_pips - slot1 * slot1_missing) % slot2 != 0)
{
throw new Exception("Missmatch in AddMissingChequers(). Players {" + p + "}, Missing pips {" + missing_pips + "}, missing {" + missing + "} slot1 {" + slot1 + "} slot2 {" + slot2 + "}");
}
if (slot1 == 25)
board.IncreaseCaptured(p, slot1_missing);
else
board.AddToPoint(p, slot1 - 1, slot1_missing);
if (slot2 == 25)
board.IncreaseCaptured(p, slot2_missing);
else
board.AddToPoint(p, slot2 - 1, slot2_missing);
}
}
}
}