CodingTrain / CodingTrain/Toy-Neural-Network-JS
Cannot read property 'top' of null
- Langage dominant
- JavaScript
- Étoiles
- 437
- Forks
- 242
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
When i was following along the video i got the following error:
> Uncaught TypeError: Cannot read property 'top' of null Bird.js:44
the same error as in the video but when he fixed it and i wrote the same as him i still got the error. does somebody knows how to fix this issue?
This is the code:`
let closest = null;
let closestD = Infinity;
for (let i = 0; i < pipes.length; i++) {
let d = pipes[i].x - this.x;
if(d < closestD && d > 0) {
closest = pipes[i];
closestD = d;
}
}
let inputs = [];
inputs[0] = this.y / height;
inputs[1] = closest.top / height;
inputs[2] = closest.bottom / height;
inputs[3] = closest.x / width;
let output = this.brain.predict(inputs);
if(output[0] > 0.5) {
this.up();
}
`
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez à Bird.js:44 et suivez la boucle de pipes avant l’assemblage des inputs. Reproduisez l’état du tutoriel dans lequel aucun pipe n’est sélectionné, puis vérifiez que le chemin de prediction peut s’exécuter sans l’erreur null-property. C’est terminé lorsque le TypeError signalé ne se produit plus pendant le jeu.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- game-dev
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 35/100