Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Monopoly simulation | |
def monopoly_simulation( | |
num_player: int, | |
iteration: int, | |
card: bool | |
): | |
# String of players | |
player_str = ['Player ' + str(i) for i in range(1, num_player + 1)] | |
# A dictionary for players |
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
# Player(s) movement | |
def move_spaces( | |
dict_latest: dict, | |
dices: int, | |
subiteration: int, | |
three_times: bool, | |
card: bool, | |
data_card: dict, | |
data_space: dict | |
): |
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
# Rounds on Monopoly board | |
def round_spaces( | |
dict_spaces: dict | |
): | |
# Latest round | |
latest_round = dict_spaces['round'] | |
# Update status | |
updated_status = False | |
# After-before spaces |
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
# Select a card and show the result | |
def take_cards( | |
subiteration_dict: dict, | |
card: bool, | |
chance_card: bool, | |
data_card: dict, | |
data_space: dict | |
): | |
# Card status | |
card_status = card |
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 |
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 in circular list | |
def distance_space( | |
data_space: dict, | |
first_index: int, | |
second_index: int | |
): | |
# Update the data space | |
data_space_update = (data_space[first_index - 1:] + data_space[:first_index - 1]) | |
# Calculate the distance |
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
# Update spaces | |
def update_space( | |
last_move: int, | |
dices: list, | |
data_space: dict | |
): | |
# Updated board based latest move | |
l_board = (data_space[last_move - 1:] + data_space[:last_move - 1]) | |
# Current space | |
d_current_space = [l_board[np.sum(dices) % len(l_board)]] |
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
# ---------- SUBPLOT WITH GRIDSPEC ---------- | |
# Figure size | |
fig = plt.figure(figsize = (10, 8)) | |
# Create a grid for plots (2 rows & 3 columns) | |
gs = gridspec.GridSpec(nrows = 2, ncols = 3, figure = fig) | |
ax1 = fig.add_subplot(gs[0, :]); | |
ax1.set_title('# Customer by payment method'); |
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
# ---------- SUBPLOT (2 ROWS, 2 COLUMNS) ---------- | |
# Create a grid for plots (2 rows & 2 columns) | |
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows = 2, ncols = 2, figsize = (10, 6)) | |
# Bar plot - 1 | |
ax1.bar( | |
x = 'gender', | |
height = 'customerID', | |
data = df_group_2, |
NewerOlder