-
Notifications
You must be signed in to change notification settings - Fork 511
Expand file tree
/
Copy pathBoard.java
More file actions
53 lines (46 loc) · 1.53 KB
/
Board.java
File metadata and controls
53 lines (46 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// import java.util.ArrayList;
// import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
public class Board {
int size;
int basevalue;
int numberOfValues;
Tile[][] tiles;
int[] boardValues;
Board(int size,int base,int count){
this.size = size;
this.basevalue = base;
this.numberOfValues = count;
initializeValues(base,count);
initializeBoard(size);
}
private void initializeValues(int base,int numberOfValues){
boardValues = new int[numberOfValues];
for(int i=0;i<numberOfValues;i++){
boardValues[i] = (int) Math.pow((double)base, (double)(i+1));
}
}
private void initializeBoard(int size){
tiles = new Tile[size][size];
for(int i=0;i<size;i++){
for(int j=0;j < size;j++){
tiles[i][j] = new Tile();
tiles[i][j].value = 0;
}
}
for(int i=0;i<2;i++){
int row = ThreadLocalRandom.current().nextInt(0,size);
int column = ThreadLocalRandom.current().nextInt(0,size);
if(tiles[row][column].value == 2){
i--;
}
else tiles[row][column].value = 2;
}
}
// public void insertTile(){
// int row = ThreadLocalRandom.current().nextInt(0,size);
// int column = ThreadLocalRandom.current().nextInt(0,size);
// int number = ThreadLocalRandom.current().nextInt(0,6);
// tiles[row][column].value = tileValueList.get(number);
// }
}