-
Notifications
You must be signed in to change notification settings - Fork 18
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
Small fixes! #2
base: master
Are you sure you want to change the base?
Small fixes! #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ public void update() { | |
if (dead) return; | ||
|
||
double birdYPossition = (double)yPos/Resources.HEIGHT; | ||
double nextTubeHeigth = ((Resources.nextTube.getY() + Resources.TUBE_HEIGHT + Resources.TUBE_GAP_DISTANCE/2)-560+Resources.TUBE_HEIGHT)/(-260+560); // 80-380 | ||
double nextTubeHeigth = ((Resources.nextTube.getY() + Resources.TUBE_HEIGHT + Resources.TUBE_GAP_DISTANCE/2)-560+Resources.TUBE_HEIGHT)/(700); // 80-380 | ||
double distanceFromNextTube = ((Resources.nextTube.getX() - Resources.BIRD_X_POSITION)%300)/300; | ||
double inputs[] = new double[]{birdYPossition-nextTubeHeigth,nextTubeHeigth-birdYPossition,distanceFromNextTube}; | ||
birdNetwork.setInputValues(inputs); | ||
|
@@ -124,11 +124,11 @@ public void update() { | |
if (Resources.IN_TUBE) { | ||
int leftBird = Resources.BIRD_X_POSITION; | ||
int rightBird = Resources.BIRD_X_POSITION + Resources.BIRD_WIDTH; | ||
int leftTube = (int) Resources.CURRENT_TUBE.getX(); | ||
int rightTube = (int) Resources.CURRENT_TUBE.getX() + Resources.TUBE_WIDTH; | ||
int leftTube = (int) Resources.CURRENT_TUBE.getX()+50; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are these magic numbers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that when I run the game the birds died before reaching the tubes. So I tried to fix the collision detecetion by changing the values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe give the constants useful names? from reading the code I can't automatically know what that is doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you run the code on your machine? This bug is interesting and its maybe just on my machine. Birds really shouldnt collide with thin air. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have difficulties compiling it, because it's confusing to me (I don't use java) I don't really care that the constants exist, but they should be given names (like pi instead of 3.14159265 - even though that isn't used here) because that helps people who are new to the project understand the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nvm, got it to run, the birds do collide with air There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You ran the one with my changes and they still die before the tubes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I meant the original, this fixes the problem 👍 got a gen 2 bird to go forever with your version. |
||
int rightTube = (int) Resources.CURRENT_TUBE.getX() + Resources.TUBE_WIDTH-20; | ||
if ((leftBird <= rightTube && leftBird >= leftTube) || (rightBird <= rightTube && rightBird >= leftTube)) { | ||
int topTube = (int) Resources.CURRENT_TUBE.getY() + Resources.TUBE_HEIGHT; | ||
int bottomTube = topTube + Resources.TUBE_GAP_DISTANCE; | ||
int topTube = (int) Resources.CURRENT_TUBE.getY() + Resources.TUBE_HEIGHT-15; | ||
int bottomTube = topTube + Resources.TUBE_GAP_DISTANCE+30; | ||
int topBird = yPos - Resources.BIRD_HEIGHT / 2; | ||
int bottomBird = topBird + Resources.BIRD_HEIGHT; | ||
if (!(topTube < topBird) || !(bottomBird < bottomTube)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not evaluate to the same value (original's divide is 300, where as the replacement is 700), also the parentheses on the right can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run the code several times for hours. The birds were evolving but never reached the point where they could pass more than 4 tubes. I noticed that the they could pass tubes when they were nearly at equal height but when there was a big difference then they accelerated to much or dropped too low. They learnet which way to fly but they overdone it. This change fixed this issue for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, well in thatcase the comment at the end of the line should probably be fixed ;)