tic toe game not working as expected,please help?
-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;namespace tictoegame
{public class gamestart { int functionalcount, computernumber,usernumber; char\[\] box = new char\[9\]; static int j=6; public gamestart() { for(int k=0;k<9;k++) { box\[k\] = ' '; } functionalcount = 0; Random rd = new Random(); while(true) { computernumber = rd.Next(0, 8); if (box\[computernumber\]!='x'&& box\[computernumber\]!='X'&&box\[computernumber\]!='o'&& box\[computernumber\]!='O') { insertvalue(computernumber,Program.computersymbol); break; } } functionalcount++; userturn(); } public void position() { int i=1; Console.CursorLeft=i; Console.CursorTop=j; j++; } public void userturn() { if (functionalcount != 9) { bool flag1 = checkwin(Program.usersymbol); if (flag1) { position(); Console.WriteLine("you won"); Thread.Sleep(3000); Environment.Exit(0); } else { while (true) { position(); Console.WriteLine("enter the number for symbol"); usernumber = Convert.ToInt32(Console.ReadLine()); if (box\[usernumber\] != 'x' || box\[usernumber\] != 'X' && box\[usernumber\] != 'o' || box\[usernumber\] != 'O') { insertvalue(usernumber, Program.usersymbol); functionalcount++; break; } } computerturn(); } } } public void computerturn() { int count=0,i; if (functionalcount == 2) { Random rd = new Random(); while (true) { com
-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;namespace tictoegame
{public class gamestart { int functionalcount, computernumber,usernumber; char\[\] box = new char\[9\]; static int j=6; public gamestart() { for(int k=0;k<9;k++) { box\[k\] = ' '; } functionalcount = 0; Random rd = new Random(); while(true) { computernumber = rd.Next(0, 8); if (box\[computernumber\]!='x'&& box\[computernumber\]!='X'&&box\[computernumber\]!='o'&& box\[computernumber\]!='O') { insertvalue(computernumber,Program.computersymbol); break; } } functionalcount++; userturn(); } public void position() { int i=1; Console.CursorLeft=i; Console.CursorTop=j; j++; } public void userturn() { if (functionalcount != 9) { bool flag1 = checkwin(Program.usersymbol); if (flag1) { position(); Console.WriteLine("you won"); Thread.Sleep(3000); Environment.Exit(0); } else { while (true) { position(); Console.WriteLine("enter the number for symbol"); usernumber = Convert.ToInt32(Console.ReadLine()); if (box\[usernumber\] != 'x' || box\[usernumber\] != 'X' && box\[usernumber\] != 'o' || box\[usernumber\] != 'O') { insertvalue(usernumber, Program.usersymbol); functionalcount++; break; } } computerturn(); } } } public void computerturn() { int count=0,i; if (functionalcount == 2) { Random rd = new Random(); while (true) { com
You haven't said what the problem really is, so how do you think we can help? You need to debug your application and try to narrow down what is happening yourself.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;namespace tictoegame
{public class gamestart { int functionalcount, computernumber,usernumber; char\[\] box = new char\[9\]; static int j=6; public gamestart() { for(int k=0;k<9;k++) { box\[k\] = ' '; } functionalcount = 0; Random rd = new Random(); while(true) { computernumber = rd.Next(0, 8); if (box\[computernumber\]!='x'&& box\[computernumber\]!='X'&&box\[computernumber\]!='o'&& box\[computernumber\]!='O') { insertvalue(computernumber,Program.computersymbol); break; } } functionalcount++; userturn(); } public void position() { int i=1; Console.CursorLeft=i; Console.CursorTop=j; j++; } public void userturn() { if (functionalcount != 9) { bool flag1 = checkwin(Program.usersymbol); if (flag1) { position(); Console.WriteLine("you won"); Thread.Sleep(3000); Environment.Exit(0); } else { while (true) { position(); Console.WriteLine("enter the number for symbol"); usernumber = Convert.ToInt32(Console.ReadLine()); if (box\[usernumber\] != 'x' || box\[usernumber\] != 'X' && box\[usernumber\] != 'o' || box\[usernumber\] != 'O') { insertvalue(usernumber, Program.usersymbol); functionalcount++; break; } } computerturn(); } } } public void computerturn() { int count=0,i; if (functionalcount == 2) { Random rd = new Random(); while (true) { com
For comparision you can look at http://www.hugetiger.com/FSetup/Tic2D-Detail.aspx[^]