public static void LocalTest2(int nb) { for (int i = 0; i < nb; i++) { int n = 0; s_game = new Game(20, 20); var game1 = new Game(20, 20); Thread.Sleep(2000); var game2 = new Game(20, 20); while (!game1.GameOver && !game2.GameOver) { var coord = game1.Play(); var ans = game2.Answer(coord[0], coord[1]); switch (ans) { case Game.Action.Eau: game1.UpdateEnemyGrid(coord[0], coord[1], Game.Cell.Empty); break; case Game.Action.Touche: game1.UpdateEnemyGrid(coord[0], coord[1], Game.Cell.Hit); break; case Game.Action.ToucheCoule: game1.UpdateEnemyGrid(coord[0], coord[1], Game.Cell.Sunked); break; default: throw new ArgumentOutOfRangeException(); } coord = game2.Play(); ans = game1.Answer(coord[0], coord[1]); switch (ans) { case Game.Action.Eau: game2.UpdateEnemyGrid(coord[0], coord[1], Game.Cell.Empty); break; case Game.Action.Touche: game2.UpdateEnemyGrid(coord[0], coord[1], Game.Cell.Hit); break; case Game.Action.ToucheCoule: game2.UpdateEnemyGrid(coord[0], coord[1], Game.Cell.Sunked); break; default: throw new ArgumentOutOfRangeException(); } //Console.Clear(); //game1.PrintGrid(); //game1.PrintOpponentGrid(); //Thread.Sleep(100); n++; } Console.WriteLine("Nb d'essais : {0}", n); } }
public void SendAnswer(Game.Action answer) { var stream = m_client.GetStream(); stream.Write(BitConverter.GetBytes((int)answer), 0, sizeof(int)); stream.Flush(); }
public static void OnGameStart(object sender, GameStartEventArgs e) { s_game = new Game(e.GameOptions.X, e.GameOptions.Y); Play(); }