-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain2048.java
More file actions
90 lines (58 loc) · 1.36 KB
/
Copy pathMain2048.java
File metadata and controls
90 lines (58 loc) · 1.36 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
public class Main2048 {
public static void main(String[] args) {
TwoThousandFourtyEight t1 = new TwoThousandFourtyEight(4, 4);
TwoThousandFourtyEight t2;
t1.up();
// 0 0 2 0
// 0 0 0 0
// 0 0 2 0
// 0 0 0 0
// Score: 4
t1.right();
// 0 0 0 2
// 0 2 0 0
// 0 0 0 2
// 0 0 0 0
// Score: 6
t1.down();
// 2 0 0 0
// 0 0 0 0
// 0 0 0 0
// 0 2 0 4
// Score: 10
t1.left();
// 2 0 0 0
// 0 0 0 0
// 0 0 2 0
// 2 4 0 0
// Score: 12
for (int i = 0 ; i < 16 ; i++) {
if (!t1.up()||!t1.left()) {
break;
}
}
//t1.printBoard();
//System.out.println("");
System.out.println(t1.getScore());
assert(t1.getScore() == 128);
t2 = t1.copy();
for (int i = 0 ; i < 16 ; i++) {
if (!t1.up() || !t1.left()) {
break;
}
}
assert(t1.getScore() == 256);
assert(t2.getScore() == 128);
if (!t2.down() || !t2.right() || !t2.up() || !t2.left()) {
assert(false);
}
assert(t2.getScore() == 146);
assert(t2.getHighestTile() == 32);
// t2's state:
// 2 8 16 32
// 8 2 0 0
// 8 0 0 0
// 4 0 0 2
System.out.println("I AM GOD!");
}
}