I am programming the game Othello in c#. i have managed to generate the grid however the starting pieces are not in the right position. I think it because the indexing from 0 when I want it to start from 1. Can someone try and help me out.
private const string White_piece = "X"; // players piece
private const string Black_piece = "O"; // computers piece
private const string Empty = " ";
const int Row = 9;
const int Column = 9;
private string[,] board = new string[9,9];
public void Draw_Board() // creates the reversi board
{
// Codes row 1-8
for (int Row = 1; Row < board.GetLength(1); Row++)
{
if (Row < 10)
{
Console.Write(" ");
}
Console.Write(String.Format("\t{0}", Row + " |"));
}
Console.WriteLine();
// codes -------------------------------------------------
for (int Row = 1; Row < board.GetLength(1) * 7 + 5; Row++)
{
Console.Write("-");
}
Console.WriteLine();
// codes the column
for (int Column = 1; Column < board.GetLength(1); Column++)
{
// 1| ..........
Console.Write(Column + "|");
for (int Row = 1; Row < board.GetLength(0); Row++)
{
Console.Write(String.Format("\t{0}", " " + " " + "|"));
if (Row == 8)
{
Console.WriteLine();
}
if (board[Row, Column] == White_piece)
{
Console.Write(White_piece);
}
if (board[Row, Column] == Black_piece)
{
Console.Write(Black_piece);
}
}
}
New_coordinate();
}
public void ResetBoard()
{
board[4, 4] = White_piece;
board[5, 4] = Black_piece;
board[4, 5] = Black_piece;
board[5, 5] = White_piece;
}
NKR13 0 Newbie Poster
rproffitt 2,662 "Nothing to see here." Moderator
tinstaafl 1,176 Posting Maven
NKR13 commented: private const int BOARDSIZE = 9; private const string White_piece = "X"; // players piece private const string Black_piece = "O"; // c +0
NKR13 0 Newbie Poster
tinstaafl 1,176 Posting Maven
Reverend Jim commented: They are stars. A Klingon would be a K. +14
NKR13 0 Newbie Poster
tinstaafl 1,176 Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.