public void setAllPlayers(ILudoPlayer yellow, ILudoPlayer red, ILudoPlayer blue, ILudoPlayer green) { yellowPlayer = yellow; redPlayer = red; bluePlayer = blue; greenPlayer = green; }
public void setPlayer(ILudoPlayer player, int color) { switch (color) { case YELLOW: yellowPlayer = player; break; case RED: redPlayer = player; break; case BLUE: bluePlayer = player; break; case GREEN: greenPlayer = player; break; } }
public void reset() { if (rand == null) { rand = new Random(); } currentColor = startColor; turns = 3; yellowPlayer = new RandomLudoPlayer(this); redPlayer = new RandomLudoPlayer(this); bluePlayer = new RandomLudoPlayer(this); greenPlayer = new RandomLudoPlayer(this); int[][] temp = { new int[] { 100, 101, 102, 103 }, new int[] { 200, 201, 202, 203 }, new int[] { 300, 301, 302, 303 }, new int[] { 400, 401, 402, 403 } }; bricks = temp; int[] temp2 = { 0, 0, 0, 0 }; turnsCounter = temp2; killed = false; point = 3; dice = 0; //repaint(); }
private void Play() // some minor changes { Stopwatch swatch = new Stopwatch(); swatch.Start(); List <ILudoPlayer> playerList = board.GetPlayerList; ILudoPlayer[] activePlayers = new ILudoPlayer[4]; int[] result = new int[4]; // show list in ui // pick what type should be play each activePlayers[0] = playerList[0]; activePlayers[1] = playerList[1]; activePlayers[2] = playerList[2]; activePlayers[3] = playerList[3]; board.setAllPlayers(activePlayers[0], activePlayers[1], activePlayers[2], activePlayers[3]); try { for (int i = 0; i < 1000; i++) { board.play(); board.kill(); int[] points = board.getPoints(); result[0] += points[0]; result[1] += points[1]; result[2] += points[2]; result[3] += points[3]; board.reset(); board.setAllPlayers(activePlayers[0], activePlayers[1], activePlayers[2], activePlayers[3]); //board.setPlayer(activePlayers[0], LudoBoard.YELLOW); //board.setPlayer(activePlayers[1], LudoBoard.RED); //board.setPlayer(activePlayers[2], LudoBoard.BLUE); //board.setPlayer(activePlayers[3], LudoBoard.GREEN); if ((i % 500) == 0) { Console.Write("."); } } } catch (Exception) { throw; } swatch.Stop(); Console.WriteLine(); Console.WriteLine("Simulation took " + swatch.ElapsedMilliseconds + " miliseconds"); Console.WriteLine("RESULT:"); Console.WriteLine("YELLOW Player: " + result[0] + " - (" + activePlayers[0].PlayerName() + ")"); Console.WriteLine("RED Player: " + result[1] + " - (" + activePlayers[1].PlayerName() + ")"); Console.WriteLine("BLUE Player: " + result[2] + " - (" + activePlayers[2].PlayerName() + ")"); Console.WriteLine("GREEN Player: " + result[3] + " - (" + activePlayers[3].PlayerName() + ")"); Console.ReadKey(); }