Code Monkey home page Code Monkey logo

guandan-ai's Introduction

掼蛋-AI

本项目是一个基于启发式规则的掼蛋AI。采用C/S架构。

客户端

/client目录下是客户端代码,里面包含了五种客户端:

  • BaseClient:其它四个客户端的基类客户端。
  • RandomClient:随机出牌的客户端。
  • MinClient: 出当前可出的最小牌的客户端。
  • HumanClient:从命令行读取人类输入出牌的客户端。
  • AIClient:基于启发式规则的AI客户端。

BaseClient

BaseClient是其它四个客户端的基类客户端。它的作用是

  • 报文处理:读取、解析、回应服务端的通讯报文。
  • 记忆:记录当前已经出的牌、记录当前牌桌上的牌。
  • 事件派发:在合适的时机调用三个分别定义为my_playothers_playfinish的事件接口, 交由继承BaseClient的客户端处理。子类客户端至少需要实现my_play方法。

服务端

服务端见另一个项目。

使用方法

首先启动服务端,然后从命令行使用下面的指令启动客户端:

python gd.py [-h] [-s {ai,random,min,human}] [-a ADDR] [-p PORT] [-t] [-v] name

positional arguments:
  name                  set the client's name

optional arguments:
  -h, --help            show this help message and exit
  -s {ai,random,min,human}, --strategy {ai,random,min,human}
                        choose the strategy
  -a ADDR, --addr ADDR  set server's ip address
  -p PORT, --port PORT  set server's port
  -t, --time            measure the time consumed by method call
  -v, --verbose         show more infomation

guandan-ai's People

Contributors

qinlinchen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.