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

Updated match 3 code. New experiment results and analysis.

parent 1ba7b197
import pandas as pd
import matplotlib.pyplot as plt
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()
\ No newline at end of file
import pandas as pd
import matplotlib.pyplot as plt
dataframe = pd.read_csv("exp_mean_median_results.csv")
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()
import csv
import os
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()
grid_sizes = df['Grid Size'].unique().tolist()
agents = ["top_agent", "bottom_agent", "NotApplicable"]
for agent in agents:
# data = pd.DataFrame()
for grid_size in grid_sizes:
# grid_size = '(' + size + ')'
for max_color in max_colors:
data_1 = df[(df['Grid Size'] == grid_size) & (df['Number of Colors'] == max_color) & (df['Agent'] == agent)]
# data.append(data_1)
if not data_1.empty:
data_regen_mean = data_1['Total No. of Regenerations until valid board generation'].mean()
data_regen_median = data_1['Total No. of Regenerations until valid board generation'].median()
data_regen_match_mean = data_1['Total No. of Times Matches Occurred during init'].mean()
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_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()
data_valid_moves_median = data_1['Avg Valid Moves Made'].median()
data_possible_moves_mean = data_1['Avg No. of Possible/Playable Moves per config'].mean()
data_possible_moves_median = data_1['Avg No. of Possible/Playable Moves per config'].median()
data_avalanche_mean = data_1['Avg No. of Avalanche Matches per move'].mean()
data_avalanche_median = data_1['Avg No. of Avalanche Matches per move'].median()
data_det_score_mean = data_1['Avg deterministic score after first move'].mean()
data_det_score_median = data_1['Avg deterministic score after first move'].median()
data_nondet_score_mean = data_1['Avg non-deterministic score after first move'].mean()
data_nondet_score_median = data_1['Avg non-deterministic score after first move'].median()
# print(data_regen_mean)
# filename = "%s.csv" % agent
# data_regen_mean.to_csv(filename, index=False)
file_exists = os.path.isfile("exp_mean_median_results.csv")
with open('exp_mean_median_results.csv', 'a+', newline='') as csv_file:
fieldnames = ['Agent',
'Grid Size',
'Number of Colors',
'Mean regenerations during init',
'Median regenerations during init',
'Mean Matches Occurred during init',
'Median Matches Occurred during init',
'Mean Deadlocks during init',
'Median Deadlocks during init',
'Mean Shuffles/Deadlocks Occurred per move',
'Median Shuffles/Deadlocks Occurred per move',
'Mean score per Game Setting',
'Median score per Game Setting',
'Mean Valid Moves Made',
'Median Valid Moves Made',
'Mean Possible/Playable Moves per config',
'Median Possible/Playable Moves per config',
'Mean Avalanche Matches per move',
'Median Avalanche Matches per move',
'Mean deterministic score after first move',
'Median deterministic score after first move',
'Mean non-deterministic score after first move',
'Median non-deterministic score after first move']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
if not file_exists:
print("File does not exist")
writer.writeheader()
writer.writerow({
'Agent': agent,
'Grid Size': grid_size,
'Number of Colors': max_color,
'Mean regenerations during init': data_regen_mean,
'Median regenerations during init': data_regen_median,
'Mean Matches Occurred during init': data_regen_match_mean,
'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 score per Game Setting': data_score_mean,
'Median score per Game Setting': data_score_median,
'Mean Valid Moves Made': data_valid_moves_mean,
'Median Valid Moves Made': data_valid_moves_median,
'Mean Possible/Playable Moves per config': data_possible_moves_mean,
'Median Possible/Playable Moves per config': data_possible_moves_median,
'Mean Avalanche Matches per move': data_avalanche_mean,
'Median Avalanche Matches per move': data_avalanche_median,
'Mean deterministic score after first move': data_det_score_mean,
'Median deterministic score after first move': data_det_score_median,
'Mean non-deterministic score after first move': data_nondet_score_mean,
'Median non-deterministic score after first move': data_nondet_score_median
})
# print(data_1)
Agent,Grid Size,Number of Colors,Mean regenerations during init,Median regenerations during init,Mean Matches Occurred during init,Median Matches Occurred during init,Mean Deadlocks during init,Median Deadlocks during init,Mean Shuffles/Deadlocks Occurred per move,Median Shuffles/Deadlocks Occurred per move,Mean score per Game Setting,Median score per Game Setting,Mean Valid Moves Made,Median Valid Moves Made,Mean Possible/Playable Moves per config,Median Possible/Playable Moves per config,Mean Avalanche Matches per move,Median Avalanche Matches per move,Mean deterministic score after first move,Median deterministic score after first move,Mean non-deterministic score after first move,Median non-deterministic score after first move
top_agent,"(5, 5)",4,5.4,3.5,4.53,2.5,0.87,1.0,0.00040999999999999994,0.0,59.82639999999999,59.93,10.0,10.0,7.3374,7.333,0.6896800000000001,0.6930000000000001,3.31,3.0,2.4632,1.88
top_agent,"(5, 5)",5,2.2,1.0,1.545,0.0,0.655,1.0,0.014910000000000001,0.012,47.4107,47.129999999999995,10.0,10.0,4.94381,4.879,0.43915000000000004,0.43899999999999995,3.165,3.0,1.7362,1.21
top_agent,"(5, 5)",10,0.715,0.0,0.15,0.0,0.565,0.0,0.5666899999999999,0.573,33.3846,33.29,10.0,10.0,4.85002,4.835,0.15612,0.156,3.025,3.0,0.3186,0.12
top_agent,"(5, 5)",15,1.335,1.0,0.16,0.0,1.175,1.0,2.19311577306,2.1109999999999998,31.199700000000004,31.18,9.9444,10.0,5.151668507365,5.197609658,0.119410117155,0.1189520965,3.01,3.0,0.10640000000000001,0.06
top_agent,"(5, 5)",20,2.26,1.0,0.17,0.0,2.09,1.0,10.080288433855001,9.035660640500002,25.100299999999997,26.04,8.1677,8.53,4.92006451641,4.9121717865,0.102243071935,0.1008493525,3.02,3.0,0.07970000000000001,0.0
top_agent,"(5, 5)",25,4.295,3.0,0.2,0.0,4.095,3.0,24.034281275949997,21.14892337,16.1006,16.630000000000003,5.2737,5.470000000000001,4.306530922505,4.3958384635000005,0.09303316872,0.092744384,3.02,3.0,0.0733,0.0
top_agent,"(10, 10)",10,3.52,2.0,2.68,1.0,0.84,1.0,0.0137,0.002,35.9927,35.58,10.0,10.0,8.13167,7.4670000000000005,0.16457999999999998,0.153,3.055,3.0,0.3949,0.15000000000000002
top_agent,"(10, 10)",15,0.97,0.5,0.46,0.0,0.51,0.5,0.14566,0.151,32.858599999999996,32.7,10.0,10.0,14.559090000000001,14.773,0.11871999999999999,0.11800000000000001,3.02,3.0,0.1607,0.06
top_agent,"(10, 10)",20,0.65,0.0,0.2,0.0,0.45,0.0,0.33287999999999995,0.34299999999999997,31.871,31.68,10.0,10.0,18.59231,19.092,0.11428,0.11199999999999999,3.035,3.0,0.1234,0.0
top_agent,"(10, 10)",25,0.6,0.0,0.145,0.0,0.455,0.0,0.55149,0.5569999999999999,31.176799999999993,31.1,10.0,10.0,20.36914,20.64,0.11009000000000001,0.11199999999999999,3.015,3.0,0.0421,0.0
top_agent,"(10, 10)",30,0.835,0.0,0.135,0.0,0.7,0.0,0.85375,0.867,30.8409,30.8,10.0,10.0,20.59971,20.692,0.10346,0.10400000000000001,3.005,3.0,0.04630000000000001,0.0
top_agent,"(10, 10)",35,1.185,1.0,0.175,0.0,1.01,1.0,1.21824,1.214,30.5896,30.58,10.0,10.0,21.55326,21.454,0.10305,0.102,3.0,3.0,0.022199999999999998,0.0
top_agent,"(10, 10)",40,1.345,1.0,0.17,0.0,1.175,1.0,1.62053,1.6019999999999999,30.485300000000002,30.44,10.0,10.0,22.128809999999998,22.232,0.10411000000000001,0.10400000000000001,3.01,3.0,0.028200000000000003,0.0
top_agent,"(10, 10)",45,1.955,1.0,0.17,0.0,1.785,1.0,2.15155,2.1399999999999997,30.396,30.34,10.0,10.0,22.139789999999998,21.917,0.10212,0.1,3.0,3.0,0.0446,0.0
top_agent,"(10, 10)",50,2.3,2.0,0.14,0.0,2.16,2.0,2.8157300000000003,2.786,30.331300000000002,30.3,10.0,10.0,22.237640000000003,22.152,0.10131,0.1,3.025,3.0,0.023900000000000005,0.0
top_agent,"(10, 10)",60,3.475,2.0,0.155,0.0,3.32,2.0,4.119870000000001,4.041,30.2005,30.18,10.0,10.0,22.393330000000002,22.159,0.09977,0.1,3.0,3.0,0.006299999999999999,0.0
top_agent,"(10, 10)",70,4.695,3.0,0.16,0.0,4.535,3.0,6.36063282856,6.039,30.1446,30.14,9.999,10.0,22.071811896499998,22.094,0.09742910272500001,0.098,3.0,3.0,0.0060999999999999995,0.0
top_agent,"(10, 10)",80,5.7,4.0,0.15,0.0,5.55,4.0,8.93427956779,8.421,30.0455,30.08,9.979800000000001,10.0,21.8820624637,21.728,0.09624901750999999,0.098,3.0,3.0,0.0042,0.0
top_agent,"(10, 10)",90,7.52,5.0,0.185,0.0,7.335,5.0,13.30970820305,12.41902834,29.619699999999998,29.94,9.8466,9.96,22.07004915585,21.75032998,0.097370309105,0.096,3.0,3.0,0.0024,0.0
top_agent,"(10, 10)",100,10.215,7.0,0.095,0.0,10.12,7.0,17.4044930366,16.641683774999997,28.845399999999998,29.42,9.586500000000001,9.78,22.0248138571,21.835295020000004,0.09821324059,0.09793617,3.005,3.0,0.0189,0.0
bottom_agent,"(5, 5)",4,5.4,3.5,4.53,2.5,0.87,1.0,0.00068,0.0,70.14219999999999,69.65,10.0,10.0,7.28091,7.252,0.9085,0.902,3.335,3.0,3.8194999999999997,2.78
bottom_agent,"(5, 5)",5,2.2,1.0,1.545,0.0,0.655,1.0,0.018070000000000003,0.016,49.926899999999996,49.62,10.0,10.0,4.892869999999999,4.882,0.49999000000000005,0.491,3.17,3.0,1.9150999999999998,1.15
bottom_agent,"(5, 5)",10,0.715,0.0,0.15,0.0,0.565,0.0,0.58869,0.59,33.501599999999996,33.33,10.0,10.0,4.965120000000001,4.9190000000000005,0.1618,0.162,3.035,3.0,0.27380000000000004,0.12
bottom_agent,"(5, 5)",15,1.335,1.0,0.16,0.0,1.175,1.0,2.1872689697800003,2.1260000000000003,31.2579,31.24,9.9498,10.0,5.170740688735,5.189942385,0.12123665344500001,0.12,3.01,3.0,0.1612,0.06
bottom_agent,"(5, 5)",20,2.26,1.0,0.17,0.0,2.09,1.0,9.890201099759999,8.821901431499999,25.2477,26.16,8.1928,8.5,4.992064484025,4.998411276500001,0.10704833540999999,0.105552825,3.02,3.0,0.12179999999999999,0.0
bottom_agent,"(5, 5)",25,4.295,3.0,0.2,0.0,4.095,3.0,23.871410310749997,21.161275359999998,16.2228,16.62,5.3206999999999995,5.48,4.236662411825,4.381730769000001,0.08779108236,0.088210798,3.02,3.0,0.05600000000000001,0.0
bottom_agent,"(10, 10)",10,3.52,2.0,2.68,1.0,0.84,1.0,0.026330000000000006,0.015,37.7994,37.33,10.0,10.0,9.22776,8.411,0.21796999999999997,0.20900000000000002,3.07,3.0,0.8808,0.24
bottom_agent,"(10, 10)",15,0.97,0.5,0.46,0.0,0.51,0.5,0.17128,0.17099999999999999,33.7046,33.19,10.0,10.0,16.59946,16.479,0.14864,0.136,3.04,3.0,0.326,0.06
bottom_agent,"(10, 10)",20,0.65,0.0,0.2,0.0,0.45,0.0,0.36002,0.367,32.263000000000005,32.06,10.0,10.0,20.03181,20.317,0.13188,0.128,3.03,3.0,0.1925,0.0
bottom_agent,"(10, 10)",25,0.6,0.0,0.145,0.0,0.455,0.0,0.5722400000000001,0.577,31.391399999999997,31.32,10.0,10.0,21.014470000000003,20.939999999999998,0.11720000000000003,0.11800000000000001,3.01,3.0,0.0685,0.0
bottom_agent,"(10, 10)",30,0.835,0.0,0.135,0.0,0.7,0.0,0.88574,0.879,30.969499999999996,30.89,10.0,10.0,21.65275,21.534,0.11081000000000002,0.11,3.005,3.0,0.0434,0.0
bottom_agent,"(10, 10)",35,1.185,1.0,0.175,0.0,1.01,1.0,1.24943,1.2429999999999999,30.6575,30.62,10.0,10.0,22.406729999999996,22.792,0.10989000000000003,0.11,3.0,3.0,0.020599999999999997,0.0
bottom_agent,"(10, 10)",40,1.345,1.0,0.17,0.0,1.175,1.0,1.65709,1.645,30.5898,30.52,10.0,10.0,22.603559999999998,22.513999999999996,0.10880000000000001,0.10700000000000001,3.01,3.0,0.0599,0.0
bottom_agent,"(10, 10)",45,1.955,1.0,0.17,0.0,1.785,1.0,2.17068,2.167,30.412200000000002,30.4,10.0,10.0,22.475160000000002,22.53,0.10511000000000001,0.10400000000000001,3.0,3.0,0.026400000000000007,0.0
bottom_agent,"(10, 10)",50,2.3,2.0,0.14,0.0,2.16,2.0,2.8165999999999998,2.772,30.3472,30.32,10.0,10.0,22.33034,22.42,0.10285,0.102,3.015,3.0,0.024700000000000003,0.0
bottom_agent,"(10, 10)",60,3.475,2.0,0.155,0.0,3.32,2.0,4.1687199999999995,4.136,30.2515,30.22,10.0,10.0,22.465500000000002,22.469,0.10214000000000001,0.102,3.0,3.0,0.023399999999999997,0.0
bottom_agent,"(10, 10)",70,4.695,3.0,0.16,0.0,4.535,3.0,6.32807374805,6.087,30.152600000000003,30.14,9.9981,10.0,22.1592938181,22.118000000000002,0.09910814023,0.098,3.0,3.0,0.0048,0.0
bottom_agent,"(10, 10)",80,5.7,4.0,0.15,0.0,5.55,4.0,8.89978222016,8.533999999999999,30.0492,30.09,9.9776,10.0,21.97325094455,21.902686515,0.09733965996,0.09609619250000001,3.0,3.0,0.0045,0.0
bottom_agent,"(10, 10)",90,7.52,5.0,0.185,0.0,7.335,5.0,13.402000488485001,12.744423935,29.554699999999997,29.9,9.8218,9.95,21.987619287450002,22.016,0.09699062718500001,0.09746202949999999,3.0,3.0,0.0027,0.0
bottom_agent,"(10, 10)",100,10.215,7.0,0.095,0.0,10.12,7.0,17.52157143825,16.611316430000002,28.8996,29.54,9.6043,9.83,21.7458164525,21.701874715000002,0.096045689385,0.0961557375,3.005,3.0,0.0165,0.0
NotApplicable,"(10, 10)",5,100.0,100.0,100.0,100.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
This diff is collapsed.
......@@ -97,4 +97,4 @@ Grid Size,Max Colors,Actual Colors,Total No. of Regenerations until valid board
"(20, 20)",350,231,232,23.2,2,0.2,230,23,10,1,0.041322314,56508,5650.8,565.08,0.017696609,1000,100,1000,100,97956,9795.6,127,12.7,100,10
"(20, 20)",370,244,164,16.4,0,0,164,16.4,10,1,0.057471264,77187,7718.7,771.87,0.01295555,1002,100.2,1000,100,91939,9193.9,113,11.3,100,10
"(20, 20)",390,252,341,34.1,0,0,341,34.1,10,1,0.028490028,104763,10476.3,1094.702194,0.009134904,957,95.7,957,95.7,80608,8060.8,103,10.3,100,10
"(20, 20)",410,260,291,29.1,3,0.3,288,28.8,10,1,0.033222591,100065,10006.5,1103.252481,0.009064108,908,90.8,907,90.7,94133,9413.3,113,11.3,100,10
\ No newline at end of file
"(20, 20)",410,260,291,29.1,3,0.3,288,28.8,10,1,0.033222591,100065,10006.5,1103.252481,0.009064108,908,90.8,907,90.7,94133,9413.3,113,11.3,100,10
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