CodingTrain / CodingTrain/Toy-Neural-Network-JS

Cannot read property 'top' of null

Đang mở
#142 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
437
Fork
242
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu tại Bird.js:44 và lần theo vòng lặp pipes trước khi các inputs được tập hợp. Tái hiện trạng thái của tutorial khi không có pipe nào được chọn, sau đó xác minh rằng đường dẫn prediction có thể chạy mà không gặp lỗi null-property. Hoàn tất khi TypeError được báo cáo không còn xảy ra trong trò chơi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
game-dev
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.