首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >windows python子进程在Othello棋盘游戏中使用时将无法工作。

windows python子进程在Othello棋盘游戏中使用时将无法工作。
EN

Stack Overflow用户
提问于 2020-09-03 15:45:10
回答 1查看 38关注 0票数 0

还在学习巨蟒的游戏“Othello”中使用了"AI“。https://www.instructables.com/id/Othello-Artificial-Intelligence/有两个版本的游戏-玩家和玩家对AI.我的问题是球员对AI,Othello_game.py。Othello_gui,播放器上的播放器工作没有问题。

错误是:

代码语言:javascript
复制
C:\Users\Joe\Documents\OthelloAI-master\OthelloAI-master> python othello_game.py [erika_5.py] [nathan_ai.py]
Traceback (most recent call last):
  File "othello_game.py", line 157, in <module>
    player1 = AiPlayerInterface(sys.argv[1],1)
  File "othello_game.py", line 36, in __init__
    self.process = subprocess.Popen(['python3',filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

init被编码为:

代码语言:javascript
复制
def __init__(self, filename, color):
    self.color = color
    self.process = subprocess.Popen(['python3',filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    name = self.process.stdout.readline().decode("ASCII").strip()
    print("AI introduced itself as: {}".format(name))
    self.name = name
    self.process.stdin.write((str(color)+"\n").encode("ASCII"))
    self.process.stdin.flush()

进口说明如下:

代码语言:javascript
复制
import sys
import subprocess
from threading import Timer
from othello_shared import find_lines, get_possible_moves, play_move, get_score

任何帮助都将不胜感激,只是学习子过程。1:https://www.instructables.com/id/Othello-Artificial-Intelligence/

EN

回答 1

Stack Overflow用户

发布于 2020-09-03 23:26:35

感谢Dinesh Pundkar的,编辑只是在添加shell = True

代码语言:javascript
复制
self.process = subprocess.Popen(['python',filename], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63727194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档