final int BSIZE = 100;\nint[][] field;\nboolean bBlacksTurn;\nvoid setup(){\n size(8*BSIZE,8*BSIZE);\n bBlacksTurn = true;\n field = new int[8][8];\n for(int i=0; i<8; ++i){\n for(int j=0; j<8; ++j){\n if((i==3||i==4)&&(j==3||j==4)){\n field[i][j] = ((i+j)%2==0)?1:-1; \/\/ initial stones;\n }else{\n field[i][j] = 0;\n }\n }\n }\n}\nvoid draw(){\n \/\/draw field\n background(0,160,0);\n stroke(0);\n for(int i=1; i<8; ++i){\n line(i*BSIZE,0,i*BSIZE,height);\n line(0, i*BSIZE, width, i*BSIZE);\n }\n noStroke();\n fill(0);\n ellipse(BSIZE*2,BSIZE*2,10,10);\n ellipse(BSIZE*6,BSIZE*2,10,10);\n ellipse(BSIZE*2,BSIZE*6,10,10);\n ellipse(BSIZE*6,BSIZE*6,10,10);\n \/\/ draw stones\n noStroke();\n for(int i=0; i<8; ++i){\n for(int j=0; j<8; ++j){\n if(field[i][j]==1){\n fill(0);\n ellipse((i*2+1)*BSIZE\/2,(j*2+1)*BSIZE\/2, BSIZE*0.8, BSIZE*0.8);\n }else if(field[i][j]==-1){\n fill(255);\n ellipse((i*2+1)*BSIZE\/2,(j*2+1)*BSIZE\/2, BSIZE*0.8, BSIZE*0.8);\n }\n }\n }\n}\nvoid mouseReleased(){\n int x = mouseX\/BSIZE;\n int y = mouseY\/BSIZE;\n boolean puttable = false;\n if(field[x][y]==0){\n puttable = checkDirection(x,y,-1,-1) | puttable;\n puttable = checkDirection(x,y,-1,0) | puttable;\n puttable = checkDirection(x,y,-1,1) | puttable;\n puttable = checkDirection(x,y,0,-1) | puttable;\n puttable = checkDirection(x,y,0,1) | puttable;\n puttable = checkDirection(x,y,1,-1) | puttable;\n puttable = checkDirection(x,y,1,0) | puttable;\n puttable = checkDirection(x,y,1,1) | puttable;\n if(puttable){\n field[x][y] = currentStone();\n bBlacksTurn = !bBlacksTurn;\n }\n }\n}\nboolean checkDirection(int x, int y, int directionX, int directionY){\n if(checkBound(x+directionX, y+directionY) && field[x+directionX][y+directionY] != currentStone()){\n return checkStones(x, y, directionX, directionY);\n }\n return false;\n}\nboolean checkStones(int x, int y, int directionX, int directionY){\n if(checkBound(x+directionX, y+directionY) && field[x+directionX][y+directionY]==currentStone()){ \/\/ find\n return true;\n }else if(checkBound(x+directionX, y+directionY) && field[x+directionX][y+directionY]==0){ \/\/ not find\n return false;\n }else if(checkBound(x+directionX, y+directionY) && checkStones(x+directionX, y+directionY, directionX, directionY)){\n field[x+directionX][y+directionY] = currentStone(); \/\/ reverse\n return true;\n }else{\n return false;\n }\n}\nboolean checkBound(int x, int y){\n return x>=0 && x<8 && y>=0 && y<8;\n}\nint currentStone(){\n return (bBlacksTurn)?1:-1;\n}<\/code><\/pre><\/div>\n\n\n\n\u5b9f\u884c\u3057\u305f\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u753b\u9762\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n