source: java/ecj/cecj/app/othello/OthelloPlayer.java @ 193

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

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 918 bytes
Line 
1package cecj.app.othello;
2
3import java.util.Arrays;
4
5import ec.util.MersenneTwisterFast;
6
7import games.Player;
8
9public class OthelloPlayer implements Player {
10        private static final int WPC_LENGTH = 64;
11
12        private double[] wpc;
13
14        public OthelloPlayer() {
15                this.wpc = new double[WPC_LENGTH];
16        }
17       
18        public OthelloPlayer(double[] wpc) {
19                this.wpc = wpc;
20        }
21
22        public double getValue(int row, int col) {
23                return wpc[(row - 1) * OthelloBoard.size() + (col - 1)];
24        }
25       
26        public double[] getWPC() {
27                return wpc;
28        }
29
30        public void setValue(int row, int col, double value) {
31                wpc[(row - 1) * OthelloBoard.size() + (col - 1)] = value;
32        }
33       
34        @Override
35        public String toString() {
36                return Arrays.toString(wpc);
37        }
38       
39        public void randomize(MersenneTwisterFast random, double range) {
40                for (int i = 0; i < WPC_LENGTH; i++) {
41                        wpc[i] = random.nextDouble() * range;
42                        if (random.nextBoolean()) {
43                                wpc[i] *= -1;
44                        }
45                }
46        }
47}
Note: See TracBrowser for help on using the repository browser.