Code Monkey home page Code Monkey logo

ethereum-prisoner-s-dilemma's Introduction

eth_prisoners_dilemma

About

There is a prisoner's dilemma in game theory. I use specific implementation when there is more than one round.

Important! Sometimes bet() has revert. It's normall try another time, in future it will be solved.

Usage

To play you need a smart contract where there will be such methods

contract IGame {
    
  uint8 constant DONT_TELL_ANYTHING = 8;
  uint8 constant TELL_EVERYTHING = 10;    
  
  
  function bet(uint8 _answer) external returns (uint8 res);
  
  function seeMyScore(address _t) external view returns (uint res);
  
  function seeMyPartnerAnswer(uint id, address _t) public view returns (uint8);
  
  function seeMyQofGames(address _t) public view returns (uint);
  
  function seeMyAnswer(uint _qGame, address _t) public view returns (uint8);
  
  function seeMyAnswers(address _t) public view returns (uint8[9]);
  
  function seeMyPartners(address _t) public view returns (address[9]);
  
  function seeMyIds(address _t) public view returns (uint[9]);
  
  function seeMyId(uint _qGame, address _t) public view returns (uint);
}

Most important

 function bet(uint8 _answer) external returns (uint8 res);

Allows you to set your bet.

Only 2 variants 8 (tell police) or 10(don't tell police)

To see your final score you need to use

 function seeMyScore(address _t) external view returns (uint res);

Features

Allows to play only to smart contracts

Solve problem with timing

ethereum-prisoner-s-dilemma's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

prazd christinto

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.