Giter Club home page Giter Club logo

pypokergui's Introduction

PyPokerGUI

Build Status PyPI MIT License

GUI application for PyPokerEngine.
You can play poker with your AI bia browser.

app_demo

This library assumes that your AI is implemented in PyPokerEngine format.
If you have not checked our PyPokerEngine, we recommend you to check it first.

Tutorial

In this tutorial, we will play poker with simple AI "FishPlayer".
("FishPlayer" is an AI always declares CALL action. )

The outline of this tutorial is following.

  1. Create script to setup our AI
  2. Setup config file which defines rule of the game
  3. Start the server with config file and play the game

Installation

Please install this library with pip.

pip install pypokergui

Create script to setup our AI

First, we will create a script which defines how to setup our AI.
What you need to do is implementing setup_ai method.
PyPokerGUI uses this method to setup your AI.

from pypokerengine.players import BasePokerPlayer

class FishPlayer(BasePokerPlayer):  # Do not forget to make parent class as "BasePokerPlayer"

    #  we define the logic to make an action through this method. (so this method would be the core of your AI)
    def declare_action(self, valid_actions, hole_card, round_state):
        # valid_actions format => [raise_action_info, call_action_info, fold_action_info]
        call_action_info = valid_actions[1]
        action, amount = call_action_info["action"], call_action_info["amount"]
        return action, amount   # action returned here is sent to the poker engine

    def receive_game_start_message(self, game_info):
        pass

    def receive_round_start_message(self, round_count, hole_card, seats):
        pass

    def receive_street_start_message(self, street, round_state):
        pass

    def receive_game_update_message(self, action, round_state):
        pass

    def receive_round_result_message(self, winners, hand_info, round_state):
        pass


def setup_ai():
    return FishPlayer()

We assume that you put this script on /Users/ishikota/poker/fish_player_setup.py in following section.

Setup config file which defines rule of the game

Next we will define the rule of the game.
We need to define following settings in yaml format.

  • max_round : how many round we will play
  • initial stack : start stack size of each player
  • small blind : the amount of small blind
  • ante : the amount of ante
  • ai_players : path to your AI-setup script

You can generate template of config file like this.

pypokergui build_config --maxround 10 --stack 100 --small_blind 10 --ante 0 >> poker_conf.yaml

Then your poker_conf.yaml would be ...

ante: 0
blind_structure: null
initial_stack: 100
max_round: 10
small_blind: 10
ai_players:
- name: FIXME:your-ai-name
  path: FIXME:your-setup-script-path

We replace ai_players items like this.

ante: 0
blind_structure: null
initial_stack: 100
max_round: 10
small_blind: 10
ai_players:
- name: fish_player_1
  path: /Users/ishikota/poker/fish_player_setup.py
- name: fish_player_2
  path: /Users/ishikota/poker/fish_player_setup.py

We assume that you put this file on /Users/ishikota/poker/poker_conf.yaml in following section.

Start the server with config file and play the game

Ok, everything is ready. We start the local server with our config file.

pypokergui serve /Users/ishikota/poker/poker_conf.yaml --port 8000 --speed moderate

Then browser will be opened and you would see registration page.
Please register yourself in the page and start the game. Enjoy poker!!

How to registrate yourself

How to declare action in the game

pypokergui's People

Contributors

ishikota avatar chrisking avatar gabrielggg 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.