关于五子棋 代码找不出问题 老师 能看你的源码吗?我的是这样的:chess {::: : : : --}
chessBoard = [] me = wins = [] count = over = myWin = [] computerWin = [] (i = i<i++){
chessBoard[i] = [] (j = j<j++){
chessBoard[i][j] = }
}
(i = i<i++){
wins[i] = [] (j = j<j++){
wins[i][j] = [] }
}
(i = i<i++){
(j = j<j++){
(k = k<k++){
wins[i][j+k][count] = }
count++ }
}
(i = i<i++){
(j = j<j++){
(k = k<k++){
wins[i+k][j][count] = }
count++ }
}
(i = i<i++){
(j = j<j++){
(k = k<k++){
wins[i+k][j+k][count] = }
count++ }
}
(i = i<i++){
(j = j>j--){
(k = k<k++){
wins[i+k][j-k][count] = }
count++ }
}
.(count) (i = i<counti++){
myWin[i] = computerWin[i] = }
chess = .() canvas = chess.() canvas.= loadImage = () loadImage.= loadImage.= () {
canvas.(loadImage) () } () {
(i = i<i++) {
canvas.(i * ) canvas.(i * ) canvas.() canvas.(i * ) canvas.(i * ) canvas.() }
}
= (ijme) {
canvas.() canvas.(i*j**.) gradient = canvas.(i*-j*-i*j*) (me){
gradient.() gradient.() }{
gradient.() gradient.() }
canvas.= gradient canvas.() canvas.() } chess.= (e) {
(over){
}
(!me){
}
x = e. y = e. i = (x%>|| x%== ) ? .(x/)+:.(x/) j = (y%>|| y%== ) ? .(y/)+:.(y/) (chessBoard[i][j] == ){
(ijme) chessBoard[i][j] == (k = k<countk++){
(wins[i][j][k]){
myWin[k]++ computerWin[k] = (myWin[k] == ){
() over = }
}
.(+myWin[k]) }
(!over){
me = !me () }
}
} = () {
max = u = v = myScore = [] computerScore = [] (i = i<i++){
myScore[i] = [] computerScore[i] = [] (j = j<j++){
myScore[i][j] = computerScore[i][j] = }
}
(i = i<i++){
(j = j<j++){
(chessBoard[i][j] == ){
(k = k<countk++){
(wins[i][j][k]){
(myWin[k] == ){
myScore[i][j] += }(myWin[k] == ){
myScore[i][j] += }(myWin[k] == ){
myScore[i][j] += }(myWin[k] == ){
myScore[i][j] += }
(computerWin[k] == ){
computerScore[i][j] += }(computerWin[k] == ){
computerScore[i][j] += }(computerWin[k] == ){
computerScore[i][j] += }(computerWin[k] == ){
computerScore[i][j] += }
}
}
(myScore[i][j] > max){
max = myScore[i][j] u = i v = j }(myScore[i][j] == max ){
(computerScore[i][j] > computerScore[u][v]){
u = i v = j }
}
(computerScore[i][j] > max){
max = computerScore[i][j] u = i v = j }(computerScore[i][j] == max ){
(myScore[i][j] > myScore[u][v]){
u = i v = j }
}
}
}
}
.(u++v) (uv) chessBoard[u][v] = (k = k<countk++){
(wins[u][v][k]){
computerWin[k]++ myWin[k] = (computerWin[k] == ){
() over = }
}
}
(!over){
me = !me }
}
添加回答
举报
0/150
提交
取消