Created
April 16, 2023 15:59
-
-
Save audhiaprilliant/62ec32181952e941c362a8c7542130cc to your computer and use it in GitHub Desktop.
Creating a Monopoly Game Board Simulation with Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find the shortest spaces for spaces in circular list | |
def shortest_space( | |
source: int, | |
targets: list, | |
data_space: dict | |
): | |
# Create a dictionary | |
d_targets = {key: None for key in targets} | |
# Loop the targets | |
for target in d_targets.keys(): | |
# Calculate the minimum distance | |
shortest = distance_space( | |
data_space = data_space, | |
first_index = source, | |
second_index = target | |
) | |
# Update the dictionary | |
d_targets.update( | |
{ | |
target: shortest | |
} | |
) | |
# Get the best space | |
space = min(d_targets, key = d_targets.get) | |
# Forward-backward status | |
forward_status = True | |
return (space, forward_status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment