Giter Site home page Giter Site logo

uno's Introduction

Uno

Some unit tested Python code to model the card game Uno

Rules

https://en.wikipedia.org/wiki/Uno_(card_game)#Official_rules

Usage

An example auto-generated game of 5 players:

from uno import UnoGame, COLORS
import random

game = UnoGame(5)

while game.is_active:
    player = game.current_player
    player_id = player.player_id
    if player.can_play(game.current_card):
        for i, card in enumerate(player.hand):
            if game.current_card.playable(card):
                if card.color == 'black':
                    new_color = random.choice(COLORS)
                else:
                    new_color = None
                print("Player {} played {}".format(player, card))
                game.play(player=player_id, card=i, new_color=new_color)
                break
    else:
        print("Player {} picked up".format(player))
        game.play(player=player_id, card=None)

See random_game.py

AI

A simple interactive AI version of the game can be played using keyboard inputs. Just create an instance of AIUnoGame with the required number of players:

from uno import AIUnoGame

game = AIUnoGame(5)

You will be assigned a player number at random, and will be asked to make your move when it is your turn. Enter card numbers as a zero-based index, and colours as lowercase strings. (I'll tidy that up later)

Graphical game

A graphical version of the game can be played, developed using pygame-zero.

Install pygame zero with:

sudo pip3 install pgzero

And run the game with:

pgzrun uno_pgz.py

uno's People

Contributors

bennuttall avatar

Stargazers

 avatar  avatar Mustafa Tufan avatar Jaime Jesús Delgado Meraz avatar  avatar  avatar  avatar LiuRi Zhang avatar  avatar Joe Accardi avatar  avatar Seyed Hosein Mousavi Fard avatar  avatar  avatar Silas(YY) avatar Marco avatar Jumbo avatar justin avatar ob1 wan  avatar Fan Ni avatar Guilherme avatar Ahmed avatar Lucas Fellipe Mondini Pereira avatar Marcus Hughes avatar  avatar xd3262nd avatar JCP_13 avatar Rishab Kharidhi avatar  avatar  avatar Tom Hartley avatar  avatar Eunchong C. Kim avatar Satrajit Basu avatar Adithya Vasisth avatar kuator avatar Cody Gagnon avatar Igor Matheus S. Moreira avatar Brent Palmer avatar danricho avatar Sidharth Shah avatar Jeremy Bae avatar Søren Magnusson avatar Elsie.Zhang avatar Jonathan Egol avatar

Watchers

Tom Hartley avatar James Cloos avatar danricho avatar Søren Magnusson avatar  avatar  avatar Maciej Zębala avatar

uno's Issues

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.