Skip to content

Instantly share code, notes, and snippets.

@audhiaprilliant
Created April 16, 2023 15:59
Show Gist options
  • Save audhiaprilliant/62ec32181952e941c362a8c7542130cc to your computer and use it in GitHub Desktop.
Save audhiaprilliant/62ec32181952e941c362a8c7542130cc to your computer and use it in GitHub Desktop.
Creating a Monopoly Game Board Simulation with Python
# 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