{"id":25737,"student_id":168,"content":"setBackdrop(\"bg.png\");\nvar W = 23;\nvar grid = [];\nvar points = [];\nfor (var x = 0; x \u003c W; x++) {\n grid[x] = [];\n points[x] = [];\n}\n\nforever(function () {\n for (var x = 4; x \u003c W - 4; x++) {\n for (var y = 4; y \u003c W - 4; y++) {\n pen.size = 0;\n if (grid[x][y] == undefined) continue;\n if (grid[x][y] == 'b') pen.fillColor = 'black';\n if (grid[x][y] == 'w') pen.fillColor = 'white';\n pen.drawCircle(x * 30 - 11, y * 30 - 91, 14);\n }\n }\n for (var x = 4; x \u003c W - 4; x++) {\n for (var y = 4; y \u003c W - 4; y++) {\n check(x, y, 1, 0);\n check(x, y, -1, 0);\n check(x, y, 0, 1);\n check(x, y, 0, -1);\n check(x, y, 1, 1);\n check(x, y, -1, 1);\n check(x, y, 1, -1);\n check(x, y, -1, -1);\n }\n }\n});\n\nwhen('click', function () {\n var x = Math.floor((cursor.x - 95) / 30) + 4;\n var y = Math.floor((cursor.y - 15) / 30) + 4;\n\n if (x \u003c 4 || x \u003e= 19 || y \u003c 4 || y \u003e= 19) return;\n\n if (grid[x][y] != undefined) return;\n\n grid[x][y] = 'w';\n\n for (var x = 4; x \u003c W - 4; x++) {\n for (var y = 4; y \u003c W - 4; y++) {\n points[x][y] = 0\n check2(x, y, 1, 0);\n check2(x, y, -1, 0);\n check2(x, y, 0, 1);\n check2(x, y, 0, -1);\n check2(x, y, 1, 1);\n check2(x, y, -1, 1);\n check2(x, y, 1, -1);\n check2(x, y, -1, -1);\n }\n }\n\n var biggestx = 4\n var biggesty = 4\n for (var x = 4; x \u003c W - 4; x++) {\n for (var y = 4; y \u003c W - 4; y++) {\n if (points[x][y] \u003e points[biggestx][biggesty]) {\n biggestx = x\n biggesty = y\n }\n }\n }\n grid[biggestx][biggesty] = 'b'\n console.log(biggestx + ',' + biggesty)\n console.log(points[4][4])\n});\n\nfunction check(x, y, vx, vy) {\n var re = grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2] + grid[x + vx * 3][y + vy * 3] + grid[x + vx * 4][y + vy * 4];\n if (re == 'bbbbb') {\n print(\"黑方獲勝\");\n stop();\n }\n if (re == 'wwwww') {\n print(\"白方獲勝\");\n stop();\n }\n}\n\nfunction check2(x, y, vx, vy) {\n var point = grid[x][y] + grid[x + vx][y + vy];\n if (point == 'undefinedw') {\n points[x][y] += 1\n }\n if (point == 'undefinedb') {\n points[x][y] += 10\n }\n var point = grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2];\n if (point == 'undefinedww') {\n points[x][y] += 1000\n }\n if (point == 'undefinedbb') {\n points[x][y] += 100\n }\n var point = grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2] + grid[x + vx * 3][y + vy * 3];\n if (point == 'undefinedwww') {\n points[x][y] += 100000\n }\n if (point == 'undefinedbbb') {\n points[x][y] += 10000\n }\n var point = grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2] + grid[x + vx * 3][y + vy * 3] + grid[x + vx * 4][y + vy * 4];\n if (point == 'undefinedwwww') {\n points[x][y] += 1000000\n }\n if (point == 'undefinedbbbb') {\n points[x][y] += 10000000\n }\n if (point == 'undefinedbbbw') {\n points[x][y] -= 9900\n }\n var point = grid[x - vx][y - vy] + grid[x][y] + grid[x + vx][y + vy];\n if (point == 'wundefinedw') {\n points[x][y] += 1000\n }\n if (point == 'bundefinedb') {\n points[x][y] += 100\n }\n var point = grid[x - vx][y - vy] + grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2];\n if (point == 'wundefinedww') {\n points[x][y] += 100000\n }\n if (point == 'bundefinedbb') {\n points[x][y] += 10000\n }\n var point = grid[x - vx][y - vy] + grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2] + grid[x + vx * 3][y + vy * 3];\n if (point == 'wundefinedwww') {\n points[x][y] += 1000000\n }\n if (point == 'bundefinedbbb') {\n points[x][y] += 10000000\n }\n if (point == 'wundefinedbbw') {\n points[x][y] -= 100\n }\n if (point == 'bundefinedbbw') {\n points[x][y] -= 9900\n }\n var point = grid[x - vx * 2][y - vy * 2] + grid[x - vx][y - vy] + grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2];\n if (point == 'wwundefinedww') {\n points[x][y] += 1000000\n }\n if (point == 'bbundefinedbb') {\n points[x][y] += 10000000\n }\n if (point == 'wbundefinedbw') {\n points[x][y] -= 100\n }\n if (point == 'bbundefinedbw') {\n points[x][y] -= 9900\n }\n var point = grid[x - vx * 2][y - vy * 2] + grid[x - vx][y - vy] + grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2] + grid[x + vx * 3][y + vy * 3];\n if (point == 'wbundefinedbbw') {\n points[x][y] -= 10000\n }\n var point = grid[x - vx][y - vy] + grid[x][y] + grid[x + vx][y + vy] + grid[x + vx * 2][y + vy * 2] + grid[x + vx * 3][y + vy * 3] + grid[x + vx * 4][y + vy * 4];\n if (point == 'wundefinedbbbw') {\n points[x][y] -= 10000\n }\n}","created_at":"2018-03-24T17:39:36.021+08:00","updated_at":"2019-11-09T16:37:07.079+08:00","name":"五子棋ai","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/25737/f4f3eb672e4073e34f5c6f4d31698cfa.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":178,"hashid":"kdmsj2vm","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":478226,"file_name":"bg.png","project_id":25737,"asset_id":33400,"created_at":"2018-03-24T17:41:37.885+08:00","updated_at":"2018-03-24T17:41:44.790+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦