Browse Source

tron: fix hard AI, links in subjects and set AI to run in strict mode

content-update
Clement Denis 4 years ago
parent
commit
6e64dc6bce
  1. 2
      subjects/tron/ai/hard.js
  2. 4
      subjects/tron/index.html
  3. 4
      subjects/tron/tron.en.md

2
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))
}

4
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 }
}

4
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.

Loading…
Cancel
Save