Giter Site home page Giter Site logo

coin_toss's Introduction

coin_toss

#ToDo

Add project to Github - done Install Composer - done Install PHPSpec - done

Set up Coin Toss program

  • Coin Toss is a Competion

    • Competition has 6 rounds of matches, each round needs to have as many matches scheduled as possible
    • Each Match is contested by two players
    • Each player is assigned heads or tails

    Restrictions

    • Each player can only play one match per round done
    • No matched pair can be from the same team done
    • No matched pair can be a repeat of the previous round's fixture
    • The process for creating matches should be random done
    • It should be possible for any two player in different teams to have the possibility of being paired
  • Coin Toss has 51 players [player1, player2, player3...] done

  • Each player belongs to a team done

    • There are 8 teams done
    • Each team has a color [Red, yellow, Green, Blue, Orange, Pink, Black and White] done

Have to use a recursuve function to check whether matches can be player

  • Maybe Factory model will be better, we can create Competition and play matches using a new object

  • Main issue was the check to see if two player have already played, this wast causing error with the function recursion

I ran into problems trying to make sure that each match was contested by different teams who havent previously played. I had to create two arrays one to hold the previously played games from the last round and another to hold each player who has played already. This caused some more issues and I refactored the way in whcih each game was generated.

I changed from using rand() to array_rand(), this allowed me to create an array of 51 players. When a game was being set the methid would take a random plater number from the draw. After they have been drawn the player numbers would be unset to stop them being drawn again in the round.

To fix the error with multiple nesting of functions I moved some of the methods into a match Class, the CoinToss Class is then used to create new matches.

Still to do

  • Allow for more that 51 players without getting nesting errors.
  • Allow for matches with more that 2 players to be displayed
  • Refactor code to remove duplication
  • Add more tests, this is still incomplete

The play_match method needs re-writing, it needs to allow for more than one competitor. This could be done by create an Array of competitors using the array_rand() The passing the array into play_match()

  • Was also looking at outputting the results and previous round as a JSON file, this would allow for the file to be checked before a next round is played. We could also use the PHP standard libray and write a query.

coin_toss's People

Contributors

howardpanton avatar

Watchers

 avatar

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.