source: java/ecj/games/league/HeuristicPerformanceMeter.java

Last change on this file was 193, checked in by Maciej Komosinski, 11 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1package games.league;
2
3import games.Player;
4import games.scenarios.GameScenario;
5import games.scenarios.SimpleTwoPlayersGameScenario;
6
7import java.io.InputStream;
8import java.util.Scanner;
9
10import cecj.app.othello.OthelloBoard;
11import cecj.app.othello.OthelloGame;
12import cecj.app.othello.OthelloPlayer;
13
14
15public 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}
Note: See TracBrowser for help on using the repository browser.