Kunstig Intelligens til Brætspillet Taiji - Danmarks Tekniske Universitet
Kunstig Intelligens til Brætspillet Taiji - Danmarks Tekniske Universitet Kunstig Intelligens til Brætspillet Taiji - Danmarks Tekniske Universitet
228 Bilag A 135 tFrame . tModel . s e t S t a r t e r ( 1 ) ; 136 tFrame . tModel . setWhitePlayer ( 2 ) ; 137 tFrame . tModel . s e t B l a c k P l a y e r ( 0 ) ; 138 } 139 i f ( s e t == 7) { // Growth VS Player 140 tFrame . tModel . s e t S t a r t e r ( 1 ) ; 141 tFrame . tModel . setWhitePlayer ( 4 ) ; 142 tFrame . tModel . s e t B l a c k P l a y e r ( 0 ) ; 143 } 144 tFrame . tModel . r e s e t ( ) ; 145 tFrame . r e p a i n t A l l ( ) ; 146 s e t V i s i b l e ( f a l s e ) ; 147 } 148 e l s e 149 { 150 s e t V i s i b l e ( f a l s e ) ; 151 } 152 } 153 } 154 } A.17 Tree.java 1 import java . u t i l . ArrayList ; 2 p u b l i c c l a s s Tree { // denne k l a s s e e r kun anvendt i Minimax AI ’ en 3 p u b l i c Node Root ; 4 p u b l i c Node Cur ; // c u r r e n t node 5 p u b l i c ArrayList evenGen ; 6 p u b l i c ArrayList oddGen ; 7 p u b l i c ArrayList Leaves ; 8 p u b l i c i n t curLeaves ; // Current number o f l e a v e s 9 p u b l i c i n t t o t a l L e a v e s ; // Temperary number o f l e a v e s . curLeaves +newly added l e a v e s . 10 p u b l i c i n t curMin ; 11 p u b l i c i n t curMax ; 12 13 14 p u b l i c Tree ( ) { 15 Root = new Node ( ) ; 16 Cur = new Node ( ) ; 17 Leaves = new ArrayList () ; 18 evenGen = new ArrayList () ; 19 oddGen = new ArrayList () ; 20 21 } 22 23 // s a e t t e r roden 24 p u b l i c void setRoot ( Node n ) { 25 Root = n ; 26 } 27 // s a e t t e r c u r r e n t node 28 p u b l i c void setCur ( Node n ) { 29 Cur = n ;
A.17 Tree.java 229 30 } 31 32 // t i l f o e j e r e t blad 33 p u b l i c void addLeave ( Node n ) { 34 Leaves . add ( n ) ; 35 } 36 37 p u b l i c void addMin ( Node n ) { 38 curMin++; 39 } 40 41 42 p u b l i c void addMax( Node n ) { 43 curMax++; 44 } 45 46 p u b l i c void resetMin ( ) { 47 curMin =0; 48 } 49 50 p u b l i c void resetMax ( ) { 51 curMax=0; 52 } 53 54 p u b l i c void addLeaveT ( Node n ) { 55 t o t a l L e a v e s ++; 56 } 57 58 p u b l i c void removeLeave ( i n t l ) { 59 Leaves . remove ( l ) ; 60 } 61 62 p u b l i c void removeLeaveT ( i n t l ) { 63 t o t a l L e a v e s −−; 64 } 65 66 p u b l i c void removeLeaveC ( i n t l ) { 67 curLeaves −−; 68 t o t a l L e a v e s −−; 69 } 70 71 72 p u b l i c i n t getCurLeaves ( ) { 73 r e t u r n ( curLeaves ) ; 74 } 75 76 }
- Page 188 and 189: 178 Bilag A 58 p u b l i c void mou
- Page 190 and 191: 180 Bilag A 149 S t r i n g t x t =
- Page 192 and 193: 182 Bilag A l o a d i n g the f i l
- Page 194 and 195: 184 Bilag A 7 p u b l i c AITaijiMi
- Page 196 and 197: 186 Bilag A 105 i f ( b l a c k P l
- Page 198 and 199: 188 Bilag A 211 tBoard . s e t P i
- Page 200 and 201: 190 Bilag A 315 { 316 f o r ( i n t
- Page 202 and 203: 192 Bilag A 416 { 417 //Bunden 418
- Page 204 and 205: 194 Bilag A 510 p r i v a t e boole
- Page 206 and 207: 196 Bilag A 612 } 613 614 // b e r
- Page 208 and 209: 198 Bilag A 702 } 703 704 // s a e
- Page 210 and 211: 200 Bilag A 802 p u b l i c void ne
- Page 212 and 213: 202 Bilag A 59 g . f i l l R e c t
- Page 214 and 215: 204 Bilag A 159 { 160 t h i s . set
- Page 216 and 217: 206 Bilag A 81 System . out . p r i
- Page 218 and 219: 208 Bilag A [ 1 ] [ 7 ] + ” ”+n
- Page 220 and 221: 210 Bilag A 176 System . out . p r
- Page 222 and 223: 212 Bilag A 212 System . out . p r
- Page 224 and 225: 214 Bilag A 246 System . out . p r
- Page 226 and 227: 216 Bilag A [ 8 ] [ 2 ] ) ; 277 i f
- Page 228 and 229: 218 Bilag A 326 p u b l i c void pr
- Page 230 and 231: 220 Bilag A 393 i f ( tModel . noRo
- Page 232 and 233: 222 Bilag A 449 i f ( tModel . noRo
- Page 234 and 235: 224 Bilag A 501 System . out . p r
- Page 236 and 237: 226 Bilag A 30 31 tFrame = frame ;
- Page 240 and 241: 230
- Page 242 and 243: 232 Bilag B ”Introduction to Algo
- Page 244: 234
A.17 Tree.java 229<br />
30 }<br />
31<br />
32 // t i l f o e j e r e t blad<br />
33 p u b l i c void addLeave ( Node n ) {<br />
34 Leaves . add ( n ) ;<br />
35 }<br />
36<br />
37 p u b l i c void addMin ( Node n ) {<br />
38 curMin++;<br />
39 }<br />
40<br />
41<br />
42 p u b l i c void addMax( Node n ) {<br />
43 curMax++;<br />
44 }<br />
45<br />
46 p u b l i c void resetMin ( ) {<br />
47 curMin =0;<br />
48 }<br />
49<br />
50 p u b l i c void resetMax ( ) {<br />
51 curMax=0;<br />
52 }<br />
53<br />
54 p u b l i c void addLeaveT ( Node n ) {<br />
55 t o t a l L e a v e s ++;<br />
56 }<br />
57<br />
58 p u b l i c void removeLeave ( i n t l ) {<br />
59 Leaves . remove ( l ) ;<br />
60 }<br />
61<br />
62 p u b l i c void removeLeaveT ( i n t l ) {<br />
63 t o t a l L e a v e s −−;<br />
64 }<br />
65<br />
66 p u b l i c void removeLeaveC ( i n t l ) {<br />
67 curLeaves −−;<br />
68 t o t a l L e a v e s −−;<br />
69 }<br />
70<br />
71<br />
72 p u b l i c i n t getCurLeaves ( ) {<br />
73 r e t u r n ( curLeaves ) ;<br />
74 }<br />
75<br />
76 }