人工智能游戏开发[1]

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
人工智能游戏开发[1]
3-out-of-4 Heuristic (cont.)
n Count total 3-out-of-4 “unblocked” winning lines
n Compare to opponent n Utility(p,G) = f(p,G) – f(opponent(p),G) n f(a,G) = # of 3-out-of-4 winning lines for
人工智能游戏开发[1]
Background
Sold by Milton Bradley in February 1974
2 players Alternate turns Goal: Connect four
tiles in a row horizontally, vertically, or diagonally
and 3-out-of-4 heuristic – Expert – alpha-beta pruning with cutoff-depth
人工智能游戏开发
2020/11/9
人工智能游戏开发[1]
Overview
n Background n Connect Four as a search problem n Alpha-beta pruning n Details about winning n Heuristics n Implementation / Demo n Conclusion
人工智能游戏开发[1]
Connect Four as a Search Problem
≤7 possible moves per turn Enumerate each move Continue for each board configuration
Player 2
Player 1
人工智能游戏开发[1]
人工智能游戏开发[1]
Alpha-beta pruning
n O (bd/2) time complexity n b = branching factor = 7 n d = depth = 7 × 6 = 42
n Computationally intensive n Need cut-off depth n Can also add heuristics
人工智能游戏开发[1]
Scoreboard Heuristic (cont.)
n Compare players’ scores n Utility(p,G)
= Score(p,G) – Score(opponent(p),G)
人工智能游戏开发[1]
Implementation
n Written in C# under .NET Framework n Microsoft Visual Studio 2008 n Windows Forms application
人工智能游戏开发[1]
Winning Connect Four
n To win, player needs a “winning line” of 4
人工智能游戏开发[1]
3-out-of-4 Heuristic
n To win, player needs a “near” winning line of 3
line either horizontally, vertically, or diagonally, or the game board is full (indicating a tie). n Utility: +∞ if player has connected four, 0 if board is full, –∞ if opponent has connected four.
player a on board G
人工智能游戏开发[1]
Scoreboard Heuristic
n Extend 3-out-of-4 heuristic to n-out-of-4 for n ≤ 3
n Award weighted points based on the value
of n n Score(p,G) = 100(n3) + 10(n2) + 1(n1) n ni is the number of i-out-of-4 winning lines
any column that is not full. n Transition Model: Returns a board configuration with a
tile added to the specified column. n Goal/Terminal Test: A player has four of her tiles in a
for player p on game board G
人工智能游戏开发[1]
Scoreboard Heuristic (cont.)
n Five 1-out-of-4 winning lines (n1 = 5) n Five 2-out-of-4 winning lines (n2 = 5)
n Score = 100(0) + 10(5) + 1(5) = 55
Connect Four as a Search Problem
n States: Any board configuration with at most one player’s tile in each location
n Initial State: An empty game board with no tiles. n Actions: Place a tile of the current player’s color into
人工智能游戏开发[1]
CPU Difficulties
n 4 difficulties
– Beginner – random – Moderate – alpha-beta pruning with cutoff-
depth 3 and simple utility function – Hard – alpha-beta pruning with cutoff-dቤተ መጻሕፍቲ ባይዱpth 6
相关文档
最新文档