Closed nobody5050 closed 3 years ago
game_ln = history.shape[1]
recent_moves = history[1,(game_ln-2):game_ln]
``` this gives you an array, idk much other than that
history[1, -1]
returns what the opponent did in the last round (0 means defect, 1 means cooperate)
history[1, -2]
returns what the opponent did in the second last round
And so on.
history[1, 0]
returns what the opponent did in the first round
history[1, 1]
returns what the opponent did in the second round
And so on.
Changing the first 1 to a 0 returns what you did in those rounds instead.
Make sure to check if (history.shape[1] > 0):
[checks if there's at least one item in the history] before accessing those indices.
Sweet, thanks!
Sure thing. You may close this issue if it was resolved.
One more thing before closing it, when we get the game length, does that include the current round or does it count every round except for the one we’re currently calculating?
you can also use negative indexing:
history[1,(game_ln-2):game_ln] == history[1,-2:]
the history only includes previous turns
the history only includes previous turns
So if I’m querying the history’s length on round 50 for example, I’m going to get a length of 49?
yep
Alright, cool
I know I have to use ‘history’ but I’m unsure how to go about converting the array into something I can humanly understand.