-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainTrain.java
More file actions
107 lines (79 loc) · 2.85 KB
/
MainTrain.java
File metadata and controls
107 lines (79 loc) · 2.85 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
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
107
package test;
import test.Tile.Bag;
public class MainTrain {
public static void testBag() {
Bag b=Tile.Bag.getBag();
Bag b1=Tile.Bag.getBag();
if(b1!=b)
System.out.println("your Bag in not a Singleton (-5)");
int[] q0 = b.getQuantities();
q0[0]+=1;
int[] q1 = b.getQuantities();
if(q0[0]!=q1[0] + 1)
System.out.println("getQuantities did not return a clone (-5)");
for(int k=0;k<9;k++) {
int[] qs = b.getQuantities();
Tile t = b.getRand();
int i=t.letter-'A';
int[] qs1 = b.getQuantities();
if(qs1[i]!=qs[i]-1)
System.out.println("problem with getRand (-1)");
b.put(t);
b.put(t);
b.put(t);
if(b.getQuantities()[i]!=qs[i])
System.out.println("problem with put (-1)");
}
if(b.getTile('a')!=null || b.getTile('$')!=null || b.getTile('A')==null)
System.out.println("your getTile is wrong (-2)");
}
private static Tile[] get(String s) {
Tile[] ts=new Tile[s.length()];
int i=0;
for(char c: s.toCharArray()) {
ts[i]=Bag.getBag().getTile(c);
i++;
}
return ts;
}
// public static void testBoard() {
// Board b = Board.getBoard();
// if(b!=Board.getBoard())
// System.out.println("board should be a Singleton (-5)");
// Bag bag = Bag.getBag();
// Tile[] ts=new Tile[10];
// for(int i=0;i<ts.length;i++)
// ts[i]=bag.getRand();
// Word w0=new Word(ts,0,6,true);
// Word w1=new Word(ts,7,6,false);
// Word w2=new Word(ts,6,7,true);
// Word w3=new Word(ts,-1,7,true);
// Word w4=new Word(ts,7,-1,false);
// Word w5=new Word(ts,0,7,true);
// Word w6=new Word(ts,7,0,false);
// if(b.boardLegal(w0) || b.boardLegal(w1) || b.boardLegal(w2) || b.boardLegal(w3) || b.boardLegal(w4) || !b.boardLegal(w5) || !b.boardLegal(w6))
// System.out.println("your boardLegal function is wrong (-10)");
// for(Tile t : ts)
// bag.put(t);
// Word horn=new Word(get("HORN"), 7, 5, false);
// if(b.tryPlaceWord(horn)!=14)
// System.out.println("problem in placeWord for 1st word (-10)");
// Word farm=new Word(get("FA_M"), 5, 7, true);
// if(b.tryPlaceWord(farm)!=9)
// System.out.println("problem in placeWord for 2ed word (-10)");
// Word paste=new Word(get("PASTE"), 9, 5, false);
// if(b.tryPlaceWord(paste)!=25)
// System.out.println("problem in placeWord for 3ed word (-10)");
// Word mob=new Word(get("_OB"), 8, 7, false);
// if(b.tryPlaceWord(mob)!=18)
// System.out.println("problem in placeWord for 4th word (-10)");
// Word bit=new Word(get("BIT"), 10, 4, false);
// if(b.tryPlaceWord(bit)!=22)
// System.out.println("problem in placeWord for 5th word (-15)");
// }
public static void main(String[] args) {
testBag(); // 30 points
//testBoard(); // 70 points
System.out.println("done");
}
}