carykh / PrisonersDilemmaTournament

Watch This Place's awesome video about iterated Prisoner's Dilemma for context! https://www.youtube.com/watch?v=BOvAbjfJ0x0
MIT License
205 stars 160 forks source link

about the "history" parameter for "strategy" #25

Closed AggamR closed 3 years ago

AggamR commented 3 years ago

Is it supposed to be a list? a numpy array?

Also, sorry for the stupid question, just never worked with NP, and it's not clear to me.

Niels-van-den-Hork commented 3 years ago

Its a numpy array, you can use

def strategy(history, memory):
    round_nr = history.shape[1]
    my_hist = list(history[0])
    opp_hist = list(history[1])

to transform it to lists

peterHoburg commented 3 years ago

History is a 2d NP array. So

a = [
    [1,0,1,0...],
    [0,0,0,0...]
]

You can access it just like a normal python list

a[0][0] == 1
AggamR commented 3 years ago

History is a 2d NP array. So

a = [
    [1,0,1,0...],
    [0,0,0,0...]
]

You can access it just like a normal python list

a[0][0] == 1

oh so a[0] is my actions and a[1] is the opponent's actions? or vise versa? or not that at all? also, do I need to turn it into a python list first, like @peterHoburg mentioned? or can I just do that on the array?

WalterCM commented 3 years ago

History is a 2d NP array. So

a = [
    [1,0,1,0...],
    [0,0,0,0...]
]

You can access it just like a normal python list

a[0][0] == 1

oh so a[0] is my actions and a[1] is the opponent's actions? or vise versa? or not that at all? also, do I need to turn it into a python list first, like @peterHoburg mentioned? or can I just do that on the array?

I guess you can do whatever you want. @peterHoburg was just giving you a suggestion if you didn't want to work with np arrays.

AggamR commented 3 years ago

History is a 2d NP array. So

a = [
    [1,0,1,0...],
    [0,0,0,0...]
]

You can access it just like a normal python list

a[0][0] == 1

oh so a[0] is my actions and a[1] is the opponent's actions? or vise versa? or not that at all? also, do I need to turn it into a python list first, like @peterHoburg mentioned? or can I just do that on the array?

I guess you can do whatever you want. @peterHoburg was just giving you a suggestion if you didn't want to work with np arrays.

oh ok, but I still have a question:

so a[0] is my actions and a[1] is the opponent's actions? or vise versa? or not that at all?

peterHoburg commented 3 years ago

History is a 2d NP array. So

a = [
    [1,0,1,0...],
    [0,0,0,0...]
]

You can access it just like a normal python list

a[0][0] == 1

oh so a[0] is my actions and a[1] is the opponent's actions? or vise versa? or not that at all? also, do I need to turn it into a python list first, like @peterHoburg mentioned? or can I just do that on the array?

I guess you can do whatever you want. @peterHoburg was just giving you a suggestion if you didn't want to work with np arrays.

oh ok, but I still have a question:

so a[0] is my actions and a[1] is the opponent's actions? or vise versa? or not that at all?

a[0] are your actions.

Bip901 commented 3 years ago

Possible duplicate of #22

carykh commented 3 years ago

@Niels-van-den-Hork and @peterHoburg are correct! It's a 2D numpy array where the first axis is which player it is (0th row is your history, 1st row is your opponent's history) and the second axis is what turn it is