Last change
on this file since 57 was
44,
checked in by mszubert, 15 years ago
|
cecj, framsticks and games packages imported
|
File size:
918 bytes
|
Rev | Line | |
---|
[44] | 1 | package cecj.app.othello; |
---|
| 2 | |
---|
| 3 | import java.util.Arrays; |
---|
| 4 | |
---|
| 5 | import ec.util.MersenneTwisterFast; |
---|
| 6 | |
---|
| 7 | import games.Player; |
---|
| 8 | |
---|
| 9 | public 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.