You are on page 1of 8

..

1 / 12 / 2015

5o
2015-2016


DS Proximity Part 2
Heuristic Algorithm

(0.75 )


o
.
, ( )
, .

1: DS-Proximity 2015-2016.

Random Player,
.


, ,
60 (3 1 20).
( ) (
) .

, , 2 ,
() .



/
.
ProximityUtilities:

ProximityUtilities
:
NUMBER_OF_ROWS = 10; NUMBER_OF_COLUMNS = 12;

:
Enum Direction{EAST, SE, SW, WEST, NW, NE}

. getNeighbor
.

ProximityUtilities
int[][] getNeighborsCoordinates(int x, int y, Board board):
6x2 [x,y].
-
.
Tile[] getNeighbors (int x, int y, Board board):
6x1 [x,y].
-
. ,
getNeighborsCoordinates( ),

2013

Tile.
, null.
Tile getNeighbor (int x, int y, Board board, Direction dir):
Tile
[x,y] dir. dir
enumeration Direction, .
: - [8,7]
: Tile tile = ProximityUtilities.getNeighbor(8,7,board,Direction.NW)
boolean isInsideBoard(int x, int y): true [x,y]

. false.
void printNeighbors(int x, int y):
,
[x,y]. -1.

Tile
int getX(): xx.
int getY(): yy.
int getColor():
. :
o
o
o

0 Grey ( )
1 Blue (
)
2 Red (
)

int getScore(): .
int playerId(): :
o 0 Grey ( )
o 1 Blue (
)
o 2 Red (
)

2013

Board
Tile getTile(int x, int y):
[x,y] .
void printBoard():
- /,
.
HashMap<Integer,Integer> getMyPool():
HashMap
.
HashMap .

,
.
int[] getOpponentsLastMove():
3 [x,y,s] x,y s
. ,
, [-1, -1, -1].

ArrayList
, ArrayList
java.util. ,
, ()
. .
, ArrayList String, :
ArrayList<String> thisArrayList = new ArrayList<String>();
ArrayList .
, ArrayList :
ArrayList<int[]> thisArrayList = new ArrayList<int[]>();
:
void add(Object o): ArrayList.
Object get(int pos):
. ArrayList
, Object.
int size():
ArrayList.
.

2013

HashMap
, HashMap
java.util. -.
.
. ,
HashMap (Integer) String :

HashMap <Integer,String> testHashMap = new HashMap<Integer,String>();

: HashMap
(int,float,double) (Integer, Double, Float)
.
:
Object put(Object k, Object v):
HashMap.
Object get(Object key):
. HashMap
, Object.
int size():
HashMap.
.

double getEvaluation(Board board, int


randomNumber, Tile tile) HeuristicPlayer,
randomNumber [x,y] ,
.
. :
1) ;
2) ;
3) .
;
4) ;
.

2013

H double
( 0 100), .
[x,y] ,
. ,
- [x,y]
.
,
(..
).
.
,
. , ,
,
.
,
. , ,
.

!!!
().
,
, .

int[]
getNextMove(Board board, int randomNumber) HeuristicPlayer. O
:
I.

II.

III.
IV.

( )
[x,y] e
.

evaluate(Board board, int randomNumber, Tile tile)


.
.
3
x,y
.

2013

Generate Board
.

dropdown boxes . 2 :
Random Player ( ) Heuristic Player

.

Play .
,
:
o SecondHeuristicPlayer. (Right click -> New
-> Class)
o

o constructors SecondHeuristicPlayer.
o drop-down menu Player No2
.

Java, .

(, , ). ,

. , .
.

1. : , ,
.
(
)
: .
2. .zip 1_2_Part.zip,
project eclipse pdf ().
.zip upload site

. .

2013


27 , 23:59 ()
.

2013

You might also like