GASP/GASP_Code
6
1
Fork
You've already forked GASP_Code
4

GASP_Tkinter Robots Breaks Due to Random Not Being Imported #2

Closed
opened 2020年07月20日 23:23:36 +02:00 by caleb33 · 1 comment

The Tkinter verison of Gasp does not import the random module, which the Pygame version of Gasp does do.

In Pygame Gasp:

def random_between(num1, num2):
 if num1 == num2:
 return num1
 elif num1 > num2:
 return random.randint(num2, num1)
 else:
 return random.randint(num1, num2)

This causes the robots game to break, as it cannot call the random_between method for placement of the player and robot characters. The issue is easily resolved by adding an import call to random and adding the above function to the robots file, but this functionality could be added to Tkinter Gasp.

The Tkinter verison of Gasp does not import the random module, which the Pygame version of Gasp does do. In Pygame Gasp: ``` def random_between(num1, num2): if num1 == num2: return num1 elif num1 > num2: return random.randint(num2, num1) else: return random.randint(num1, num2) ``` This causes the robots game to break, as it cannot call the `random_between` method for placement of the player and robot characters. The issue is easily resolved by adding an import call to random and adding the above function to the robots file, but this functionality could be added to Tkinter Gasp.

I added a test for this in test_api.rst, to be sure it won't return, then fixed it.

I added a test for this in test_api.rst, to be sure it won't return, then fixed it.
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
GASP/GASP_Code#2
Reference in a new issue
GASP/GASP_Code
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?