Question:For some treason it tells me the aray is to small.
“Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Program.ceackforablock(Boolean[,] inputaray) in /home/runner/ticktactoe/main.cs:line 37
at Program.Main(String[] args) in /home/runner/ticktactoe/main.cs:line 9”
Repl link:https://replit.com/@Josephyc/ticktactoe
public static void Main(string[] args)
{
Console.WriteLine("Hello World");
bool[,] ticktactoebourd = {{true,true,false},{true,true,false},{true,true,false}};
ceackforablock(ticktactoebourd);
}
static public bool ceackforablock(bool[,] inputaray)
{
bool[,] isblockedaray = { { false, false, false }, { false, false, false }, { false, false, false } };
bool isbloked = false;
int x = -1;
int y = 0;
int isthisthefirstone = 0;
if (isthisthefirstone == 0)
{
foreach (bool input in inputaray)
{
bool isyesinputturn = false;
if (x == 2)
{
y++;
x = -1;
}
if (x > 3)
{
x++;
}
if(y == 3){
y=0;
}
if (input)
{
isblockedaray[x, y] = true;
isyesinputturn = true;
}
if (!(input) && (isyesinputturn = false))
{
isblockedaray[x, y] = false;
isyesinputturn = false;
}
isyesinputturn = false;
}
}
if (isthisthefirstone > 0)
{
foreach (bool input2 in inputaray)
{
if (x == 2)
{
y++;
x = -1;
}
if (x > 3)
{
x++;
}
if(y == 2){
y=0;
}
if (input2 == true && isblockedaray[x, y] == true)
{
return isbloked = true;
}
if ((input2 == false && isblockedaray[x, y] == true) || (input2 == true && isblockedaray[x, y] == false))
{
return isbloked = false;
}
}
}
return isbloked;
}