Commit fe9a8878 authored by Prathisha Kunnumbrath Manden's avatar Prathisha Kunnumbrath Manden
Browse files

Experiment results, RL agent development

parent ae85f545
import pandas as pd
import matplotlib.pyplot as plt
dataframe = pd.read_csv("Experiments/match_3_experiments_final.csv")
dataframe = pd.read_csv("Experiments_old/match_3_experiments_final.csv")
df1 = dataframe[dataframe['Grid Size'] == "(5, 5)"]
df2 = dataframe[dataframe['Grid Size'] == "(7, 7)"]
df3 = dataframe[dataframe['Grid Size'] == "(10, 10)"]
......@@ -34,7 +34,7 @@ plt.legend(["Grid Size (5, 5)", "Grid Size (7, 7)", "Grid Size (10, 10)", "Grid
# plt.title('')
plt.xlabel('Number of Colors')
plt.ylabel('Average Number of Moves until Shuffle occurs')
plt.savefig('Experiments/plot1.png')
plt.savefig('Experiments_old/plot1.png')
plt.clf()
......@@ -52,7 +52,7 @@ plt.plot(x5, y5)
plt.legend(["Grid Size (5, 5)", "Grid Size (7, 7)", "Grid Size (10, 10)", "Grid Size (15, 15)", "Grid Size (20, 20)"])
plt.xlabel('Number of Colors')
plt.ylabel('Average Number of Times Deadlock Occurred')
plt.savefig('Experiments/plot2.png')
plt.savefig('Experiments_old/plot2.png')
plt.clf()
......@@ -69,7 +69,7 @@ plt.plot(x5, y5)
plt.legend(["Grid Size (5, 5)", "Grid Size (7, 7)", "Grid Size (10, 10)", "Grid Size (15, 15)", "Grid Size (20, 20)"])
plt.xlabel('Number of Colors')
plt.ylabel('Average Score per Move')
plt.savefig('Experiments/plot3.png')
plt.savefig('Experiments_old/plot3.png')
plt.clf()
......@@ -86,7 +86,7 @@ plt.plot(x5, y5)
plt.legend(["Grid Size (5, 5)", "Grid Size (7, 7)", "Grid Size (10, 10)", "Grid Size (15, 15)", "Grid Size (20, 20)"])
plt.xlabel('Number of Colors')
plt.ylabel('Average Number of Possible Moves per Configuration')
plt.savefig('Experiments/plot4.png')
plt.savefig('Experiments_old/plot4.png')
plt.clf()
......@@ -103,4 +103,4 @@ plt.plot(x5, y5)
plt.legend(["Grid Size (5, 5)", "Grid Size (7, 7)", "Grid Size (10, 10)", "Grid Size (15, 15)", "Grid Size (20, 20)"])
plt.xlabel('Number of Colors')
plt.ylabel('Average Number of Avalanche matches occurred')
plt.savefig('Experiments/plot5.png')
\ No newline at end of file
plt.savefig('Experiments_old/plot5.png')
\ No newline at end of file
import pandas as pd
import matplotlib.pyplot as plt
import os
dataframe = pd.read_csv("exp_mean_median_results.csv")
path = os.path.expanduser("~/Desktop/Desktop/Prathisha/Master_Thesis/Experiments/plots/1/")
df1 = dataframe[(dataframe['Grid Size'] == "(5, 5)") & (dataframe['Agent'] == "top_agent")]
x = df1['Number of Colors']
y = df1['Mean score per Game Setting']
plt.xlabel('Number of Colors')
plt.ylabel('Mean Score per Game Setting')
plt.plot(x, y, color='r')
df2 = dataframe[(dataframe['Grid Size'] == "(5, 5)") & (dataframe['Agent'] == "bottom_agent")]
x = df2['Number of Colors']
y = df2['Mean score per Game Setting']
plt.plot(x, y, color='b')
plt.legend(["Top Agent", "Bottom Agent"])
plt.title("5X5 Grid")
plt.show()
\ No newline at end of file
# dataframe = pd.read_csv("exp_mean_median_results.csv")
#
# df1 = dataframe[(dataframe['Grid Size'] == "(5, 5)") & (dataframe['Agent'] == "top_agent")]
# x = df1['Number of Colors']
# y = df1['Mean score per Game Setting']
# plt.xlabel('Number of Colors')
# plt.ylabel('Mean Score per Game Setting')
# plt.plot(x, y, color='r')
# df2 = dataframe[(dataframe['Grid Size'] == "(5, 5)") & (dataframe['Agent'] == "bottom_agent")]
# x = df2['Number of Colors']
# y = df2['Mean score per Game Setting']
# plt.plot(x, y, color='b')
# plt.legend(["Top Agent", "Bottom Agent"])
# plt.title("5X5 Grid")
# plt.show()
df = pd.read_csv("exp_mean_median_results.csv")
# grid_sizes = ['(5, 5)', '(7, 7)', '(10, 10)', '(15, 15)', '(20, 20)']
# input_data = pd.read_csv('../m3/exp_game_setting.csv')
max_colors = sorted(df['Number of Colors'].unique().tolist())
grid_sizes = df['Grid Size'].unique().tolist()
agents = ["top_agent", "bottom_agent"]
for grid_size in grid_sizes:
for agent in agents:
# grid_size = '(' + size + ')'
(row, col) = grid_size.split(',')[0].replace("(", ""), grid_size.split(",")[1].replace(" ", "").replace(")", "")
# for max_color in max_colors:
df1 = df[(df['Grid Size'] == grid_size) & (df['Agent'] == agent)]
x = df1['Number of Colors']
y = df1['Mean regenerations during init']
plt.xlabel('Number of Colors')
# plt.ylabel('Regenerations during init')
plt.plot(x, y)
y2 = df1['Mean Matches Occurred during init']
plt.plot(x, y2)
y3 = df1['Mean Deadlocks during init']
plt.plot(x, y3)
plt.legend(['Regenerations during init',
'Matches Occurred during init',
'Deadlocks during init'])
title = "%sX%s Grid" % (row, col)
plt.title(title)
filename = "%sX%s_regen_init" % (row, col)
# plt.savefig(path+filename)
plt.show()
plt.clf()
y4 = df1['Mean Shuffles/Deadlocks Occurred per move']
plt.plot(x, y4)
plt.legend(['Shuffles/Deadlocks Occurred per move'])
title = "%sX%s Grid played by %s" % (row, col, agent)
plt.title(title)
filename = "%sX%s_mean_deadlock_%s" % (row, col, agent)
# plt.savefig(path+filename)
plt.show()
plt.clf()
y5 = df1['Mean Shuffles/Deadlocks Occurred per game']
plt.plot(x, y5)
plt.legend(['Shuffles/Deadlocks Occurred per game'])
title = "%sX%s Grid played by %s" % (row, col, agent)
plt.title(title)
filename = "%sX%s_mean_shuffle_per_game_%s" % (row, col, agent)
# plt.savefig(path+filename)
plt.show()
plt.clf()
y6 = df1['Mean Possible/Playable Moves per config']
plt.plot(x, y6)
plt.legend(['Possible/Playable Moves per config'])
title = "%sX%s Grid played by %s" % (row, col, agent)
plt.title(title)
filename = "%sX%s_mean_possible_moves_%s" % (row, col, agent)
# plt.savefig(path+filename)
plt.show()
plt.clf()
# filename = "%s.csv" % agent
# title = "%sX%s Grid played by %s" % (row, col, agent)
# plt.show()
import pandas as pd
import matplotlib.pyplot as plt
import os
path = os.path.expanduser("~/Desktop/Desktop/Prathisha/Master_Thesis/Experiments/plots/1/")
df = pd.read_csv("exp_mean_median_results.csv")
# grid_sizes = ['(5, 5)', '(7, 7)', '(10, 10)', '(15, 15)', '(20, 20)']
# input_data = pd.read_csv('../m3/exp_game_setting.csv')
max_colors = df['Number of Colors'].unique().tolist()
grid_sizes = df['Grid Size'].unique().tolist()
agents = ["top_agent", "bottom_agent"]
for grid_size in grid_sizes:
# grid_size = '(' + size + ')'
(row, col) = grid_size.split(',')[0].replace("(", ""), grid_size.split(",")[1].replace(" ", "").replace(")", "")
# for max_color in max_colors:
df1 = df[(df['Grid Size'] == grid_size) & (df['Agent'] == "bottom_agent")]
x = df1['Number of Colors']
y = df1['Mean non-deterministic score after first move']
plt.xlabel('Number of Colors')
plt.ylabel('Mean non-deterministic score')
plt.plot(x, y)
filename = "%sX%s_mean_nondet_score" % (row, col)
title = "%sX%s Grid" % (row, col)
plt.title(title)
plt.savefig(path+filename)
plt.clf()
import pandas as pd
import matplotlib.pyplot as plt
import os
dataframe = pd.read_csv("exp_mean_median_results.csv")
path = os.path.expanduser("~/Desktop/Desktop/Prathisha/Master_Thesis/Experiments/plots/1/")
df1 = dataframe[(dataframe['Grid Size'] == "(10, 10)") & (dataframe['Agent'] == "bottom_agent")]
x = df1['Number of Colors']
y = df1['Mean non-deterministic score after first move']
plt.xlabel('Number of Colors')
plt.ylabel('Mean non-deterministic score')
plt.plot(x, y)
plt.title("10X10 Grid")
plt.show()
df = pd.read_csv("exp_mean_median_results.csv")
max_colors = df['Number of Colors'].unique().tolist()
grid_sizes = df['Grid Size'].unique().tolist()
agents = ["top_agent", "bottom_agent"]
for grid_size in grid_sizes:
labels = []
(row, col) = grid_size.split(',')[0].replace("(", ""), grid_size.split(",")[1].replace(" ", "").replace(")", "")
for agent in agents:
# grid_size = '(' + size + ')'
# for max_color in max_colors:
df1 = df[(df['Grid Size'] == grid_size) & (df['Agent'] == agent)]
if grid_size == '(5, 5)':
df1 = df[(df['Grid Size'] == grid_size) & (df['Agent'] == agent) & (df['Number of Colors'] >= 5) & (df['Number of Colors'] <= 10)]
if grid_size == '(10, 10)':
df1 = df[(df['Grid Size'] == grid_size) & (df['Agent'] == agent) & (df['Number of Colors'] >= 10) & (df['Number of Colors'] <= 30)]
if grid_size == '(15, 15)':
df1 = df[(df['Grid Size'] == grid_size) & (df['Agent'] == agent) & (df['Number of Colors'] >= 15) & (df['Number of Colors'] <= 50)]
if grid_size == '(20, 20)':
df1 = df[(df['Grid Size'] == grid_size) & (df['Agent'] == agent) & (df['Number of Colors'] >= 25) & (df['Number of Colors'] <= 70)]
x = df1['Number of Colors']
y = df1['Mean score per Game Setting']
plt.xlabel('Number of Colors')
plt.ylabel('Score per game')
plt.plot(x, y)
labels.append(agent)
plt.legend(labels)
# filename = "%s.csv" % agent
title = "%sX%s Grid" % (row, col)
plt.title(title)
filename = "%sX%s_mean_score" % (row, col)
plt.savefig(path+filename)
plt.clf()
# plt.show()
......@@ -6,7 +6,7 @@ import pandas as pd
df = pd.read_csv('exp_results.csv')
# grid_sizes = ['(5, 5)', '(7, 7)', '(10, 10)', '(15, 15)', '(20, 20)']
# input_data = pd.read_csv('../m3/exp_game_setting.csv')
max_colors = df['Number of Colors'].unique().tolist()
max_colors = sorted(df['Number of Colors'].unique().tolist())
grid_sizes = df['Grid Size'].unique().tolist()
agents = ["top_agent", "bottom_agent", "NotApplicable"]
......@@ -24,8 +24,10 @@ for agent in agents:
data_regen_match_median = data_1['Total No. of Times Matches Occurred during init'].median()
data_regen_deadlock_mean = data_1['Total No. of Deadlocks during init'].mean()
data_regen_deadlock_median = data_1['Total No. of Deadlocks during init'].median()
data_deadlock_mean = data_1['Avg No. of Shuffles/Deadlocks Occurred per move'].mean()
data_deadlock_median = data_1['Avg No. of Shuffles/Deadlocks Occurred per move'].median()
data_deadlock_per_move_mean = data_1['Avg No. of Shuffles/Deadlocks Occurred per move'].mean()
data_deadlock_per_move_median = data_1['Avg No. of Shuffles/Deadlocks Occurred per move'].median()
data_deadlock_per_game_mean = data_1['Avg No. of Shuffles/Deadlocks Occurred per game'].mean()
data_deadlock_per_game_median = data_1['Avg No. of Shuffles/Deadlocks Occurred per game'].median()
data_score_mean = data_1['Avg score per Game Setting'].mean()
data_score_median = data_1['Avg score per Game Setting'].median()
data_valid_moves_mean = data_1['Avg Valid Moves Made'].mean()
......@@ -55,6 +57,8 @@ for agent in agents:
'Median Deadlocks during init',
'Mean Shuffles/Deadlocks Occurred per move',
'Median Shuffles/Deadlocks Occurred per move',
'Mean Shuffles/Deadlocks Occurred per game',
'Median Shuffles/Deadlocks Occurred per game',
'Mean score per Game Setting',
'Median score per Game Setting',
'Mean Valid Moves Made',
......@@ -83,8 +87,10 @@ for agent in agents:
'Median Matches Occurred during init': data_regen_match_median,
'Mean Deadlocks during init': data_regen_deadlock_mean,
'Median Deadlocks during init': data_regen_deadlock_median,
'Mean Shuffles/Deadlocks Occurred per move': data_deadlock_mean,
'Median Shuffles/Deadlocks Occurred per move': data_deadlock_median,
'Mean Shuffles/Deadlocks Occurred per move': data_deadlock_per_move_mean,
'Median Shuffles/Deadlocks Occurred per move': data_deadlock_per_move_median,
'Mean Shuffles/Deadlocks Occurred per game': data_deadlock_per_game_mean,
'Median Shuffles/Deadlocks Occurred per game': data_deadlock_per_game_median,
'Mean score per Game Setting': data_score_mean,
'Median score per Game Setting': data_score_median,
'Mean Valid Moves Made': data_valid_moves_mean,
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
# Mann-Whitney U test
import pandas as pd
from numpy.random import seed
from numpy.random import randn
from scipy.stats import mannwhitneyu, wilcoxon
# seed the random number generator
# seed(1)
# generate two independent samples
# data1 = 5 * randn(100) + 50
# data2 = 5 * randn(100) + 51
df = pd.read_csv('exp_results.csv', usecols=["Grid Size", "Number of Colors", "Agent", "Avg score per Game Setting"])
max_colors = df['Number of Colors'].unique().tolist()
grid_sizes = df['Grid Size'].unique().tolist()
agents = ["top_agent", "bottom_agent"]
for grid_size in grid_sizes:
labels = []
# grid_size = '(' + size + ')'
(row, col) = grid_size.split(',')[0].replace("(", ""), grid_size.split(",")[1].replace(" ", "").replace(")", "")
for color in max_colors:
data_1 = df[(df['Grid Size'] == grid_size) & (df['Number of Colors'] == color) & (df['Agent'] == "top_agent")]
data_2 = df[(df['Grid Size'] == grid_size) & (df['Number of Colors'] == color) & (df['Agent'] == "bottom_agent")]
if not data_1.empty and not data_2.empty:
data1 = data_1['Avg score per Game Setting'].copy()
data2 = data_2['Avg score per Game Setting'].copy()
# -----------------------Mann-Whitney U Test-------------------
# compare samples
stat, p = mannwhitneyu(data1, data2)
print('Statistics=%.3f, p=%.3f' % (stat, p))
# interpret
alpha = 0.05
if p > alpha:
print(f'Same distribution (fail to reject H0) for {grid_size} and {color}')
else:
print(f'Different distribution (reject H0) for {grid_size} and {color}')
grid_size,color_end
"5, 5",4
"5, 5",5
"5, 5",10
"5, 5",15
"5, 5",20
"5, 5",25
"5, 5",30
"10, 10",5
"10, 10",10
"10, 10",15
"10, 10",20
"10, 10",25
"10, 10",30
"10, 10",35
"10, 10",40
"10, 10",45
"10, 10",50
"10, 10",60
"10, 10",70
"10, 10",80
"10, 10",90
"10, 10",100
"15, 15",5
"15, 15",10
"15, 15",15
"15, 15",20
"15, 15",25
"15, 15",30
"15, 15",35
"15, 15",40
"15, 15",45
"15, 15",50
"15, 15",100
"15, 15",150
"15, 15",200
"15, 15",225
"20, 20",5
"20, 20",10
"20, 20",15
"20, 20",20
"20, 20",25
"20, 20",30
"20, 20",35
"20, 20",40
"20, 20",45
"20, 20",50
"20, 20",100
"20, 20",150
"20, 20",200
"20, 20",250
"20, 20",300
"20, 20",350
"20, 20",400
\ No newline at end of file
Agent,Grid Size,Number of Colors,Total No. of Regenerations until valid board generation,Total No. of Times Matches Occurred during init,Total No. of Deadlocks during init,Total No. of Shuffles/Deadlocks Occurred,Total score per Game Setting,Total Valid Moves Made,Total No. of Possible/Playable Moves,Total No. of Avalanche Matches,Total Moves Available per Game Setting,Total deterministic score after first move,Total non-deterministic score after first move,Total avalanche count after first move,Init Time,Move Time
NotApplicable,"(10, 10)",4,1000,1000,0,0,0,0,0,0,10,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
NotApplicable,"(10, 10)",4,100,100,0,0,0,0,0,0,3,0,0,0,0,0
human,"(5, 5)",4,0,0,0,0,27,3,26,4,3,5,19,4,0,0
top_agent,"(5, 5)",4,6,5,1,0,9,3,18,0,3,3,0,0,0,0
human,"(5, 5)",4,0,0,0,0,57,3,25,8,3,3,13,3,0,0
random_agent,"(5, 5)",4,0,0,0,0,18,3,23,2,3,3,0,0,0,0
NUM_OF_DEADLOCK_RETRIES = 10
NUM_OF_MOVES_PER_GAME = 10
EXP_SAME_BOARD_REPEAT = 2
EXP_DIFF_BOARD_REPEAT = 3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment