-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMachinePlayer.java
106 lines (90 loc) · 2.2 KB
/
MachinePlayer.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.util.Scanner;
import java.util.ArrayList;
public class MachinePlayer extends Player
{
boolean MACHINE = true;
private class myBest
{
}
public MachinePlayer(Card[] tops, Card[] bottoms, Card[] privates, Card[] enemyTops, Card[] enemyBottoms, Card[] enemyPrivates)
{
super(tops, bottoms, privates, enemyTops, enemyBottoms, enemyPrivates);
}
public int evaluate(Player a, Player b)
{
return a.numHands - b.numHands;
}
public Object[] chooseMove(boolean side, int alpha, int beta, Card placedCard)
{
Object[] myBest = new Object[]; //move followed by score
Object[] reply;
if (numCards == 0)
{
return a.numHands - b.numHands;
}
if (side == MACHINE) {
myBest.score = alpha;
} else {
myBest.score = beta;
}
ArrayList legalMoves = getAllLegalMoves2(placedCard)[0];
myBest[0] = legalMoves[0];
for (Object[] move : legalMoves)
{
}
}
//MOVE: <code><index>
//code: T for top, B for bottom, P for private
//index: 0 start
//Postcondition: move is valid
public String getMove(Card placedCard)
{
Object[] state = new Object[];
state[0] = Array.copyOf(tops, tops.length);
state[1] = Array.copyOf(bottoms, bottoms.length);
state[2] = Array.copyOf(privateCards, privateCards.length);
state[3] = Array.copyOf(enemyTops, enemyTops.length);
state[4] = Array.copyOf()
// boolean isValid = true;
// String move = "";
// Scanner reader = new Scanner(System.in);
// ArrayList legalMoves = getAllLegalMoves(placedCard)[0];
// do {
// System.out.print("What move should we do? Input: ");
// move = reader.nextLine();
// } while (!legalMoves.contains(move));
// return move;
}
public int maxIndex(int[] nums)
{
if (nums.length > 0)
{
int max = nums[0];
int index = 0;
for (int i = 0; i < nums.length; i++)
{
if (nums[i] > max)
{
max = nums[i];
index = i;
}
}
return index;
}
return -1;
}
public int getSurCall()
{
int[] suitScores = new int[] {0, 0, 0, 0};
for (int i = 0; i < 6; i++)
{
suitScores[tops[i].suit()] += tops[i].number();
if (i < 3)
{
suitScores[privateCards[i].suit()] += privateCards[i].number();
}
}
return maxIndex(suitScores);
//tops, privates, enemyTops
}
}