-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.ps
1484 lines (1422 loc) · 47.6 KB
/
readme.ps
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%!PS-Adobe-3.0
%%BoundingBox: 25 25 587 767
%%Title: Enscript Output
%%For: Jonathan R. Shewchuk
%%Creator: GNU enscript 1.6.4
%%CreationDate: Sun Mar 3 22:12:06 2013
%%Orientation: Landscape
%%Pages: (atend)
%%DocumentMedia: Letter 612 792 0 () ()
%%DocumentNeededResources: (atend)
%%EndComments
%%BeginProlog
%%BeginResource: procset Enscript-Prolog 1.6 4
%
% Procedures.
%
/_S { % save current state
/_s save def
} def
/_R { % restore from saved state
_s restore
} def
/S { % showpage protecting gstate
gsave
showpage
grestore
} bind def
/MF { % fontname newfontname -> - make a new encoded font
/newfontname exch def
/fontname exch def
/fontdict fontname findfont def
/newfont fontdict maxlength dict def
fontdict {
exch
dup /FID eq {
% skip FID pair
pop pop
} {
% copy to the new font dictionary
exch newfont 3 1 roll put
} ifelse
} forall
newfont /FontName newfontname put
% insert only valid encoding vectors
encoding_vector length 256 eq {
newfont /Encoding encoding_vector put
} if
newfontname newfont definefont pop
} def
/MF_PS { % fontname newfontname -> - make a new font preserving its enc
/newfontname exch def
/fontname exch def
/fontdict fontname findfont def
/newfont fontdict maxlength dict def
fontdict {
exch
dup /FID eq {
% skip FID pair
pop pop
} {
% copy to the new font dictionary
exch newfont 3 1 roll put
} ifelse
} forall
newfont /FontName newfontname put
newfontname newfont definefont pop
} def
/SF { % fontname width height -> - set a new font
/height exch def
/width exch def
findfont
[width 0 0 height 0 0] makefont setfont
} def
/SUF { % fontname width height -> - set a new user font
/height exch def
/width exch def
/F-gs-user-font MF
/F-gs-user-font width height SF
} def
/SUF_PS { % fontname width height -> - set a new user font preserving its enc
/height exch def
/width exch def
/F-gs-user-font MF_PS
/F-gs-user-font width height SF
} def
/M {moveto} bind def
/s {show} bind def
/Box { % x y w h -> - define box path
/d_h exch def /d_w exch def /d_y exch def /d_x exch def
d_x d_y moveto
d_w 0 rlineto
0 d_h rlineto
d_w neg 0 rlineto
closepath
} def
/bgs { % x y height blskip gray str -> - show string with bg color
/str exch def
/gray exch def
/blskip exch def
/height exch def
/y exch def
/x exch def
gsave
x y blskip sub str stringwidth pop height Box
gray setgray
fill
grestore
x y M str s
} def
/bgcs { % x y height blskip red green blue str -> - show string with bg color
/str exch def
/blue exch def
/green exch def
/red exch def
/blskip exch def
/height exch def
/y exch def
/x exch def
gsave
x y blskip sub str stringwidth pop height Box
red green blue setrgbcolor
fill
grestore
x y M str s
} def
% Highlight bars.
/highlight_bars { % nlines lineheight output_y_margin gray -> -
gsave
setgray
/ymarg exch def
/lineheight exch def
/nlines exch def
% This 2 is just a magic number to sync highlight lines to text.
0 d_header_y ymarg sub 2 sub translate
/cw d_output_w cols div def
/nrows d_output_h ymarg 2 mul sub lineheight div cvi def
% for each column
0 1 cols 1 sub {
cw mul /xp exch def
% for each rows
0 1 nrows 1 sub {
/rn exch def
rn lineheight mul neg /yp exch def
rn nlines idiv 2 mod 0 eq {
% Draw highlight bar. 4 is just a magic indentation.
xp 4 add yp cw 8 sub lineheight neg Box fill
} if
} for
} for
grestore
} def
% Line highlight bar.
/line_highlight { % x y width height gray -> -
gsave
/gray exch def
Box gray setgray fill
grestore
} def
% Column separator lines.
/column_lines {
gsave
.1 setlinewidth
0 d_footer_h translate
/cw d_output_w cols div def
1 1 cols 1 sub {
cw mul 0 moveto
0 d_output_h rlineto stroke
} for
grestore
} def
% Column borders.
/column_borders {
gsave
.1 setlinewidth
0 d_footer_h moveto
0 d_output_h rlineto
d_output_w 0 rlineto
0 d_output_h neg rlineto
closepath stroke
grestore
} def
% Do the actual underlay drawing
/draw_underlay {
ul_style 0 eq {
ul_str true charpath stroke
} {
ul_str show
} ifelse
} def
% Underlay
/underlay { % - -> -
gsave
0 d_page_h translate
d_page_h neg d_page_w atan rotate
ul_gray setgray
ul_font setfont
/dw d_page_h dup mul d_page_w dup mul add sqrt def
ul_str stringwidth pop dw exch sub 2 div ul_h_ptsize -2 div moveto
draw_underlay
grestore
} def
/user_underlay { % - -> -
gsave
ul_x ul_y translate
ul_angle rotate
ul_gray setgray
ul_font setfont
0 0 ul_h_ptsize 2 div sub moveto
draw_underlay
grestore
} def
% Page prefeed
/page_prefeed { % bool -> -
statusdict /prefeed known {
statusdict exch /prefeed exch put
} {
pop
} ifelse
} def
% Wrapped line markers
/wrapped_line_mark { % x y charwith charheight type -> -
/type exch def
/h exch def
/w exch def
/y exch def
/x exch def
type 2 eq {
% Black boxes (like TeX does)
gsave
0 setlinewidth
x w 4 div add y M
0 h rlineto w 2 div 0 rlineto 0 h neg rlineto
closepath fill
grestore
} {
type 3 eq {
% Small arrows
gsave
.2 setlinewidth
x w 2 div add y h 2 div add M
w 4 div 0 rlineto
x w 4 div add y lineto stroke
x w 4 div add w 8 div add y h 4 div add M
x w 4 div add y lineto
w 4 div h 8 div rlineto stroke
grestore
} {
% do nothing
} ifelse
} ifelse
} def
% EPSF import.
/BeginEPSF {
/b4_Inc_state save def % Save state for cleanup
/dict_count countdictstack def % Count objects on dict stack
/op_count count 1 sub def % Count objects on operand stack
userdict begin
/showpage { } def
0 setgray 0 setlinecap
1 setlinewidth 0 setlinejoin
10 setmiterlimit [ ] 0 setdash newpath
/languagelevel where {
pop languagelevel
1 ne {
false setstrokeadjust false setoverprint
} if
} if
} bind def
/EndEPSF {
count op_count sub { pos } repeat % Clean up stacks
countdictstack dict_count sub { end } repeat
b4_Inc_state restore
} bind def
% Check PostScript language level.
/languagelevel where {
pop /gs_languagelevel languagelevel def
} {
/gs_languagelevel 1 def
} ifelse
%%EndResource
%%BeginResource: procset Enscript-Encoding-88591 1.6 4
/encoding_vector [
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /hyphen /period /slash
/zero /one /two /three
/four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
/at /A /B /C
/D /E /F /G
/H /I /J /K
/L /M /N /O
/P /Q /R /S
/T /U /V /W
/X /Y /Z /bracketleft
/backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c
/d /e /f /g
/h /i /j /k
/l /m /n /o
/p /q /r /s
/t /u /v /w
/x /y /z /braceleft
/bar /braceright /tilde /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef
/space /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /bullet
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis
] def
%%EndResource
%%EndProlog
%%BeginSetup
%%IncludeResource: font Courier-Bold
%%IncludeResource: font Courier
/HFpt_w 10 def
/HFpt_h 10 def
/Courier-Bold /HF-gs-font MF
/HF /HF-gs-font findfont [HFpt_w 0 0 HFpt_h 0 0] makefont def
/Courier /F-gs-font MF
/F-gs-font 7 7 SF
/#copies 1 def
% Pagedevice definitions:
gs_languagelevel 1 gt {
<<
/PageSize [612 792]
>> setpagedevice
} if
%%BeginResource: procset Enscript-Header-enscript 1.6 4
%%IncludeResource: font Times-Bold
%%IncludeResource: font Times-Roman
% Fonts.
/Times-Bold /HeaderFont-Bold MF
/HeaderDateF /HeaderFont-Bold findfont 12 scalefont def
/Times-Roman /HeaderFont-Times MF
/HeaderHDRF /HeaderFont-Times findfont 14 scalefont def
/HeaderPageNumF /Helvetica-Bold findfont 28.8 scalefont def
/do_header { % print enscript header
gsave
d_header_x d_header_y translate
% light bar
0 0 d_header_w d_header_h 2 div Box
.95 setgray fill
% dark gray boxes
/dbw d_header_h 2 mul def % dark box width
/dbc .7 def % dark box color
% left dark box.
0 0 dbw d_header_h Box
dbc setgray fill
0 setgray
HeaderDateF setfont
moddatestr dup stringwidth pop dbw exch sub 2 div
d_header_h 2 div 2 add moveto show
modtimestr dup stringwidth pop dbw exch sub 2 div
d_header_h 5 div moveto show
% right dark box
d_header_w dbw sub 0 dbw d_header_h Box
dbc setgray fill
HeaderPageNumF setfont
1 setgray
pagenumstr dup
stringwidth pop dbw exch sub 2 div d_header_w dbw sub add
d_header_h .2 mul moveto show
% filename
0 setgray
HeaderHDRF setfont
d_header_w fname stringwidth pop sub 2 div d_header_h 8 div moveto
fname show
% user supplied header string.
user_header_p {
/h d_header_h 8 div 5 mul def
% Implement strict enscript compatibility.
user_header_center_str () eq user_header_right_str () eq and {
d_header_w user_header_left_str stringwidth pop sub 2 div
h moveto user_header_left_str show
} {
dbw 5 add h moveto user_header_left_str show
d_header_w user_header_center_str stringwidth pop sub 2 div
h moveto user_header_center_str show
d_header_w dbw sub 5 sub user_header_right_str stringwidth pop
sub h moveto user_header_right_str show
} ifelse
} if
grestore
} def
%%EndResource
/d_page_w 742 def
/d_page_h 562 def
/d_header_x 0 def
/d_header_y 526 def
/d_header_w 742 def
/d_header_h 36 def
/d_footer_x 0 def
/d_footer_y 0 def
/d_footer_w 742 def
/d_footer_h 0 def
/d_output_w 742 def
/d_output_h 526 def
/cols 2 def
%%EndSetup
%%Page: (1) 1
%%BeginPageSetup
_S
90 rotate
25 -587 translate
/pagenum 1 def
/fname (readme) def
/fdir () def
/ftail (readme) def
% User defined strings:
/pagenumstr (1) def
/moddatestr (03/03/13) def
/modtimestr (22:11:41) def
/user_header_p false def
/user_footer_p false def
%%EndPageSetup
column_lines
do_header
5 516 M
( CS 61B Project 2) s
5 508 M
( Network \(The Game\)) s
5 500 M
( Due 5:30 pm Friday, April 5, 2013) s
5 492 M
( Interface design due in lab March 12-13) s
5 476 M
(Warning: This project is substantially more time-consuming than Project 1.) s
5 468 M
( Start early.) s
5 452 M
(This is a team project. Form a team of 2 or 3 people. No teams of 1 or teams) s
5 444 M
(of 4 or more are allowed. Your project partners do NOT have to be in your lab.) s
5 428 M
(Copy the Project 2 directory by doing the following, starting from your home) s
5 420 M
(directory.) s
5 404 M
( cp -r ~cs61b/hw/pj2 .) s
5 396 M
( cd pj2) s
5 380 M
(Suggested Timeline \(if you want to finish on time\)) s
5 372 M
(==================) s
5 364 M
(Design the classes, modules, and interfaces \(see "Teamwork"\). March 11) s
5 356 M
(Have working code for the easier modules. March 17) s
5 348 M
(Have working code for identifying a network; progress on search. March 24) s
5 340 M
(Finish project. April 5) s
5 324 M
(Network) s
5 316 M
(=======) s
5 308 M
(In this project you will implement a program that plays the game Network) s
5 300 M
(against a human player or another computer program. Network is played on an) s
5 292 M
(8-by-8 board. There are two players, "Black" and "White." Each player has ten) s
5 284 M
(chips of its own color to place on the board. White moves first.) s
5 268 M
( -----------------------------------------) s
5 260 M
( | | 10 | 20 | 30 | 40 | 50 | 60 | |) s
5 252 M
( -----------------------------------------) s
5 244 M
( | 01 | 11 | 21 | 31 | 41 | 51 | 61 | 71 |) s
5 236 M
( -----------------------------------------) s
5 228 M
( | 02 | 12 | 22 | 32 | 42 | 52 | 62 | 72 |) s
5 220 M
( -----------------------------------------) s
5 212 M
( | 03 | 13 | 23 | 33 | 43 | 53 | 63 | 73 |) s
5 204 M
( -----------------------------------------) s
5 196 M
( | 04 | 14 | 24 | 34 | 44 | 54 | 64 | 74 |) s
5 188 M
( -----------------------------------------) s
5 180 M
( | 05 | 15 | 25 | 35 | 45 | 55 | 65 | 75 |) s
5 172 M
( -----------------------------------------) s
5 164 M
( | 06 | 16 | 26 | 36 | 46 | 56 | 66 | 76 |) s
5 156 M
( -----------------------------------------) s
5 148 M
( | | 17 | 27 | 37 | 47 | 57 | 67 | |) s
5 140 M
( -----------------------------------------) s
5 124 M
(The board has four goal areas: the top row, the bottom row, the left column,) s
5 116 M
(and the right column. Black's goal areas are squares 10, 20, 30, 40, 50, 60) s
5 108 M
(and 17, 27, 37, 47, 57, 67. Only Black may place chips in these areas.) s
5 100 M
(White's goal areas are 01, 02, 03, 04, 05, 06 and 71, 72, 73, 74, 75, 76; only) s
5 92 M
(White may play there. The corner squares--00, 70, 07, and 77--are dead;) s
5 84 M
(neither player may use them. Either player may place a chip in any square not) s
5 76 M
(on the board's border.) s
376 508 M
(Object of Play) s
376 500 M
(==============) s
376 492 M
(Each player tries to complete a "network" joining its two goal areas.) s
376 484 M
(A network is a sequence of six or more chips that starts in one of the player's) s
376 476 M
(goal areas and terminates in the other. Each consecutive pair of chips in the) s
376 468 M
(sequence are connected to each other along straight lines, either orthogonally) s
376 460 M
(\(left, right, up, down\) or diagonally.) s
376 444 M
(The diagram below shows a winning configuration for Black. \(There should be) s
376 436 M
(White chips on the board as well, but for clarity these are not shown.\) Here) s
376 428 M
(are two winning black networks. Observe that the second one crosses itself.) s
376 412 M
( 60 - 65 - 55 - 33 - 35 - 57) s
376 404 M
( 20 - 25 - 35 - 13 - 33 - 55 - 57) s
376 388 M
( -----------------------------------------) s
376 380 M
( | | | BB | | | | BB | | _0) s
376 372 M
( -----------------------------------------) s
376 364 M
( | | | | | | | | | _1) s
376 356 M
( -----------------------------------------) s
376 348 M
( | | | | | BB | | | | _2) s
376 340 M
( -----------------------------------------) s
376 332 M
( | | BB | | BB | | | | | _3) s
376 324 M
( -----------------------------------------) s
376 316 M
( | | | | | | | | | _4) s
376 308 M
( -----------------------------------------) s
376 300 M
( | | | BB | BB | | BB | BB | | _5) s
376 292 M
( -----------------------------------------) s
376 284 M
( | | | | | | | | | _6) s
376 276 M
( -----------------------------------------) s
376 268 M
( | | | BB | | | BB | | | _7) s
376 260 M
( -----------------------------------------) s
376 252 M
( 0_ 1_ 2_ 3_ 4_ 5_ 6_ 7_) s
376 236 M
(An enemy chip placed in the straight line between two chips breaks the) s
376 228 M
(connection. In the second network listed above, a white chip in square 56) s
376 220 M
(would break the connection to Black's lower goal.) s
376 204 M
(Although more than one chip may be placed in a goal area, a network can have) s
376 196 M
(only two chips in the goal areas: the first and last chips in the network.) s
376 188 M
(Neither of the following are networks, because they both make use of two chips) s
376 180 M
(in the upper goal.) s
376 164 M
( 60 - 20 - 42 - 33 - 35 - 57) s
376 156 M
( 20 - 42 - 60 - 65 - 55 - 57) s
376 140 M
(A network cannot pass through the same chip twice, even if it is only counted) s
376 132 M
(once. For that reason the following is not a network.) s
376 116 M
( 20 - 25 - 35 - 33 - 55 - 35 - 57) s
376 100 M
(A network cannot pass through a chip without turning a corner \(i.e. changing) s
376 92 M
(direction\). Because of the chip in square 42, the following is not a network.) s
376 76 M
( 60 - 42 - 33 - 35 - 25 - 27) s
_R
S
%%Page: (2) 2
%%BeginPageSetup
_S
90 rotate
25 -587 translate
/pagenum 2 def
/fname (readme) def
/fdir () def
/ftail (readme) def
% User defined strings:
/pagenumstr (2) def
/moddatestr (03/03/13) def
/modtimestr (22:11:41) def
/user_header_p false def
/user_footer_p false def
%%EndPageSetup
column_lines
do_header
5 508 M
(Legal Moves) s
5 500 M
(===========) s
5 492 M
(To begin the game, choose who is Black and who is White in any manner \(we use a) s
5 484 M
(random number generator\). The players alternate taking turns, with White) s
5 476 M
(moving first.) s
5 460 M
(The first three rules of legal play are fairly simple.) s
5 452 M
( 1\) No chip may be placed in any of the four corners. ) s
5 444 M
( 2\) No chip may be placed in a goal of the opposite color.) s
5 436 M
( 3\) No chip may be placed in a square that is already occupied.) s
5 420 M
(The fourth rule is a bit trickier.) s
5 412 M
( 4\) A player may not have more than two chips in a connected group, whether) s
5 404 M
( connected orthogonally or diagonally.) s
5 388 M
(This fourth rule means that you cannot have three or more chips of the same) s
5 380 M
(color in a cluster. A group of three chips form a cluster if one of them is) s
5 372 M
(adjacent to the other two. In the following diagram, Black is not permitted to) s
5 364 M
(place a chip in any of the squares marked with an X, because doing so would) s
5 356 M
(form a group of 3 or more chips. \(Of course, the far left and right columns) s
5 348 M
(are also off-limits to Black.\)) s
5 332 M
( -----------------------------------------) s
5 324 M
( | | X | X | BB | X | | | |) s
5 316 M
( -----------------------------------------) s
5 308 M
( | | X | BB | X | X | X | X | |) s
5 300 M
( -----------------------------------------) s
5 292 M
( | | X | X | X | X | BB | X | |) s
5 284 M
( -----------------------------------------) s
5 276 M
( | | | | | X | BB | X | |) s
5 268 M
( -----------------------------------------) s
5 260 M
( | | | BB | | X | X | X | |) s
5 252 M
( -----------------------------------------) s
5 244 M
( | | X | X | | | | BB | |) s
5 236 M
( -----------------------------------------) s
5 228 M
( | | BB | | | | X | | |) s
5 220 M
( -----------------------------------------) s
5 212 M
( | | | | | BB | | | |) s
5 204 M
( -----------------------------------------) s
5 188 M
(There are two kinds of moves: add moves and step moves. In an add move, a) s
5 180 M
(player places a chip on the board \(following the rules above\). Each player has) s
5 172 M
(ten chips, and only add moves are permitted until those chips are exhausted.) s
5 164 M
(If neither player has won when all twenty chips are on the board, the rest of) s
5 156 M
(the game comprises step moves. In a step move, a player moves a chip to a) s
5 148 M
(different square, subject to the same restrictions. A player is not permitted) s
5 140 M
(to decline to move a piece \(nor to "move from square ij to square ij"\).) s
5 124 M
(A step move may create a network for the opponent by unblocking a connection) s
5 116 M
(between two enemy chips. If the step move breaks the network at some other) s
5 108 M
(point, the enemy does not win, but if the network is still intact when the chip) s
5 100 M
(has been placed back on the board, the player taking the step move loses. If) s
5 92 M
(a player makes a move that causes both players to complete a network, the other) s
5 84 M
(player wins.) s
5 68 M
(To make sure you understand the rules, try playing a few games against your) s
5 60 M
(project partners. See the instructions in "Running Network" below. Or, use) s
5 52 M
(ten pennies, ten silver coins, and a checkerboard.) s
5 36 M
(Bibliographic note: Network is taken from Sid Sackson, "A Gamut of Games,") s
5 28 M
(Dover Publications \(New York\), 1992.) s
376 508 M
(Your Task) s
376 500 M
(=========) s
376 492 M
(Your job is to implement a MachinePlayer class that plays Network well. One) s
376 484 M
(subtask is to write a method that identifies legal moves; another subtask is to) s
376 476 M
(write a method that finds a move that is likely to win the game.) s
376 460 M
(The MachinePlayer class is in the player package and extends the abstract) s
376 452 M
(Player class, which defines the following methods.) s
376 436 M
( // Returns a new move by "this" player. Internally records the move \(updates) s
376 428 M
( // the internal game board\) as a move by "this" player.) s
376 420 M
( public Move chooseMove\(\);) s
376 404 M
( // If the Move m is legal, records the move as a move by the opponent) s
376 396 M
( // \(updates the internal game board\) and returns true. If the move is) s
376 388 M
( // illegal, returns false without modifying the internal state of "this") s
376 380 M
( // player. This method allows your opponents to inform you of their moves.) s
376 372 M
( public boolean opponentMove\(Move m\);) s
376 356 M
( // If the Move m is legal, records the move as a move by "this" player) s
376 348 M
( // \(updates the internal game board\) and returns true. If the move is) s
376 340 M
( // illegal, returns false without modifying the internal state of "this") s
376 332 M
( // player. This method is used to help set up "Network problems" for your) s
376 324 M
( // player to solve.) s
376 316 M
( public boolean forceMove\(Move m\);) s
376 300 M
(In addition to the methods above, implement two constructors for MachinePlayer.) s
376 284 M
( // Creates a machine player with the given color. Color is either 0 \(black\)) s
376 276 M
( // or 1 \(white\). \(White has the first move.\)) s
376 268 M
( public MachinePlayer\(int color\)) s
376 252 M
( // Creates a machine player with the given color and search depth. Color is) s
376 244 M
( // either 0 \(black\) or 1 \(white\). \(White has the first move.\)) s
376 236 M
( public MachinePlayer\(int color, int searchDepth\)) s
376 220 M
(As usual, do not change the signatures of any of these methods; they are your) s
376 212 M
(interface to other players. You may add helper methods.) s
376 196 M
(Your MachinePlayer must record enough internal state, including the current) s
376 188 M
(board configuration, so that chooseMove\(\) can choose a good \(or at the very) s
376 180 M
(least, legal\) move. In a typical game, two players and a referee each have) s
376 172 M
(their own internal representation of the board. If all the implementations are) s
376 164 M
(free of bugs, they all have the same idea of what the board looks like,) s
376 156 M
(although each of the three uses different data structures. The referee keeps) s
376 148 M
(its own copy to prevent malicious or buggy players from cheating or corrupting) s
376 140 M
(the board. If your MachinePlayer is buggy and attempts to make an illegal) s
376 132 M
(move, the referee will grant the win to your opponent.) s
376 116 M
(Most of your work will be implementing chooseMove\(\). You will be implementing) s
376 108 M
(the minimax algorithm for searching game trees, described in Lecture 17.) s
376 100 M
(A game tree is a mapping of all possible moves you can make, and all possible) s
376 92 M
(responses by your opponent, and all possible responses by you, and so on to a) s
376 84 M
(specified "search depth." You will NOT need to implement a tree data) s
376 76 M
(structure; a "game tree" is the structure of a set of recursive method calls.) s
376 60 M
(The forceMove\(\) method forces your player to make a specified move. It is for) s
376 52 M
(testing and grading. We can set up particular board configurations by) s
376 44 M
(constructing a MachinePlayer and making an alternating series of forceMove\(\)) s
376 36 M
(and opponentMove\(\) calls to put the board in the desired configuration. Then) s
376 28 M
(we will call chooseMove\(\) to ensure that your MachinePlayer makes a good) s
376 20 M
(choice.) s
376 4 M
(The second MachinePlayer constructor, whose second parameter searchDepth is the) s
_R
S
%%Page: (3) 3
%%BeginPageSetup
_S
90 rotate
25 -587 translate
/pagenum 3 def
/fname (readme) def
/fdir () def
/ftail (readme) def
% User defined strings:
/pagenumstr (3) def
/moddatestr (03/03/13) def
/modtimestr (22:11:41) def
/user_header_p false def
/user_footer_p false def
%%EndPageSetup
column_lines
do_header
5 516 M
(chosen search depth, is also used for debugging and testing your code.) s
5 508 M
(A search depth of one implies that your MachinePlayer considers all the moves) s
5 500 M
(and chooses the one that yields the "best" board. A search depth of two) s
5 492 M
(implies that you consider your opponent's response as well, and choose the move) s
5 484 M
(that will yield the "best" board after your opponent makes the best move) s
5 476 M
(available to it. A search depth of three implies that you consider two) s
5 468 M
(MachinePlayer moves and one opponent move between them.) s
5 452 M
(The first MachinePlayer constructor should create a MachinePlayer whose search) s
5 444 M
(depth you have chosen so that it always returns a move within five seconds.) s
5 436 M
(\(This precise time limit will be important only for the Network tournament late) s
5 428 M
(in the semester.\) The second MachinePlayer constructor MUST create a) s
5 420 M
(MachinePlayer that always searches to exactly the specified search depth.) s
5 404 M
(You may want to design the MachinePlayer constructed by your first constructor) s
5 396 M
(so that it searches to a variable depth. In particular, you will almost) s
5 388 M
(certainly want to reduce your search depth for step moves, because there are) s
5 380 M
(many more possible step moves than add moves, and a search depth that is fast) s
5 372 M
(for add moves will be very slow for step moves.) s
5 356 M
(The Move class in Move.java is a container for storing the fields needed to) s
5 348 M
(define one move in Network. It is not an ADT and it has no interesting) s
5 340 M
(invariants, so all its fields are public. It is part of the interface of your) s
5 332 M
(MachinePlayer, and it is how your MachinePlayer communicates with other) s
5 324 M
(programs, so you cannot change Move.java in any way. If you would like to have) s
5 316 M
(additional methods or fields, feel free to extend the Move class; your) s
5 308 M