{"id":49560,"student_id":10,"content":"var grid = [];\nvar maze = [];\n\nfor (var x=0; x\u003c8; x++) {\n grid[x] = [];\n maze[x] = [];\n for (var y=0; y\u003c8; y++) {\n grid[x][y] = [0,0,0,0];\n if (x == 0 || x == 7 || y == 0 || y == 7) maze[x][y] = 'wall';\n else maze[x][y] = '';\n }\n}\n\nmaze[6][6] = 'target';\n\n\nvar player = {\n x: 1,\n y: 1\n}\n\nwhen('click', function () {\n var x = Math.floor(cursor.x/50);\n var y = Math.floor(cursor.y/50);\n if (x \u003e 7 || y \u003e 7) return;\n if (maze[x][y] == '') maze[x][y] = 'wall';\n else if (maze[x][y] == 'wall') maze[x][y] = '';\n});\n\nforever(function(){\n for (var x=0; x\u003c8; x++) {\n for (var y=0; y\u003c8; y++) {\n if (maze[x][y] == '') {\n pen.fillColor = '#333';\n }\n else if (maze[x][y] == 'wall') {\n pen.fillColor = '#555';\n }\n else if (maze[x][y] == 'target') {\n pen.fillColor = 'blue';\n }\n pen.color = '#333';\n pen.drawRect(x*50, y*50, 50, 50);\n }\n }\n pen.fillColor = 'red';\n pen.drawRect(player.x*50, player.y*50, 50, 50);\n \n});\n\n\n\n\n\n\n\n// forever(function () {\n var current = grid[player.x][player.y];\n var i=current.indexOf(Math.max(...current));\n if (i == 0) player.y--;\n if (i == 1) player.x++;\n if (i == 2) player.y++;\n if (i == 3) player.x--;\n \n// });\n","created_at":"2018-11-22T18:39:02.345+08:00","updated_at":"2019-10-30T20:19:28.299+08:00","name":"Q-learning maze","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/49560/89edcce60b8890776f43b51e69f48ea4.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":301,"hashid":"4y3s9wpd","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦