Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'top' of null #142

Open
Madmadz16 opened this issue Dec 6, 2019 · 0 comments
Open

Cannot read property 'top' of null #142

Madmadz16 opened this issue Dec 6, 2019 · 0 comments

Comments

@Madmadz16
Copy link

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();
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant