Giter Site home page Giter Site logo

elephantfish's Introduction

Elephantfish

介绍

elephantfish 是受到 sunfish 启发而撰写的纯python的**象棋引擎, 整个象棋引擎核心代码只有124行(见compressed.py),棋力方面我仅进行过其与象棋小巫师傻瓜难度的一场对局,在我测试的对剧中,elephantfish赢得了比赛。

在几天前看到了sunfish这个项目(是一个国际象棋引擎,只有111行),觉得很有意思,于是做了一个类似**象棋版本,**象棋和国际象棋略有不同,我仅仅单独完成了棋规部分,子力价值表直接的参考了 象眼 ,mtd search部分的代码由于原版sunfish写的非常通用,我也就一行未改。

如果你对于程序中的mtd search看不懂建议先看一些对弈基础理论,比如articles下的几篇文章,如对弈程序基本技术,其官方网址:https://www.xqbase.com/computer/outline.htm

elephantfish默认会进行5秒钟的思考,当然实际一般会比5秒多一些,如果你想要它进行更长时间搜索以获得更好的性能可以对源码相应位置进行更改。

如同sunfish一样,我认为elephantfish会是一个很好的平台,由于其代码非常少,可以很方便的进行各种实验,希望各位感兴趣的同学可以尝试对其进行优化. 如果在优化后想要评估和目前版本的棋力差别,可以使用test.py中的self_arena来将你的代码和elephantfish进行对弈。

运行截图

Think depth: 6 My move: b9c7

  9 俥.象士将士象傌俥
  8 .........
  7 .砲傌....砲.
  6 卒.卒.卒.卒.卒
  5 .........
  4 .........
  3 兵.兵.兵.兵.兵
  2 .炮..炮....
  1 .........
  0 车马相仕帅仕相马车
    abcdefghi
    
Your move:

运行elephantfish!

elephahtfish 自包含在 elephantfish.py 文件中,只是用了python的自带操作而没有使用任何第三方库. 建议使用 pypy 或者 pypy3 来获得更好的性能表现.

简单的使用命令python elephantfish.py 或者pypy elephantfish.py 就可以运行象棋程序,程序会利用自带一个命令行工具进行对局.

特性

  1. 使用简单而高效的 MTD 二分搜索算法(见对弈程序基本技术).
  2. 使用众所周知的现代象棋引擎trick 比如空着裁剪.
  3. 通过简单的子力价值表进行局面评估.
  4. 使用python标准数据结构.

License

GNU GPL v3

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.