function json = scoreButton(color, click)
%SCOREBUTTON updates the button score
%   Keeps track of expected rewards (clicks) for the buttons
%   and return JSON object for plotting with Google Charts

c = {'Blue','Orange','Yellow'};         % button colors
filename = 'C:\Work\Bandit\myobj.mat';  % file path
if exist(filename,'file') == 2          % if file exists
    load(filename);                     % load banditTester from it
else                                    % if not
    banditTester = eGreedy(length(c));  % create a new object
end

banditTester.update(color, click);      % update scores

% format data for Google Charts
n = size(banditTester.scores, 1);       % number of rows
idx = 0:(n - 1);                        % row indices
idx = cellstr(num2str(idx'));           % convert cellstr
scores = num2cell(banditTester.scores); % scores
scores = [idx scores];                  % indices + scores
arr = cell(n + 1,1);                    % preallocation
arr{1} = [{'Trials'} c];                % add column labels
for ii = 1:n                            % loop over scores
    arr{ii + 1} = scores(ii,:);         % separate each row
end   

ser = serializable();                   % initialize serializable
ser.addprop('array');                   % add array property
ser.array = arr;                        % add the array
json = ser.toJSON();                    % convert to JSON

save(filename,'banditTester')           % save the object
end

