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