{"id":377679,"student_id":10,"content":"grid[4] = 'o';\n\nforever(loop); //不斷執行遊戲迴圈\n\n//遊戲迴圈中印出格子分數\nfunction loop () {\n \n}\n\nfunction AI (grid) {\n \n}\n\n//評估函式\nfunction evaluate (grid) {\n \n}\n\n//計算某一條線的分數\nfunction getScore (a, b, c) {\n \n}","created_at":"2022-05-13T13:03:07.643+08:00","updated_at":"2022-05-13T13:03:21.126+08:00","name":"井字遊戲AI(預設版) 副本","language":"javascript","screenshot":{"url":"/uploads/project/screenshot/377679/a08e346e0ea4ffc0fa118d14e690a0be.jpg"},"parent_id":172912,"plugin":"Game.set({width: 1200, height: 900});\n\nsetBackdrop('#f8e8cc');\n\nvar scores = [0, 0, 0, 0, 0, 0, 0, 0, 0];\nvar grid = ['', '', '', '', '', '', '', '', ''];\nvar offsetX = 240;\nvar offsetY = 90;\nvar width = 240;\nvar turn = 'o';\n\nforever(loop);\nwhen('click', onclick);\n\nfunction check () {\n var g = grid;\n if (g[0] == g[1] \u0026\u0026 g[1] == g[2]) return g[0];\n if (g[3] == g[4] \u0026\u0026 g[4] == g[5]) return g[3];\n if (g[6] == g[7] \u0026\u0026 g[7] == g[8]) return g[6];\n if (g[0] == g[3] \u0026\u0026 g[3] == g[6]) return g[0];\n if (g[1] == g[4] \u0026\u0026 g[4] == g[7]) return g[1];\n if (g[2] == g[5] \u0026\u0026 g[5] == g[8]) return g[2];\n if (g[0] == g[4] \u0026\u0026 g[4] == g[8]) return g[0];\n if (g[2] == g[4] \u0026\u0026 g[4] == g[6]) return g[2];\n return false;\n}\n\nfunction onclick () {\n var x = Math.floor((cursor.x - offsetX)/width);\n var y = Math.floor((cursor.y - offsetY)/width);\n var i = y*3 + x;\n if (x \u003e 2 || y \u003e 2 || x \u003c 0 || y \u003c 0) return;\n if (grid[i] !== '') return;\n var olen = grid.filter(item =\u003e item == 'o').length;\n var xlen = grid.filter(item =\u003e item == 'x').length;\n grid[i] = xlen \u003e= olen ? 'o' : 'x';\n AI(grid);\n}\n\nfunction loop () {\n var winner = check();\n if (winner) {\n text = winner + ' 獲勝!';\n stop();\n } else if (grid.indexOf('') === -1) {\n text = '平手';\n stop();\n } else {\n text = 'playing';\n }\n drawText(text , 500, 20, 'black', 45, 'Comic Sans MS');\n \n for (var i=0; i \u003c 9; i++) {\n var x = i%3;\n var y = (i - x)/3;\n var xx = x*width + offsetX;\n var yy = y*width + offsetY;\n var color = grid[i] == 'o' ? '#ff595a' : '#4a86e8';\n \n drawText(grid[i], xx + 40, yy, color, 240, 'Comic Sans MS');\n \n pen.size = 30;\n pen.color = '#222';\n pen.fillColor = '#fff';\n pen.drawRect(xx, yy, 240, 240);\n }\n}\n\nfunction showScore (score, i) {\n var x = i%3;\n var y = (i - x)/3;\n var xx = x*width + offsetX + 20;\n var yy = y*width + offsetY + 20;\n print(score, xx, yy, 'black', 60, 'Comic Sans MS');\n}\n\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":340,"hashid":"meysw3mnj","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":8404706,"file_name":"Gymnopedie_No_1.mp3","project_id":377679,"asset_id":244103,"created_at":"2022-05-13T13:03:07.648+08:00","updated_at":"2022-05-13T13:03:07.648+08:00"},{"id":8404707,"file_name":"koding.png","project_id":377679,"asset_id":244104,"created_at":"2022-05-13T13:03:07.649+08:00","updated_at":"2022-05-13T13:03:07.649+08:00"},{"id":8404708,"file_name":"space_bg.jpg","project_id":377679,"asset_id":244105,"created_at":"2022-05-13T13:03:07.651+08:00","updated_at":"2022-05-13T13:03:07.651+08:00"},{"id":8404709,"file_name":"earth.png","project_id":377679,"asset_id":244106,"created_at":"2022-05-13T13:03:07.652+08:00","updated_at":"2022-05-13T13:03:07.652+08:00"}]
Orange Apple Learning Platform
My Projects
View Project Page
Export
Remix
Import
Delete
Download Android APP (APK)
Screenshot
繁中
简中
English
日本語
1:1:1
1:1
Full Width
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer
Scan the QRCode below with your phone to install
Or you can
download APK
to this computer