Giter Site home page Giter Site logo

war_game's Introduction

Problem statement #24

Use the Standard deck to create a simplified version of the game War. In this game, there are two players. Each starts with half of a deck. The players each deal the top card from their decks and whoever has the higher card wins the other player’s cards and adds them to the bottom of his deck. If there is a tie, the two cards are eliminated from play (this differs from the actual game, but is simpler to program). The game ends when one player runs out of cards.

possible code improvements
  • use enum for the card varients
  • improve the typing
possible speed improvements
  • multiprocessing
    • need to use the multiprocessing library as the GIL does not allow python threads to run concurrently
    • check if this is needed
  • use deque in the simulation as inserting at index 0 is very slow
    • store the tuple in this and not the Card as described below
      • no refcounting this way ig
  • implement the deque using numpy arrays
    • only ranks matter for the game, so they should be filled with only ranks
    • but how do i collect data on freq of each rank being left at the end?
      • maybe store a tuple in it instead: (<rank>, <index in deck>)
    • why would this be faster with numpy if i use deque anyway?
  • implement this in a faster language like Rust or Cpp
    • implementing this in rust and then using matplotlib to visualise this data should be easy as PyO3 can be used to generate a python lib, when can then be used in a python environment just like regualr python functions/classes
metrics to gather info on
  • freq of turns
  • freq of the number of cards left
  • freq of each rank being left at the end
  • freq of each rank having a tie in the game
    • should be possible to just calculate the probability of this happening :/

war_game's People

Contributors

thrombe avatar

Stargazers

 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.