Battleofai API的包装。

battleofai的Python项目详细描述


人工智能之战-python库

面向对象的easy2使用解决方案与https://battleofai.net/的API交互

基本特征的简要概述

轻松配置客户端。

frombattleofaiimportClientclient=Client(credentials=('username','password'))# if you want to export your configclient.config.from_python_file('config.py')# or use jsonclient.config.from_json_file('config.json')

自动玩游戏。

frombattleofaiimportClient,Coreclient=Client()# specify credentials@client.callback()defturn(board,symbol):forx_pos,columnsinenumerate(board):fory_pos,fieldinenumerate(columns):iffield=='#':# if position is freereturnx_pos,y_pos# set my stoneclient.play(Core)

手动玩游戏。

frombattleofaiimportClient,Core,GameStateimporttimeclient=Client()# specify credentialsdefturn(board,symbol):forx_pos,columnsinenumerate(board):fory_pos,fieldinenumerate(columns):iffield=='#':# if position is freereturnx_pos,y_pos# set my stonegame=Core.create_game()client.login()my_match=Core(callback=turn)my_match.join_game(client,game)# then eithermy_match.play()# or even something like thisplaying=Truewhileplaying:game.update()ifnotgame.state==GameState.STARTED:breakifmy_match.is_active:resp=my_match.make_turn()ifresp.status_code==200and'false'inresp.text:playing=Falsetime.sleep(5)

管理游戏。

frombattleofaiimportGame,GameState,Coremy_game=Game.get(game_id=100)print(my_game.players)open_games=Game.list(game_state=GameState.WAITING)new_game=Game.create(Core.__game_name__)

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

推荐PyPI第三方库


热门话题
如何使用外部java程序在minecraft中移动minecraft角色的相机   java输出文本文件中的变量   java LazyLoadingException在我尝试从多通关系获取对象时出现   java json rest API的错误:ClassCastException:org。json。无法将JSONObject强制转换为组织。json。杰索纳雷   java BigInteger。C中的intValue()等价物#   java大写所有字符,但不包括带引号字符串中的字符   java获取特殊字符   javascript为什么Selenium中的所有getX()调用都需要这么长时间?   rabbitmq rabbitmq java客户端并行消费   如何使用selenium Java在popover窗口中提取文本   对象在java中构造一类对象   java Room数据库未实现   json JSONObject可以使用java保存大的格式化双值吗?   有时限的旅行推销员   java HttpsURLConnection openConnection查询   java无法使用Spring@Entity注释创建MySQL表   lambda Java 8仅映射到值类型集合   java提供OSGi服务而不实现接口   java单个对象重写对象数组,不确定原因