I have done the code the "wrapping of the matrix" via concatenation so I can count all the neighbours.
I know the logical steps for the function score and advance but I am not sure how to write them
S= Score (A:matrix, b:payoff)
Ae= Embed(A)
For k= left to right
For h= top to bottom
Get neighbors of A(h,k) --> not sure how to count all the neighbours and itself
Add up cooperators --> not sure either
If A=0
Multiply by b
End
S(h,k) = score
Advance (A, S)
Se=embed(S)
Ae=embed(A)
for each element of the matrix
Find highest score neighbor take location from S . How do I take the location for the neighbour of each element? find strategy from A end.