2012-12-07 46 views
0

我想提出一個五子棋遊戲,我有使用二維數組,像這樣的板設置:我想搬到一個兩個維數組內的項目在Java中

stoneCounts[0][0]=stoneCounts[0][1]=stoneCounts[0][2]=stoneCounts[0][3]=stoneCounts[0][4] = W; 
stoneCounts[11][0]=stoneCounts[11][1] = W; 
stoneCounts[16][0]=stoneCounts[16][1]=stoneCounts[16][2]= W; 
stoneCounts[18][0]=stoneCounts[18][1]=stoneCounts[18][2]=stoneCounts[18][3]=stoneCounts[18][4]=W; 
stoneCounts[23][0]=stoneCounts[23][1]=stoneCounts[23][2]=stoneCounts[23][3]=stoneCounts[23][4] =B; 
stoneCounts[12][0]=stoneCounts[12][1] = B; 
stoneCounts[7][0]=stoneCounts[7][1]=stoneCounts[7][2]=stoneCounts[7][3]=stoneCounts[7][4] =B; 
stoneCounts[5][0]=stoneCounts[5][1]=stoneCounts[5][2]= B; 

當玩家走棋,怎麼能我得到了,例如。 'W'在stoneCounts [0] [1]移動到stoneCounts [2] [3]

+0

Java?還有別的嗎? – Thilo

+0

在java中,對不起。 –

+0

stoneCounts [2] [3] = stoneCounts [0] [1]? – igon

回答

0

我假設你也有一個E代表一個空的方塊。然後,所有你需要做的就是(假設新方已爲空):

stoneCounts[2][3] = stoneCounts[0][1]; 
stoneCounts[0][1] = E; 

換句話說,就在老方的狀態複製到新廣場(記住以某種方式清除的狀態老廣場)。

相關問題