#๐Ÿ”’ help with street fighter style ai opponent

24 messages ยท Page 1 of 1 (latest)

oak granite
#

https://paste.pythondiscord.com/PT2Q
once the ai attacks it is infinetely spamming the attack for some reason , problem found far into the code in the ai class,mechanics method and the attack_select i believe

icy jacinthBOT
#

@oak granite

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lean kindle
#

I would start by turning some of those really long lines into variables and such
will make reading and understanding what is going wrong easier

oak granite
#

whihc

#

which long lines?

lean kindle
#

the stuff I noticed was above the character class

#

balrog_walking_flip=[pygame.transform.flip(pygame.image.load('balrogwalking1.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking2.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking3.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking4.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking1.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking2.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking3.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking4.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking1.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking2.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking3.png'),True,False),pygame.transform.flip(pygame.image.load('balrogwalking4.png'),True,False)]

#

this is a single line for example

oak granite
#

but thats the sprites

#

i need them in a list

#

just ignore that part lol

lean kindle
#

image_name = pygame.image.load('balrogwalking3.png')
then you can just call image_name

#

way more readeable

#

Just hard to see what is going wrong, when the code is hard to read is all

oak granite
lean kindle
#
balrog_walking_flip = [
    pygame.transform.flip(pygame.image.load('balrogwalking1.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking2.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking3.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking4.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking1.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking2.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking3.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking4.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking1.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking2.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking3.png'), True, False),
    pygame.transform.flip(pygame.image.load('balrogwalking4.png'), True, False)
]

this was ai genned but is very easy to read in comparison
you could also make a function to simply this futher but that is probably best left to future you if you wanna do that

icy jacinthBOT
#

Hey @lean kindle!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
oak granite
#

so you just reordered it?

lean kindle
#

Yeah, you could make it cleaner as well with a little math and stuff, since it is just adding 1 to the image name but that might be a bit much for you rn
but if you make stuff cleaner like that is helps people help you way faster

oak granite
#

ok cool thank you

lean kindle
#

I took a look around trying to discern your bug but I can't seem to fully understand the flow at a glance

oak granite
#

would you like me to upload a video of the error?

icy jacinthBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.