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

Small fixes! #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Small fixes! #2

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 27, 2017

Small fixes I found while testing your version. Now runs smooth and learns correctly

pseudobanana added 2 commits May 27, 2017 22:48
- fixed Tube hitboxes
- fixed nextTubeHeight calculation and proper jump
- renamed "Colums passed: " to the real data it shows "Fitness: "
@@ -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
Copy link

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.

Copy link
Author

@ghost ghost May 31, 2017

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.

Copy link

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

@@ -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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these magic numbers?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

The 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

Copy link
Author

@ghost ghost Jun 2, 2017

Choose a reason for hiding this comment

The 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. :)
Edit: Later I might work more on it and change names and stuff but otherwise I'm new to programming and this was my first glance at java.

Copy link

Choose a reason for hiding this comment

The 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.
(I do agree however, that birds shouldn't collide with thin air)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, got it to run, the birds do collide with air

Copy link
Author

Choose a reason for hiding this comment

The 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?

Copy link

Choose a reason for hiding this comment

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

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

Successfully merging this pull request may close these issues.

1 participant