09.09.2013 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A.6 FigureMap.java 163<br />

41 {<br />

42 noCols = c o l s ;<br />

43 noRows = rows ;<br />

44 r e s e t F i g B o a r d ( ) ;<br />

45 mapFigures ( b ) ;<br />

46 c o u n t P i e c e s ( ) ;<br />

47 i n t s c o r e ;<br />

48 s c o r e = w h i t e P i e c e s − b l a c k P i e c e s ;<br />

49 // System . out . p r i n t l n (” s c o r e ”+s c o r e+” WhiteS ”+w h i t e P i e c e s<br />

+” BlackS ”+b l a c k P i e c e s ) ;<br />

50 r e t u r n ( s c o r e ) ;<br />

51 }<br />

52<br />

53 // Returner f i g B o a r d e t f o r e t b r a e t ( f i g u r B r a e t t e t )<br />

54 p u b l i c i n t [ ] [ ] getFigBoard ( i n t [ ] [ ] b , i n t c o l s , i n t rows ) {<br />

55 noCols = c o l s ;<br />

56 noRows = rows ;<br />

57 r e s e t F i g B o a r d ( ) ;<br />

58 mapFigures ( b ) ;<br />

59 r e t u r n ( f i g B o a r d ) ;<br />

60 }<br />

61<br />

62<br />

63<br />

64 // Navnegiver de e n k e l t e f e l t e r e f t e r h v i l k e n f i g u r de hoere<br />

t i l .<br />

65 //( Navnene e r l i g e t a l f o r s o r t e f i g u r e og u l i g e f o r hvide )<br />

66 p u b l i c void mapFigures ( i n t [ ] [ ] b ) {<br />

67 { // F o e r s t e kolone nedad<br />

68 f i g B o a r d = new i n t [ tModel . noCols ] [ tModel . noRows ] ;<br />

69 i n t c =0;<br />

70 {<br />

71 f o r ( i n t r =0; r < tModel . noRows ; r++)<br />

72 {<br />

73 i f ( b [ c ] [ r ] == 1)<br />

74 {<br />

75 i f ( f i g B o a r d [ c ] [ r ] == 0)<br />

76 {<br />

77 s e t F i g u r e ( c , r , figW ) ;<br />

78 figW = figW +2;<br />

79 }<br />

80 }<br />

81 e l s e<br />

82 {<br />

83 i f ( b [ c ] [ r ] == 0)<br />

84 {<br />

85 i f ( f i g B o a r d [ c ] [ r ] == 0)<br />

86 {<br />

87 s e t F i g u r e ( c , r , f i g B ) ;<br />

88 f i g B = f i g B +2;<br />

89 }<br />

90 }<br />

91 }<br />

92 }<br />

93 }

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!