Code Monkey home page Code Monkey logo

piece's Introduction

js五子棋实现(包括AI)

五子棋开发流程

  1. 界面实现
    1. 通过css + div + js 生产界面 首先生产格子
    2. 单击事件产生格子(注意单击后锁住按钮,防止事件重复)
  2. 游戏逻辑实现
    1. 使用二维数组[][]维护落子情况
    2. 下完棋判断落子棋的水平,右上,右下,垂直的成五情况,以及和棋情况
  3. AI实现(简单,困难,噩梦)
    1. 简单AI(防守型AI,眼光短浅)
      1. 对棋盘局面落子位进行我方和对手打分,如果对手的最大分值大于我方最大分值则防守。
    2. 困难AI(进攻型AI,眼光短浅)
      1. 对棋盘局面落子位进行打分,并计算威胁分数,如果我方的威胁比对方威胁大,则进攻。
    3. 噩梦(进攻型,眼光一般)
      1. 由于组合爆炸,通过 alphabeta剪枝实现后五步预测。根据威胁打分结果进行落子
      2. 由于五步预测,对于AI来说眼光还是很短,加上了自己的一些剪枝方式但是感觉有些问题
    4. 其他
      1. 落子随机性,有些情况,由于多个位置分数相同,通过随机方式,防止对手发现程序弱点后,走上次输得棋局。
      2. 关于打分

说明

目前AI的棋力还是很弱的,稍微认真一点还是很好赢。个人技术有限,无法写出较好的AI。。

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.