使用PyGame用AI实现的Connect4游戏的修改版本。

connect-n的Python项目详细描述


连接-N

License: GPL v3Build StatusCodacy BadgeCodecovCode Style


简介

使用PyGame在Python中用AI实现的connectfour游戏的一个简单修改版本。在

项目描述

  • 这个存储库包含一个用python制作的简单游戏,类似于Connect 4。在
  • 一个位修改为任何连接长度为任何董事会大小。在
  • 目前支持在一个二维板上可变数量的玩家。在
  • GUI模式下仅支持3播放器。在
  • 对于更多玩家,请在connect\u/pygame中添加新的colorsCOLOR变量_实用工具.py文件。在
  • ID 1是为AI保留的。在
  • 目前只支持一个游戏中的单个AI玩家。在
  • 在Windows操作系统上用Python3.7进行测试(由开发人员负责)。在
  • API:用于API开发的flask。在
  • 使用flask-migrate进行数据库迁移。在
  • 使用httpie进行API调用和测试,类似于postman。在

安装

Windows

git clone https://github.com/Kartikei-12/Connect-N
cd Connect-N-master
python -m venv venv
./venv/Scripts/activate
pip install -r requirements.txt
python -m unittest discover --verbose

基于Linux的操作系统

^{pr2}$

直接使用

举个简单的例子

跑主.py作为python main.pywindows上,使用虚拟环境(./venv/Scripts/activate)。在

跑主.py在^{str1}$Ubuntu/Linux上使用虚拟环境(source /venv/Scripts/activate)作为python3 main.py。在

美国石油学会

API设置(一次性)

git clone https://github.com/Kartikei-12/Connect-N
cd Connect-N-master
python -m venv venv
./venv/Scripts/activate
pip install -r requirements.txt
cd connect_n/api/
pip install -r requirements.txt
flask db init
flask db migrate -m "Initial migration"
flask db upgrade
cd ../../

API用法

Connect-N/connect_n/api目录中使用flask run运行服务器。在

API调用:在新终端do http GET http://127.0.0.1:5000/test

系统要求

  • Python 3
  • Pip通常与python一起预装,请检查pip3 --version。在
  • Python模块PyGame可通过pip安装。在

文件

docs

限制

GUINOT在docker内部工作,因为docker不支持pygame。 解决方法:代码自动切换到命令行界面,而不会引发错误connect\un/connect_n.py。在

出资人

@Kartikei Mittal

需要帮助

  • 寻找任何算法,可能有助于设计人工智能的回合为基础的游戏有两个以上的玩家。在
  • 寻找一个前端开发人员为网页和安卓做API前端。在

额外资源

承认

<;html>; <;head>; <;title>;测试报告<;/title>; <;meta charset=“utf-8”>; <;meta name=“viewport”content=“width=device width,initial scale=1.0”>; <;link rel=“stylesheet”href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css“integrity=”sha384-1q8mTJOASx8j1Au+a5wdvnpi2lkfwweaa8hddjzlplegxhjvme1fgjwpgmkzs7“crossorigin=”匿名“>; <;/head>; <;车身>;

试验报告

开始时间:2019-08-11 19:14:05

持续时间:51.73秒

摘要:总计:26,通过:26

test_ai.AITestsStatus
test_get_movePass
test_greedyPass
test_horizontal_scorePass
test_negative_digonal_scorePass
test_positive_digonal_scorePass
test_string_scorePass
test_vertical_scorePass
Total: 7, Pass: 7 -- Duration: 105 ms
^{tb2}$
test_connect_n.ConnectNTestsStatus
test_add_playerPass
test_get_stringsPass
test_get_valid_movesPass
test_horizontal_winning_movePass
test_is_valid_movePass
test_make_movePass
test_negative_digonal_winning_movePass
test_positive_digonal_winning_movePass
test_simulatePass
test_versionPass
test_vertical_winning_movePass
Total: 11, Pass: 11 -- Duration: 1 ms
test_dataset_generate.GenerateDataTestsStatus
test_generate_savePass
test_loadPass
Total: 2, Pass: 2 -- Duration: 25.66 s
test_db_user_model.UserModelCaseStatus
test_check_tokenPass
test_password_hashingPass
test_to_dictPass
test_token_expirationPass
Total: 4, Pass: 4 -- Duration: 2.58 s
test_pygame_utility.PygameUtilityTestsStatus
test_playPass <button class="btn btn-default btn-xs">View</button>

pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html

Total: 1, Pass: 1 -- Duration: 23.39 s
<;/body>;<;/html>;

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在Android Studio中使用while循环显示包含textview对象的数据   创建名为“userController”的bean时发生java错误:通过字段“userService”表示未满足的依赖关系   java PDFBox PDFImageWrite。writeImage未正确处理所有字符   java无法识别代码中的nzec错误   无法更改java TabLayout字体   在Java中使用子字符串删除部分字符串   Java中的listener addPropertyChangeListener方法   java可以同时拖动多个对象   java如何将数组中的值添加到向量中   java为什么在Camel 3.7.3中无法正确计算属性?   与后端问题不同的机器中的java客户端资源   带字符串的java分割字节数组?   java On_选项_项目_选择的方法说明   java如何在画布的父画中画一个圆?   连接超时和打开连接数的java Netty通道配置   java mysql中如何防止向数据库中插入重复数据   升级到macOS Big Sur后,java无法启动Neo4j控制台应用程序   在Java中使用XSLT将XML转换为HTMLString的ajax   java无法使用Apache POI获取Excel工作表中的数据