static void Main(string[] args) { //Main setup program char playAgain = 'y'; while (playAgain != 'n') { Program nim = new Program(); Game Nim = new Game(); List<List<int>> list = new List<List<int>>(); int piles, sticks; string num; bool turn = true; Console.Clear(); nim.gameIntro(); Console.Out.Write("\n\n How many Piles for today's game? "); num = Console.ReadLine(); piles = Convert.ToInt32(num); //Sets up the initial array for playing field int[] numOfPiles = new int[piles]; int pileNumber = 1; for (int i = 0; i < numOfPiles.Length; i++) { Console.Out.Write(" Enter the number sticks for pile " + pileNumber + ": "); // May want to get rid of piles num = Console.ReadLine(); sticks = Convert.ToInt32(num); numOfPiles[i] = sticks; pileNumber++; } turn = Nim.playerOrder(); //Console.Out.WriteLine("This needs to get put into arry: {0}", Nim.compDecide(Nim.getIndicator(numOfPiles),numOfPiles)); //to test the elements of the array. Console.Clear(); Console.Out.WriteLine("Sticks in each pile: \n"); for (int i = 0; i < numOfPiles.Length; i++) { Console.Out.Write("Pile " + (i+1) + ": " + numOfPiles[i] + " \n"); } while (Nim.getWinner(numOfPiles) == false)//winner method) { if (turn) { //method that handles player turn Console.Clear(); Console.Out.WriteLine("Sticks in each pile: \n"); for (int i = 0; i < numOfPiles.Length; i++) { Console.Out.Write("Pile " + (i + 1) + ": " + numOfPiles[i] + " \n"); } Console.Out.WriteLine("\n************************"); Console.Out.WriteLine("Player turn"); numOfPiles[Nim.choosePile(numOfPiles) - 1] -= Nim.chooseSticks(); ; //test to see if num of sticks is decreased from correct pile. //Console.Out.Write("Nuber of sticks in each pile: "); //for (int i = 0; i < numOfPiles.Length; i++) //{ // Console.Out.WriteLine(numOfPiles[i] + " "); //} turn = false; } else { //put computer turn here //Console.Out.WriteLine("Computer turn"); Nim.compDecide(Nim.getIndicator(numOfPiles), numOfPiles); //Console.Out.Write("Nuber of sticks in each pile: "); //for (int i = 0; i < numOfPiles.Length; i++) //{ // Console.Out.Write(numOfPiles[i] + " "); //} turn = true; } } //test to see winner playAgain = winner(turn); } progTerm(); //Terminate program }
static void Main(string[] args) { //Main setup program char playAgain = 'y'; while (playAgain != 'n') { Program nim = new Program(); Game Nim = new Game(); List <List <int> > list = new List <List <int> >(); int piles, sticks; string num; bool turn = true; Console.Clear(); nim.gameIntro(); Console.Out.Write("\n\n How many Piles for today's game? "); num = Console.ReadLine(); piles = Convert.ToInt32(num); //Sets up the initial array for playing field int[] numOfPiles = new int[piles]; int pileNumber = 1; for (int i = 0; i < numOfPiles.Length; i++) { Console.Out.Write(" Enter the number sticks for pile " + pileNumber + ": "); // May want to get rid of piles num = Console.ReadLine(); sticks = Convert.ToInt32(num); numOfPiles[i] = sticks; pileNumber++; } turn = Nim.playerOrder(); //Console.Out.WriteLine("This needs to get put into arry: {0}", Nim.compDecide(Nim.getIndicator(numOfPiles),numOfPiles)); //to test the elements of the array. Console.Clear(); Console.Out.WriteLine("Sticks in each pile: \n"); for (int i = 0; i < numOfPiles.Length; i++) { Console.Out.Write("Pile " + (i + 1) + ": " + numOfPiles[i] + " \n"); } while (Nim.getWinner(numOfPiles) == false)//winner method) { if (turn) { //method that handles player turn Console.Clear(); Console.Out.WriteLine("Sticks in each pile: \n"); for (int i = 0; i < numOfPiles.Length; i++) { Console.Out.Write("Pile " + (i + 1) + ": " + numOfPiles[i] + " \n"); } Console.Out.WriteLine("\n************************"); Console.Out.WriteLine("Player turn"); numOfPiles[Nim.choosePile(numOfPiles) - 1] -= Nim.chooseSticks();; //test to see if num of sticks is decreased from correct pile. //Console.Out.Write("Nuber of sticks in each pile: "); //for (int i = 0; i < numOfPiles.Length; i++) //{ // Console.Out.WriteLine(numOfPiles[i] + " "); //} turn = false; } else { //put computer turn here //Console.Out.WriteLine("Computer turn"); Nim.compDecide(Nim.getIndicator(numOfPiles), numOfPiles); //Console.Out.Write("Nuber of sticks in each pile: "); //for (int i = 0; i < numOfPiles.Length; i++) //{ // Console.Out.Write(numOfPiles[i] + " "); //} turn = true; } } //test to see winner playAgain = winner(turn); } progTerm(); //Terminate program }