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

7.05 project.md is hard to read #395

Open
jdonwells opened this issue May 10, 2022 · 3 comments
Open

7.05 project.md is hard to read #395

jdonwells opened this issue May 10, 2022 · 3 comments
Assignees
Labels
Bug IntroCS.2 Medium Severity Makes the lesson hard to use but has a workaround

Comments

@jdonwells
Copy link

The biggest problem is "pp". It is defined as "pp(power points)".

We give the students the AP for the Pokemon types. We also give them the Power for each attack.

At no time do we give them the "pp". They must try to figure out if that is the same as Power or AP or something else.

The attack amount is hard to understand since it isn't a real sentence. Somehow there is a random bullet point in there.
image

@jdonwells
Copy link
Author

I have been looking at this for a while now.

The game design seems a bit off.

Each Pokemon has a max attack amount. Each attack has an attack power. The damage is dependent on the lower of the two.
So for example Grass Pokemon have max attack powers of 40, 50, and 60. The Grass types have attacks with powers 50, 55, and 130. Now, the higher the attack power the lower the accuracy.

Let's think about that. You can't do 130 damage with a Grass Pokemon. The most is 60. You would never ever choose that attack because you have a much higher chance of missing. If your Pokemon can only do a max of 40 damage you will always want to choose the power 50 attack which is a guaranteed hit. You have just lost some of the game's fun.

What I am going to do instead is what many games do. Each Pokemon has an attack power. That attack power is higher if the Pokemon has lower health and vice versa. Each attack will then have an attack power percentage. That percentage will be higher if the accuracy is lower and vice versa. I will make the percentage and accuracy multiply out to be around 50%. I will also use 3 random numbers added together for the damage so it falls on a bell curve. That way damage will mostly be around 25% of attack power over several attacks. But there is still a good chance to get very high or very low damage depending on how you play it.

We also need to look at this in the given solution:

            # the attack should also randomly fail according to the attack's accuracy:
            if accuracy != 100 and random.randint(100 - accuracy, 100) == 100:
                print(self.name + " used " + attack_name + " and it failed!")

I have seen uglier things, but this is ugly. So if accuracy is 100 it is a guaranteed hit. Good. Otherwise we have a random chance of missing. So if accuracy is the chance of a hit 100 - accuracy is the chance of a miss. We choose a random number between the chance of a miss and 100. If that is 100 then you miss.

Wait...What?!!! Let's compute that for 100% accuracy. The chance of a miss is 1 in 101. Close enough. Okay let's look at 0 accuracy. The chance of a miss is 1 in 1. Perfect. Now what about 50% we are expecting 1 in 2. The chance of missing is 1 in 51. 1% accuracy is 1 in 2. That doesn't seem right.

How about we just do something like this instead.

    def calculate_damage(self, attack_power):
        if randint(1, 100) <= self.accuracy:
            scaled_attack = round(attack_power * self.power_percent / 100 / 3)
            # damage amount is on a bell curve. Most of the time you do half the max damage.
            return (randint(1, scaled_attack) + randint(0, scaled_attack) + randint(0, scaled_attack))
        else:
            # Ha ha missed me
            return 0

@jdonwells
Copy link
Author

The names of 2 Pokeman are misspelled. Bulbasaur and Poliwag.

@Dan-TEALS Dan-TEALS self-assigned this May 13, 2022
@Dan-TEALS Dan-TEALS added Bug IntroCS.2 Medium Severity Makes the lesson hard to use but has a workaround labels May 13, 2022
@jdonwells
Copy link
Author

I have rewritten it. #402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IntroCS.2 Medium Severity Makes the lesson hard to use but has a workaround
Projects
None yet
Development

No branches or pull requests

2 participants