使用PyGame用AI实现的Connect4游戏的修改版本。
connect-n的Python项目详细描述
连接-N
简介
使用PyGame在Python中用AI实现的connectfour游戏的一个简单修改版本。在
项目描述
- 这个存储库包含一个用python制作的简单游戏,类似于Connect 4。在
- 一个位修改为任何连接长度为任何董事会大小。在
- 目前支持在一个二维板上可变数量的玩家。在
- GUI模式下仅支持3播放器。在
- 对于更多玩家,请在connect\u/pygame中添加新的colors
COLOR
变量_实用工具.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.py
在windows上,使用虚拟环境(./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
系统要求
文件
限制
GUINOT在docker内部工作,因为docker不支持pygame。 解决方法:代码自动切换到命令行界面,而不会引发错误connect\un/connect_n.py。在
出资人
需要帮助
- 寻找任何算法,可能有助于设计人工智能的回合为基础的游戏有两个以上的玩家。在
- 寻找一个前端开发人员为网页和安卓做API前端。在
额外资源
- 烧瓶总成: 在
- freecodecamptutorial
承认
- 感谢Miguel Grinberg在烧瓶和如何学习它的优秀资源。在
- 感谢freecodecamp为伟大的开端助推。在
试验报告
开始时间:2019-08-11 19:14:05
持续时间:51.73秒
摘要:总计:26,通过:26
test_ai.AITests | Status | |
---|---|---|
test_get_move | Pass | |
test_greedy | Pass | |
test_horizontal_score | Pass | |
test_negative_digonal_score | Pass | |
test_positive_digonal_score | Pass | |
test_string_score | Pass | |
test_vertical_score | Pass | |
Total: 7, Pass: 7 -- Duration: 105 ms |
^{tb2}$
test_connect_n.ConnectNTests | Status | |
---|---|---|
test_add_player | Pass | |
test_get_strings | Pass | |
test_get_valid_moves | Pass | |
test_horizontal_winning_move | Pass | |
test_is_valid_move | Pass | |
test_make_move | Pass | |
test_negative_digonal_winning_move | Pass | |
test_positive_digonal_winning_move | Pass | |
test_simulate | Pass | |
test_version | Pass | |
test_vertical_winning_move | Pass | |
Total: 11, Pass: 11 -- Duration: 1 ms |
test_dataset_generate.GenerateDataTests | Status | |
---|---|---|
test_generate_save | Pass | |
test_load | Pass | |
Total: 2, Pass: 2 -- Duration: 25.66 s |
test_db_user_model.UserModelCase | Status | |
---|---|---|
test_check_token | Pass | |
test_password_hashing | Pass | |
test_to_dict | Pass | |
test_token_expiration | Pass | |
Total: 4, Pass: 4 -- Duration: 2.58 s |
test_pygame_utility.PygameUtilityTests | Status | |
---|---|---|
test_play | Pass | <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 |
- 项目
标签: