Giter Site home page Giter Site logo

hand-simulator's Introduction

hand-simulator

Usage

hand.py contains a Hand class that accepts a filename as input, generates a deck from the given file, and generates hands from that deck. It supports several functions:

new_hand(size)

Generates a new hand of the given size, contained within the Hand object, and returns a copy. Defaults to 7.

contains(cards)

Accepts the name of a card or a list of names, returns 1 if the current hand contains any of those cards, 0 otherwise.

count_of(cards)

Accepts the name of a card or a list of names, returns the total number of those cards in the current hand.

expect(cards, size)

Accepts the name of a card or a list of names and a hand size, returns the hypergeometric expectation of those cards in a hand of the given size.

set_deck(new_deck)

Accepts a filename, a list of individual cards, or a dictionary of card names and quantities. Sets the deck and decklist to the input.

get_deck()

Returns a copy of the internal deck, a list of individual cards.

get_decklist()

Returns a copy of the internal decklist, a dictionary of card names and quantities.

has_tron()

Returns whether the current hand contains Tron, counting the first Expedition Map. Will be deprecated when I find the motivation.

Examples

grixis_mana.py, grixis_mana_full, eldrazi_tron.py, and affinity.py contain applications. They all work essentially the same way. The main thing is implementing logic to classify the kinds of hands you're looking for.

grixis_mana.py tests to see how often checklands come into play untapped with a standard Grixis energy manabase. grixis_mana_full tries to find the optimal grixis manabase given a set of parameters that characterize an utility function. eldrazi_tron.py finds how often Eldrazi Tron gets its best draws. affinity.py finds how often Affinity plays a 2- or 3-drop on turn 1.

##Tests

Execute tests with pytest in root project dir

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.