public static void newGame(Grid game) { bool GameLoop = true; while (GameLoop) { game.displayGrid(); Console.Write("Enter Move ( as 'x y' ): "); string move = Console.ReadLine(); string[] coord = move.Split(' '); Int32 val; if ((coord.Length == 2) && (Int32.TryParse(coord[0], out val) && Int32.TryParse(coord[1], out val)) && game.checkMove(Int32.Parse(coord[0]), Int32.Parse(coord[1]))) { game.removeGroup(Int32.Parse(coord[0]), Int32.Parse(coord[1])); game.Logger.addLog("MOVE: (" + coord[0] + "," + coord[1] + ")"); game.Logger.addLog(" --Points: " + game.calculatePoints()); } else { Console.WriteLine("Invalid Move! Try again!"); } game.compressGrid(); if (game.checkWin()) { GameLoop = false; Console.WriteLine("You Win!"); game.Logger.addLog("GAME WIN: All bubbles eliminated"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } else if (game.checkLocked()) { GameLoop = false; //display final game board showing locked game game.displayGrid(); Console.WriteLine("You Lose!"); game.Logger.addLog("GAME LOSS: Gameboard locked!"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } } }
public static void newGame(Grid game) { bool GameLoop = true; while (GameLoop) { game.displayGrid(); Console.Write("Enter Move ( as 'x y' ): "); string move = Console.ReadLine(); string[] coord = move.Split(' '); Int32 val; if((coord.Length==2) && (Int32.TryParse(coord[0], out val) && Int32.TryParse(coord[1], out val)) && game.checkMove(Int32.Parse(coord[0]), Int32.Parse(coord[1]))) { game.removeGroup(Int32.Parse(coord[0]), Int32.Parse(coord[1])); game.Logger.addLog("MOVE: (" + coord[0] + "," + coord[1] + ")"); game.Logger.addLog(" --Points: " + game.calculatePoints()); } else { Console.WriteLine("Invalid Move! Try again!"); } game.compressGrid(); if (game.checkWin()) { GameLoop = false; Console.WriteLine("You Win!"); game.Logger.addLog("GAME WIN: All bubbles eliminated"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } else if (game.checkLocked()) { GameLoop = false; //display final game board showing locked game game.displayGrid(); Console.WriteLine("You Lose!"); game.Logger.addLog("GAME LOSS: Gameboard locked!"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } } }
public static void newAIGame(Grid game) { bool GameLoop = true; bool list = false; AI blue = new AI(50); Stack <MoveNode> moves = new Stack <MoveNode>(); if ((game.Colors <= 5 && game.X < 7) || (game.Colors < 4 && game.X <= 15)) { MoveNode move = blue.solveTree(game); if (move != null) { list = true; while (move != null) { moves.Push(move); move = move.PreviousMove; } } } while (GameLoop) { int[] nextMove; game.displayGrid(); if (list) { nextMove = new int[2]; MoveNode cur = moves.Pop(); nextMove[0] = cur.Group.X; nextMove[1] = cur.Group.Y; } else { nextMove = blue.makeNextMove(game); } Console.WriteLine("AI makes the move (" + nextMove[0] + ", " + nextMove[1] + ")"); game.removeGroup(nextMove[0], nextMove[1]); game.Logger.addLog("MOVE: (" + nextMove[0] + "," + nextMove[1] + ")"); game.Logger.addLog(" --Points: " + game.calculatePoints()); game.compressGrid(); if (game.checkWin()) { GameLoop = false; Console.WriteLine("You Win!"); game.Logger.addLog("GAME WIN: All bubbles eliminated"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } else if (game.checkLocked()) { GameLoop = false; //display final game board showing locked game game.displayGrid(); Console.WriteLine("You Lose!"); game.Logger.addLog("GAME LOSS: Gameboard locked!"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } } }
public static void newAIGame(Grid game) { bool GameLoop = true; bool list = false; AI blue = new AI(50); Stack<MoveNode> moves = new Stack<MoveNode>(); if((game.Colors <= 5 && game.X <7) || (game.Colors < 4 && game.X <= 15)) { MoveNode move = blue.solveTree(game); if(move != null) { list = true; while(move != null) { moves.Push(move); move = move.PreviousMove; } } } while (GameLoop) { int[] nextMove; game.displayGrid(); if(list) { nextMove = new int[2]; MoveNode cur = moves.Pop(); nextMove[0] = cur.Group.X; nextMove[1] = cur.Group.Y; } else { nextMove = blue.makeNextMove(game); } Console.WriteLine("AI makes the move (" + nextMove[0] + ", " + nextMove[1] + ")"); game.removeGroup(nextMove[0], nextMove[1]); game.Logger.addLog("MOVE: (" + nextMove[0] + "," + nextMove[1] + ")"); game.Logger.addLog(" --Points: " + game.calculatePoints()); game.compressGrid(); if (game.checkWin()) { GameLoop = false; Console.WriteLine("You Win!"); game.Logger.addLog("GAME WIN: All bubbles eliminated"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } else if (game.checkLocked()) { GameLoop = false; //display final game board showing locked game game.displayGrid(); Console.WriteLine("You Lose!"); game.Logger.addLog("GAME LOSS: Gameboard locked!"); game.Logger.addLog("FINAL POINTS: " + game.Points); game.Logger.close(); Console.ReadLine(); } } }