1 | package games.league; |
---|
2 | |
---|
3 | import games.Player; |
---|
4 | import games.scenarios.GameScenario; |
---|
5 | import games.scenarios.SimpleTwoPlayersGameScenario; |
---|
6 | |
---|
7 | import java.io.InputStream; |
---|
8 | import java.util.Scanner; |
---|
9 | |
---|
10 | import cecj.app.othello.OthelloBoard; |
---|
11 | import cecj.app.othello.OthelloGame; |
---|
12 | import cecj.app.othello.OthelloPlayer; |
---|
13 | |
---|
14 | |
---|
15 | public class HeuristicPerformanceMeter { |
---|
16 | |
---|
17 | double[] wpc = { 1.00f, -0.25f, 0.10f, 0.05f, 0.05f, 0.10f, -0.25f, 1.00f, -0.25f, -0.25f, |
---|
18 | 0.01f, 0.01f, 0.01f, 0.01f, -0.25f, -0.25f, 0.10f, 0.01f, 0.05f, 0.02f, 0.02f, 0.05f, |
---|
19 | 0.01f, 0.10f, 0.05f, 0.01f, 0.02f, 0.01f, 0.01f, 0.02f, 0.01f, 0.05f, 0.05f, 0.01f, |
---|
20 | 0.02f, 0.01f, 0.01f, 0.02f, 0.01f, 0.05f, 0.10f, 0.01f, 0.05f, 0.02f, 0.02f, 0.05f, |
---|
21 | 0.01f, 0.10f, -0.25f, -0.25f, 0.01f, 0.01f, 0.01f, 0.01f, -0.25f, -0.25f, 1.00f, |
---|
22 | -0.25f, 0.10f, 0.05f, 0.05f, 0.10f, -0.25f, 1.00f }; |
---|
23 | |
---|
24 | private OthelloPlayer player; |
---|
25 | |
---|
26 | public void readPlayer(InputStream input) { |
---|
27 | Scanner s = new Scanner(input); |
---|
28 | double[] playerWpc = new double[64]; |
---|
29 | for (int i = 0; i < 64; i++) { |
---|
30 | playerWpc[i] = s.nextDouble(); |
---|
31 | } |
---|
32 | player = new OthelloPlayer(playerWpc); |
---|
33 | |
---|
34 | System.out.println("Player = " + player); |
---|
35 | } |
---|
36 | |
---|
37 | private void testPlayer() { |
---|
38 | OthelloPlayer heuristic = new OthelloPlayer(wpc); |
---|
39 | GameScenario scenario1 = new SimpleTwoPlayersGameScenario( |
---|
40 | new Player[] { player, heuristic }); |
---|
41 | GameScenario scenario2 = new SimpleTwoPlayersGameScenario( |
---|
42 | new Player[] { heuristic, player }); |
---|
43 | OthelloGame game = new OthelloGame(new OthelloBoard()); |
---|
44 | |
---|
45 | game.reset(); |
---|
46 | System.out.println("Playing as black, the result is " + scenario1.play(game)); |
---|
47 | System.out.println(game.getBoard()); |
---|
48 | |
---|
49 | game.reset(); |
---|
50 | System.out.println("Playing as white, the result is " + scenario2.play(game)); |
---|
51 | System.out.println(game.getBoard()); |
---|
52 | } |
---|
53 | |
---|
54 | /** |
---|
55 | * @param args |
---|
56 | */ |
---|
57 | public static void main(String[] args) { |
---|
58 | HeuristicPerformanceMeter hpm = new HeuristicPerformanceMeter(); |
---|
59 | hpm.readPlayer(System.in); |
---|
60 | hpm.testPlayer(); |
---|
61 | } |
---|
62 | |
---|
63 | } |
---|