From 6e64dc6bce9b30200928fa024f20def80a45d50c Mon Sep 17 00:00:00 2001 From: Clement Denis Date: Sat, 13 Jun 2020 08:56:37 +0200 Subject: [PATCH] tron: fix hard AI, links in subjects and set AI to run in strict mode --- subjects/tron/ai/hard.js | 2 +- subjects/tron/index.html | 4 +--- subjects/tron/tron.en.md | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/subjects/tron/ai/hard.js b/subjects/tron/ai/hard.js index 338a6f46..4896f16c 100644 --- a/subjects/tron/ai/hard.js +++ b/subjects/tron/ai/hard.js @@ -101,7 +101,7 @@ const findBestPath = ({ ai }) => { return index === 0 || index === 1 ? ai.coords[2] : ai.coords[3] } - for ({ x, y, cardinal } of ai.coords) { + for (const { x, y, cardinal } of ai.coords) { // if everything is ok it must continue with the best path arr.push(calDistance(x, y, cardinal, 0)) } diff --git a/subjects/tron/index.html b/subjects/tron/index.html index 4213e1c2..f811b6de 100644 --- a/subjects/tron/index.html +++ b/subjects/tron/index.html @@ -204,13 +204,11 @@ const buildInfo = (ai, i) => { } const notInBounds = n => n >= 100 || n < 0 - - const toBlob = async r => { if (!r.ok) throw Error(`${r.status}: ${r.statusText}`) const code = await r.text() const type = { type : 'text/javascript' } - const blob = new Blob([`${code}${injectedCode}`], type) + const blob = new Blob([`'use strict';${code}${injectedCode}`], type) return { url: URL.createObjectURL(blob, type), code } } diff --git a/subjects/tron/tron.en.md b/subjects/tron/tron.en.md index 656e2915..4a18bda0 100644 --- a/subjects/tron/tron.en.md +++ b/subjects/tron/tron.en.md @@ -43,8 +43,8 @@ You will need to create a public repository with the name `tron`. Next you need - You may use this link [tron](/public/subjects/tron?ai=&seed=1653547275), to test your AI - You need to add your AI as a user in that link > Example: - - if your git login is **Frenchris** and you want to test against **LEEDASILVA** the link becomes: `/public/subjects/tron?AI=Frenchris@master+LEEDASILVA@master` - - if you want to test against the default `/random.js` AI the link becomes: `/public/subjects/tron?AI=Frenchris@master+/random.js` + - if your git login is **Frenchris** and you want to test against **LEEDASILVA** the link becomes: [/public/subjects/tron?ai=Frenchris@master+LEEDASILVA@master](/public/subjects/tron?ai=Frenchris@master+LEEDASILVA@master) + - if you want to test against the default `/random.js` AI the link becomes: [/public/subjects/tron?ai=Frenchris@master+/random.js](/public/subjects/tron?ai=Frenchris@master+/random.js) - Open the inspector of the browser used and **disable the cache** - let's change the update function so that your AI only goes forward.