Giter Site home page Giter Site logo

Comments (10)

Errorcrafter avatar Errorcrafter commented on June 20, 2024
game_ln = history.shape[1]
recent_moves = history[1,(game_ln-2):game_ln]
``` this gives you an array, idk much other than that

from prisonersdilemmatournament.

Bip901 avatar Bip901 commented on June 20, 2024

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.

from prisonersdilemmatournament.

nobody5050 avatar nobody5050 commented on June 20, 2024

Sweet, thanks!

from prisonersdilemmatournament.

Bip901 avatar Bip901 commented on June 20, 2024

Sure thing.
You may close this issue if it was resolved.

from prisonersdilemmatournament.

nobody5050 avatar nobody5050 commented on June 20, 2024

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?

from prisonersdilemmatournament.

LaTrissTitude avatar LaTrissTitude commented on June 20, 2024

you can also use negative indexing:
history[1,(game_ln-2):game_ln] == history[1,-2:]

from prisonersdilemmatournament.

LaTrissTitude avatar LaTrissTitude commented on June 20, 2024

the history only includes previous turns

from prisonersdilemmatournament.

nobody5050 avatar nobody5050 commented on June 20, 2024

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?

from prisonersdilemmatournament.

LaTrissTitude avatar LaTrissTitude commented on June 20, 2024

yep

from prisonersdilemmatournament.

nobody5050 avatar nobody5050 commented on June 20, 2024

Alright, cool

from prisonersdilemmatournament.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.