DotBox.pdf - CS 2553 \u0007\b \b \u0007 \b \u0014\u0015 456\u001e2\u0015\u001e)\u001f\u0018 Dots and Boxes Game Android Application(DOT Droid >5\u0013 \u0011\u0012\u0013 \u0014\u0015\u0016\u0017\u0013\u0018\u0019\u001a\u0013 5\u001a\"\u0018\u001f\u001e\u0018\u0015\u00161 \u0011\u0012\u0013 \u0014\u001b\u0016\u0017\u0013\u001c \u001b\u001e\u001f\u0012(\u0012 \u0011\u0012\u0013 \u001d\u0016\u0018\u001b\u001e

DotBox.pdf - CS 2553 u0007b b u0007 b u0014u0015...

This preview shows page 1 out of 32 pages.

You've reached the end of your free preview.

Want to read all 32 pages?

Unformatted text preview: CS 2553     / 4562) Dots and Boxes Game Android Application ((DOT Droid) ) >5   5"1!   (   3(0* 523020241-4 523020259-5 523020924-6  !"#$%: %  ! 5.  >(,! &#'()*$"+, 322 261 .J+)(J (J"(KL(62>3!.J"" -." 2 #M3$% 2553 -.,,./,0! .12,3(0! /*,+6) (5J /./ .3 2554) 322261 Wireless and mobile communication network    0N4#2(.!O 5P>#6// 4562)(DOT Droids) J"O*LQORL L(/NOL>#6/#240!/ 4562)K5LL/S(.J"J"PO*L)/(4(,5,+$& J"#T 4U )/6UU.5 5"S/ 2PO*LUJ"*)K5L) QRLOL $0L/"))/U.J" SK5L  J"(L./,5,*J 6+)+ V(/N(L./,5,K5L/))/.5 62J" /6UU").5/R) //U4#1!.J""KL( 62/U/"/6>L/" 2)6UU(.K5L)(4( $K5LP/"/R) 6L&/#240!O*L(/N)/K#L/S(.K5L>5P()+L/RU() 4#1!.J""KL( .J"*$"K#.J"*$" 322261 Wireless and mobile communication network  >#6// 54 62) &(/N4)K#K5L5L52K5LU ./J&WXY ./)*J 62K5L.P#$%#') 5 *Z[ ++U2.41 ! 5.  >(,! "#' !"#$%>.62K5LO*L.P62P6O ,.2*!62\2UU+>.& ++U.41 .41) .416/) "#'PO O62P>./>505 ++U.41 "S J"S "O*L.P#$%62)*JO5L6.,50)S QRL 5P 322261 Wireless and mobile communication network   5"1! 523020241-4   ( 523020259-5   3(0* 523020924-6   ! U.5) ,00,/#23 (U (U- " 1  $ 1.1 *62*04Q 1.2 0N4#2(.!+>. 1.3 #^*/62+U+0+>. 1.4 #2>!"K5LU " 2  %& '()*+""" %,! 2.1 _%`""+L 2.2 2UU""+L " 3 %-"$   3.1 +&0,a5P, " 4 ' 4.1 Use Case Diagram 4.2 Activity Diagram 4.3 .J"/JO" LO\ 4.4 UML 62 Class diagram 4.5Application !  62-.Q  + .  1 1 1 2 2 3 3 11 12 12 13 13 14 15 16 19 24 322261 Wireless and mobile communication network /0  -" 1 Game of dots and boxes on the 2×2 board -" 2 Game of dots and boxes on the 3×3 board -" 3 Game of dots and boxes on the 4×4 board 1 -" 4 Game of dots and boxes on the 4×4 board 2 -" 5 Game of dots and boxes on the 4×4 board 3 -" 6 Game of dots and boxes on the 4×4 board 4 -" 7 Game of dots and boxes on the 4×4 board 5 -" 8 Mather of the game by Iran Verdi -" 9 Use Case Diagram -" 10 Activity Diagram 6UUQRL).5 -" 11 Activity Diagram 6UUQRL)(. -" 12 Full Class Inheritance diagram -" 13 Full Class Dependent diagram -" 14 Full Class Association diagram -" 15 -6(5K.62*L,"/0L/ -" 16 -6(5*L,"/0L/ -" 17 -6(5O()J"QRL) -" 18 -6(5J(&6UUQRL ).5626UUQRL)(. -" 19 -6(5J(62)/ -" 20 -6(5)/ -" 21-6(5) U/62*L .P62P)/ -" 22 -6(5*L .P62P)/ -" 23-6(5*L 0&.)(#2U)/ 322261 Wireless and mobile communication network ! 3 5 8 8 8 9 9 11 13 14 15 16 17 18 19 19 20 20 21 21 22 22 23 1 " 1  $ 1.1 ('( 23( 2UU#s,U0,"PU>3!/JNJO#T 4U&/R)//*4) *$" 2UU#s,U0,"PK5LU./(O "V.J t655!u J" (/N\6,."+$& OLK5L &#'>)vv(!5L \/V#'*$"6,." " )(O / 25)/L/U*J Dots and Boxes V#'/*$""K5LU./,/#')/U .J")/*J>3!/JNJ*S60W!/ QRL 5P>. $K5L.L.L62\ / 4562)O*L(/N)U2UU#s,U0,655!K5L&6UU).5626UU*QRL) $"/25))*/L/ */4 *J6/L60)/ 4562)&#'"/U)   2PO*LQRL)K5LU./(4(,5, )6L #'()*$"O)\ 2U.,5 (0,#T]] )ZwO*LQRL)/(/a,62OL(0,#T]].,5O*LU.UO05(,O 6LK+ #T]*0)SK5L5+$&5L *J &\6,.""PO*L(/N)K5L*S.V #'\./x55L(./62/1!O*$"5L 1.2 %42 5,   J"\/ 4562)O*L( /N)K5LU2UU#s,U0, 655! QRL),5./ (4(,5, 6,."/./(/NJ"/0)2*).J"62(/N)L/SK5L *S.J" 62J"O*L,5./RL./+LO O>.(LP+2UU#s,U0,655!& 5L.U.4/4#1!U626(5Q (N#T0/+J"/>62N)>+L/R2*) >3!/JNJ"OL2UU#s,U0,655! 322261 Wireless and mobile communication network 2 1.3 6  '(,,,   1.3.1 #^*/+>. 1.3.1.1 / 4562-(/N)U2UU#s,U0,655!K5L , 1.3.1.2 \/ 4562-O*L(/N)L/SK5L(.#')L 1.3.2 +U+0+>. 1.3.2.1 \/ 4562-5L>#6/ P2UU#s,U0,655! 1.3.2.2 /2UU&6UUQRL).5626UUQRL)(.L/ 1.3.2.3 /6(5Q((L+QRL)"600)62(/N#"(K5L 1.3.2.4 /.Pa,U`0,62,a)/ 4562) 1.3.2.5 /2UU(4#Q.26*  U/ 1.3.2.6 (/N /K5L))62(25 1.4  7 5" %&8! 1.4.1 QRL)K5LU./(4(,5, )/ 4562) 1.4.2 QRL\62QRL"PK#3$%62\0)K5LU./RL62+L6LK+"(/NPK#\0) 5K5L 1.4.3 /./RL62./+LO O>.(LP +.P(".U.4/4#1!U 2UU#s,U0,655! 1.4.4 (/NP/ 4562)"\6LK#+K5L 322261 Wireless and mobile communication network 3 " 2  %& '()*+""" %,! 2.1 )*+""" %,! 2.1.1 ,a) Dots and Boxes From wikipedia.org Dots and Boxes (also known as Boxes, Squares, Paddocks, Square-it, Dots and Dashes, Dots, Smart Dots, Dot Boxing, or, simply, the Dot Game) is a pencil and paper game for two players (or sometimes, more than two) first published in 1889 by Édouard Lucas. 54 62) (RL OJ" /),/("*/ 04(,/./L,/ 4562+5(L,/ 45) .J /"OL5,(6225%O) (P*U) 2 . (U.& )K5L/) 2 .) NR.,5.L.& 6O#M ..3.1889 >5 Édouard Lucas -1" Game of dots and boxes on the 2×2 board./ 4562)U25 2x2 322261 Wireless and mobile communication network 4 Starting with an empty grid of dots, players take turns, adding a single horizontal or vertical line between two unjoined adjacent dots. A player who completes the fourth side of a box earns one point and takes another turn. (The points are typically recorded by placing in the box an identifying mark of the player, such as an initial). The game ends when no more lines can be placed. The winner of the game is the player with the most points. ,"/0L5L,5+ 45")#)(/ 4560)K/)K5L+5(L) >5QRL)#"+5(L60&*J 6 2*) 45 2 45"0,5 ."+5(L#')K5L 2K5L 1 .2662K5L)0) (.26 2NR U$>5+J"."K5L.26O)"+5K5L) / 2 U/J"K/)(/N+5(LK5L6L 62." 2.J."K5L.262"(45 The board may be of any size. When short on time, 2×2 boxes (created by a square of 9 dots) is good for beginners, and 6×6 is good for experts. In games with an even number of boxes, it is conventional that if the game is tied then the win should be awarded to the second player (this offsets the advantage of going first). U.&25"OL) /*+5 ) 2x2 OL/J"/L (P>5OL 45 9 45 O*L #'R#("*"/ 04() */2(P*U.","*5) 62 6x6 (P*U.")P6L P) O/ 2#' P.R) /#'+L0)NL//.26) QRL"2 2#'QRL)." 2 2NJ)QRL" )) 2#'Z[K5L#U The diagram on the right shows a game being played on the 2×2 board. The second player (B) plays the mirror image of the first player's move, hoping to divide the board into two pieces and tie the game. The first player (A) makes a sacrifice at move 7; B accepts the sacrifice, getting one box. However, B must now add another line, and connects the center dot to the center-right dot, causing the remaining boxes to be joined together in a chain as shown at the end of move 8. With A's next move, A gets them all, winning 3†1. -5L+/J6(5,"/)/U25+5 2x2 QRL)."((B) )6UU R#+QRL).&6 >52>55+L/J"6U)25#' 2 ()62PO*L/(/ QRL). 6 A ((2/+5(L0) B 62 B V/U 6LK5L 1 .26 )KV0/ B 0L+5(L62J"/ 450+LU 455L+ #'*04O*L*J)"+5(L+L5L P*$" 5"6(5O R# P5U" 8 62(45L A V+5(L"*J&*/5 ()QO*L A 2 3-1 322261 Wireless and mobile communication network 5 Strategy (%-" -" 2 Game of dots and boxes on the 3×3 board The double-cross strategy. Faced with position 1, a novice player would create position 2 and lose. An experienced player would create position 3 and win. ,aO* .J U"U./(O 5LR#" 1 , QRL"*5O*/) 2+5(L*/JR#" 2 60)QRL"/ #2(U1!6L 2P*/JR#" 3 62V#'QRL2 At the start of a game, play is more or less random, the only strategy is to avoid adding the third side to any box. This continues until all the remaining (potential) boxes are joined together into chains † groups of one or more adjacent boxes in which any move gives all the boxes in the chain to the opponent. A novice player faced with a situation like position 1 in the diagram on the left, in which some boxes can be captured, takes all the boxes in the chain, resulting in position 2. But with their last move, they have to open the next (and larger) chain, and the novice loses the game, 54 ,"/0L+/ 2/(4)/ 45J"+5(L ,aO) .J *"+5(LO5L " 3 +) ) 25P,K#J" S ))"*J 2NRJ"/#'*$") */5 QRL"*5 )O*/) 2 U(N1!*/J0P6*)" 1 5"6(5O-5LvL "U)(/NPO*L (/UR1!K5L NLPO*L(/UR1!6L Q"K5L 2#'5R#" 2 60)+5(L.&(45L PO*L(L*)>v)" O*])) NRZ[0+L/0,/ )(/UR1! 62(45LQRL"*5O*/)V#'Z[6L An experienced player faced with position 1 instead plays the double-cross strategy, taking all but 2 of the boxes in the chain, leaving position 3. This leaves the last two boxes in the chain for their opponent, but then the opponent has to open the next chain. By moving to position 3, player A wins. 322261 Wireless and mobile communication network 6 3F!( ""G537 ( H F'" 1 IJ K F'""! F,   8K I % 3F!(  ("(" "&! ,JL ! 0&$H !"MN L $ ' 8!'  The double-cross strategy applies however many long chains there are. Take all but two of the boxes in each chain, but take all the boxes in the last chain. If the chains are long enough then the player will certainly win. Therefore, when played by experts, Dots and Boxes becomes a battle for control: An expert player tries to force their opponent to start the first long chain. Against a player who doesn't understand the concept of a sacrifice, the expert simply has to make the correct number of sacrifices to encourage the opponent to hand him the first chain long enough to ensure a win. If the other player also knows to offer sacrifices, the expert also has to manipulate the number of available sacrifices through earlier play. ( 2-5' I % L K  "$ H &2 3F!( L  MN 0  ! % I H !" % %"20 ("(" 0(" 0(L$ 3F!( "7$ &0  !  IH ! %"20 &$0L "'("H !"MN ! " ' There is never any reason not to accept a sacrifice, as if it is refused, the player who offered it can always take it without penalty. Thus, the impact of refusing a sacrifice need not be considered in your strategy.  L O! "" (,JL 0L  MN  3F!"( K 8&! P H !$  8  H !F" ! "2 Experienced players can avoid the chaining phenomenon by making early moves to split the board. A board split into 4x4 squares is ideal. Dividing limits the size of chains- in the case of 4x4 squares, the longest possible chain is four, filling the larger square. A board with an even number of spaces will end in a draw (as the number of 4x4 squares will be equal for each player); an odd numbered board will lead to the winner winning by one square (the 4x4 squares and 2x1 half-squares will fall evenly, with one box not incorporated into the pattern falling to the winner). 3F!( ""G54 ("(" 4 3F   ! &2! 0'  '  K " (" ,  4x4 &J &""2 ' ,"&$, , , IH G" 4x4  IH ! % "28 4! '($H !K " (" , H   ""&$ % 7 K &$ % F&&( !%   ' ""&$ % 7 K &$ % "&$H !3F!7 7 8 J 7 322261 Wireless and mobile communication network 7 A common alternate ruleset is to require all available boxes be claimed on your turn. This eliminates the double cross strategy, forcing even the experienced player to take all the boxes, and give his opponent the win. +"  %8 $ H !2( ""L &4F!  -H , 2G IJ "L& $&( 2-,! F In combinatorial game theory dots and boxes is very close to being an impartial game and many positions can be analyzed using Sprague†Grundy theory. H /0%)*+"&2'(( ,!H(!"&K "K ( '($'   Q4 %  5  H7!)*+"SpragueTGrundy 2.1.2 Dots and Boxes by mathworld.wolfram.com 2.1.2 4562)>5 mathworld.wolfram.com Dots and boxes is a two-person game based on a rectangular lattice of points. Each player, in turn, draws a horizontal or vertical line connecting two adjacent points. Whenever placement of a line complete a single 1×1 square, the square is colored in, the player scores one point, and the player having completed the square receives an additional move. &2'(( K $ (  IJ ,JL  F  3(JF" (" , &2 3F!( '( H '( &%! ' %  ' %L 7&2 &2" F HO"$'  , ! $H !F" (" , 1x1FG5" ("  L &4F' !% ", 3F!( L '( K J ' '(4! ! 7H 8! 322261 Wireless and mobile communication network 8 -" 3 Game of dots and boxes on the 4×4 board 1 -" 4 Game of dots and boxes on the 4×4 board 2 In the first part of the game, the players will avoid adding the third side of a square. H % ', 3F!( & ("(" 0! ",  " (" , 1x1 -" 5 Game of dots and boxes on the 4×4 board 3 322261 Wireless and mobile communication network 9 As soon as this is no longer possible, the player (A) who makes the next move will enable his opponent B to form a sequence of squares, called a chain. Player B will end his move by adding a segment which does not close any square and possibly opens a new chain to A.  ""84 ("(" 8!3F!( (A) &0! 7'($H !3F!( (B)4! ( 8! " % % I 4!! ! 7888!! ( HQO&&P H !3F!( (A)!! ( 8! -" 6 Game of dots and boxes on the 4×4 board 4 The best move is not necessarily the one closing as many squares as possible and opening the shortest chain to the opponent. 7! 7"""28&$K ! H !8!P ( ( Q( "K 88!'(P % I" L "2H !MN  ,! -" 7 Game of dots and boxes on the 4×4 board 5 Sometimes it is more convenient to force the other player to open a chain that it is longer than the one currently available. This can be achieved, for example, by completing all but two squares of the available chain and forming a rectangle (a so-called domino) out of the last two. 322261 Wireless and mobile communication network 10  L O&&%%" H !3F!(  P % I" %%  "" F '( "&$H ! 3($O& 7 $H !O&L L '" ("   "0!&K % I'(K F " (" 3 3!H !K   2! The winning strategies of this game are very complex and have not yet been completely classified. In 2001, David Wilson showed the 3×5 game is a win for the second player. ( 2-7  "L" %II! '(  88!   FG5 H Y 2001 David Wilson 8!' %-"7 H  3x5  3F!( " &K MN 7  (4#,a) : /J","/0L 2#s 45 P*$"+$&U*L  QRL)."*$"OL,&(/Q(" 45( 45"0L 2(LJ"/(60& *J 6) K5L*$"(L NL(L"&J"/#'R# ("*"/ 04( +5 1x1 *) (+5"V"(45) K/))R#("*"/ 04( & 2#2U5L(L+Z[ O5ULV0/60)NL(/N(L(45L"#'R#("*"/K5L 2NJ)K5L*$"60L/ 2(/N(L *$"(L4S.&"(L)("*"/ 04( K5L NL(L"K/)K5LPO*L,5)("*"/ 04( V 2 #"05,O*LQRL).5, P)&K#J"S )Z[O5Z[*$"*J&(Z[(L) .U (P*UU.26O.(L P)K5L/)V 2NJ)#'Z[2K# 322261 Wireless and mobile communication network 11 2.2   "" %,! 2.2.1 Mather of the Game by Ilan Vardi -" 8 Mather of the game by Iran Vardi 322261 Wireless and mobile communication network 12 " 3 %-"$   3.1 ,L  %-"$   3.1.1 3$%62.L.L+L/R""+LU>. >53$%25 VUKv0!""+LU Application U/JNJ""+LU / 4562) /&_%`62,a) 62.>>()+L/R2*)4#1!.J""KL( Bluetooth )/P)K 3.1.2 3$%.J"/J" 2P/OL\2UU K5L6) ˆ 3$%,aOL.P("O android sdk(P*U6(5Q*L 62J"/0) ˆ 3$%OL Eclipse (P*U\>#6/ ˆ 3$%-% Java \>#6/ 3.1.3 6Q 5P>.K5L6) ˆ ,.2*!2UU ˆ 6UU2UU (Use Case, Activity Diagram) ˆ \2UU ˆ 5(UOL626LK+O()"Q,55+2UU 322261 Wireless and mobile communication network 13  4     4.1 Use Case Diagram  9 Use Case Diagram 322261 Wireless and mobile communication network 14 4.2 Activity Diagram 4.2.1 Activity Diagram 6UUQRL).5 -" 10 Activity Diagram 6UUQRL).5 322261 Wireless and mobile communication network 15 4.2.2 Activity Diagram 6UUQRL)(. -" 11 Activity Diagram 6UUQRL)(. 4.3   "H7!H 0b  4.3.1 Android sdk .J"/JWT! 4.3.2 Android emulator P.J"android  4.3.3 Eclipse Java Helios sr1-win32 sr1 +Code 322261 Wireless and mobile communication network 16 4.4 UML '( Class diagram 4.4.1 Full Class Inheritance diagram 322261 Wireless and mobile communication network 17 4.4.2 Full Class Dependent diagram 322261 Wireless and mobile communication network 18 4.4.3 Full Class Association diagram 322261 Wireless and mobile communication network 19 4.5 Application -" 15 -6(5K.62*L,"/0L/ -" 16 -6(5*L,"/0L/ 322261 Wireless and mobile communication network 20 -" 17 -6(5O()J"QRL) -" 18 -6(5J(&6UUQRL ).5626UUQRL)(. 322261 Wireless and mobile communication network 21 -" 19 -6(5J(62)/ -" 20 -6(5)/ 322261 Wireless and mobile communication network 22 -" 21-6(5) U/62*L .P62P)/ -" 22 -6(5*L .P62P)/ 322261 Wireless and mobile communication network 23 -" 23-6(5*...
View Full Document

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture