
%Initial paramaters of the game are the board, and the number of moves
%These are constant
board = [0,1,0,0,1,1,0,10,1,0,0];
nummoves = 25;

%These parameters are updated after each move.
position = 1;
positionhistory(1) = 1;
totalrewards = board(position);

%The initial probablity of going right
p = 1/2;

for i=1:nummoves
    
    expectedRightReward = 
    
    %Decide whether to move left or right
    %Keep track of decisions for future reference
    decisionhistory(i) = cointoss(p);
    if decisionhistory(i)==1
        position = min([length(board),position+1]);%can't move off board
    else
        position = max([1,position-1]); %can't move off left side of board
    end
    
    %Keep track of all the moves made, for reference
    positionhistory(i+1) = position;
    
    %Update the reward accordingly
    totalrewards = totalrewards + board(position);

end
     
