Tic Tac Toe VS A.I

What's the easiest way to create A.I so the user plays against the machine?

namespace Galinho
{ class Program
{
public static void Main(string[] args)
{
Console.WriteLine("TicTacToe Player VS Hard Bot");
System.Threading.Thread.Sleep(1000);
Console.Clear();
char[,]huy= new char [3,3];
do{
Console.WriteLine();
Console.WriteLine(" {0} | {1} | {2} ",huy[0,0],huy[0,1],huy[0,2]);
Console.WriteLine("________");
Console.WriteLine(" {0} | {1} | {2} ",huy[1,0],huy[1,1],huy[1,2]);
Console.WriteLine("
________");
Console.WriteLine(" {0} | {1} | {2} ",huy[2,0],huy[2,1],huy[2,2]); int numeroJogada = Convert.ToInt16(Console.ReadLine()); if (numeroJogada==11){ huy[0,0] = 'x'; } else if (numeroJogada==12){ huy[0,1] = 'x'; } else if (numeroJogada==13){ huy[0,2] = 'x'; } else if (numeroJogada==21){ huy[1,0] = 'x'; } else if (numeroJogada==22){ huy[1,1] = 'x'; } else if (numeroJogada==23){ huy[1,2] = 'x'; } else if (numeroJogada==31){ huy[2,0] = 'x'; } else if (numeroJogada==32){ huy[2,1] = 'x'; } else if (numeroJogada==33){ huy[2,2] = 'x'; } Console.Clear(); }while(true);

 Console.ReadKey(); } } 

}

by sweetbabyblackjesus via /r/csharp

Leave a Reply