课程: AI Algorithms for Game Design with Python
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Code example: A random cat
- As a warmup, let me show you the code for the random cat I just played against. First, let's go to main dot pi to see the server code. In this file, we are only interested in two actions, when the user starts a new game and when the user clicks on an empty tile. Both actions come from the VSCode extension as messages. Don't worry, you won't have to modify anything in this file. I just want you to see the methods I'm using to interact with the Cat Trap backend. In line 44, we catch the new game command. So in line 46, we create a new instance of the Cat Trap game class with a hexgrid of the requested size. Then in line 47, we initialize the hexgrid with random tiles blocked. Next in line 49, we have the move command. In lines 56 through 64, we read the parameters from the controls in the GUI extension. Now in line 69, we call the select cat move method to produce the new cat's position. This method receives all the parameters we gathered to determine the algorithm to use. Now let's…
内容
-
-
-
(已锁定)
Some history as motivation3 分钟 46 秒
-
(已锁定)
Different types of games2 分钟 17 秒
-
(已锁定)
Tree-based decision-making2 分钟 28 秒
-
(已锁定)
Time complexity of brute-force approaches2 分钟 56 秒
-
(已锁定)
Time complexity of chess2 分钟 31 秒
-
The cat trap game3 分钟 36 秒
-
(已锁定)
The Python setting for the cat trap6 分钟 38 秒
-
(已锁定)
Code example: A random cat6 分钟 8 秒
-
(已锁定)
-
-
-
-
-