import{_ as i,D as l,c as t,j as e,a as o,I as a,a4 as d,o as n}from"./chunks/framework.DtvhUNIn.js";const O=JSON.parse('{"title":"项目:Tic-Tac-Toe 井字棋","description":"","frontmatter":{},"headers":[],"relativePath":"技术资源汇总(杭电支持版)/4.人工智能/4.3.1.2项目:Tic-Tac-Toe井字棋.md","filePath":"技术资源汇总(杭电支持版)/4.人工智能/4.3.1.2项目:Tic-Tac-Toe井字棋.md"}'),r={name:"技术资源汇总(杭电支持版)/4.人工智能/4.3.1.2项目:Tic-Tac-Toe井字棋.md"},s=e("h1",{id:"项目-tic-tac-toe-井字棋",tabindex:"-1"},[o("项目:Tic-Tac-Toe 井字棋 "),e("a",{class:"header-anchor",href:"#项目-tic-tac-toe-井字棋","aria-label":'Permalink to "项目:Tic-Tac-Toe 井字棋"'},"​")],-1),p=e("div",{class:"warning custom-block"},[e("p",{class:"custom-block-title"},"😋 我们为你提供了一个简单有趣的项目,帮助你进行知识巩固,请认真阅读文档内容。"),e("p",null,"如果你卡住了,请记得回来阅读文档,或请求身边人的帮助。")],-1),u={class:"tip custom-block"},_=e("p",{class:"custom-block-title"},"📥",-1),h=d('

pip3 install -r requirements.txt

理解

这个项目有两个主要文件:runner.pytictactoe.pytictactoe.py 包含了玩游戏和做出最佳动作的所有逻辑。runner.py 已经为你实现,它包含了运行游戏图形界面的所有代码。一旦你完成了 tictactoe.py 中所有必需的功能,你就可以运行 python runner.py 来对抗你的人工智能了!

让我们打开 tictactoe.py 来了解所提供的内容。首先,我们定义了三个变量:X、O 和 EMPTY,以表示游戏的可能移动。

函数 initial_state 返回游戏的启动状态。对于这个问题,我们选择将游戏状态表示为三个列表的列表(表示棋盘的三行),其中每个内部列表包含三个值,即 X、O 或 EMPTY。以下是我们留给你实现的功能!

说明

实现 player, actions, result, winner, terminal, utility, 以及 minimax.

提示

',10);function T(m,y,x,b,f,P){const c=l("Download");return n(),t("div",null,[s,p,e("div",u,[_,e("p",null,[o("本节附件下载 "),a(c,{url:"https://cdn.xyxsw.site/code/1-Projects.zip"})])]),h])}const X=i(r,[["render",T]]);export{O as __pageData,X as default};