import sys
import hifive_filler.field as field
import hifive_filler.parse as parse
import hifive_filler.token as token
import hifive_filler.placement as placement
def parse_field(player_number, field):
incoming = input()
(row_count, column_count) = parse.parse_field_meta(incoming)
field.update_dimensions(row_count, column_count)
_ = input() # drop column number row
for row_index in range(0,field.row_count):
incoming = input()
row_as_string = parse.split_field_input_line(incoming)[1]
(_, player_one, player_two) = parse.parse_field_line(row_as_string, row_index)
if player_number == 1:
field.player.update_content(player_one)
field.opponent.update_content(player_two)
else:
field.player.update_content(player_two)
field.opponent.update_content(player_one)
print('current player field is',field.player.content)
def parse_token(token):
incoming = input()
(row_count, column_count) = parse.parse_field_meta(incoming)
print('token dims',row_count,column_count)
token.update_dimensions(row_count, column_count)
token.reset_values()
for row_index in range(0,token.row_count):
incoming = input()
(token_res, _, _) = parse.parse_field_line(incoming, row_index)
token.shape.update_content(token_res)
print('token is',token.shape.content)
token.trim()
print('token is',token.shape.content)
def parse_input(player_number, field, token):
parse_field(player_number, field)
parse_token(token)
def place_token(field, token):
possibilites = placement.find_possible_placements(field, token)
could_place = (len(possibilites) > 0)
if (len(possibilites) > 0):
return (True, possibilites[0][0], possibilites[0][1])
return (False, 0, 0)
def main() -> None:
try:
player_number = parse.parse_player(input())[0]
f = field.Field()
t = token.Token()
could_place = True
while could_place:
parse_input(player_number, f, t)
(could_place, x, y) = place_token(f, t)
if could_place:
print(f"{y} {x}")
else:
print("0 0")
except Exception as e:
sys.stderr.write(e)
exit(1)
if __name__ == "__main__":
main()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共10个文件
py:8个
pkg-info:1个
toml:1个
资源分类:Python库 所属语言:Python 资源全名:hifive_filler-0.2.25.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
hifive_filler-0.2.25.tar.gz (10个子文件)
hifive_filler-0.2.25
PKG-INFO 210B
pyproject.toml 315B
hifive_filler
main.py 2KB
token.py 618B
placement.py 1KB
__init__.py 0B
parse.py 2KB
field.py 417B
shape.py 1KB
setup.py 602B
共 10 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功