我正在Pacman的基本游戏中的Python 2.7.11中实现minimax。Pacman是最大化代理,而一个或多个幽灵(取决于测试布局)是最小化代理。
我必须实现minimax,以便可能有多个以上的最小化代理,并且它可以创建n层(深度)的树。例如,第1层将是每个幽灵转弯以最小化终端状态实用程序的可能移动,以及pacman进行转弯以最大化幽灵已经最小化的东西。在图形上,层1如下所示:
如果我们将以下任意实用程序分配给绿色终端状态(从左到右):
-10, 5, 8, 4, -4, 20, -7, 17
Pacman应该返回-4,然后朝该方向移动,根据该决定创建一个全新的minimax树。首先,实现我的实现所需要的变量和函数的列表:
# Stores everything about the current state of the game
gameState
# A globally defined depth that varies depending on the test cases.
# It could be as little as 1 or arbitrarily large
self.depth
# A locally defined depth that keeps track of how many plies deep I've gone in the tree
self.myDepth
# A function that assigns a numeric …Run Code Online (Sandbox Code Playgroud) 我工作的一个AgentPython中2.7.11使用一类马尔可夫决策过程(MDP)来搜索最优策略π的GridWorld.我正在GridWorld使用以下Bellman方程为所有状态的100次迭代实现基本值迭代:
这个等式来源于取得Q值函数的最大值,这是我在程序中使用的:
构造my时Agent,会传递一个MDP,它是一个包含以下方法的抽象类:
# Returns all states in the GridWorld
def getStates()
# Returns all legal actions the agent can take given the current state
def getPossibleActions(state) …Run Code Online (Sandbox Code Playgroud) python iteration dictionary artificial-intelligence python-2.7
我是PHP的新手,但对JetBrains IDE非常熟悉,所以我选择PhpStorm作为我的IDE来学习.我可以很好地创建PHP文件,但是找到并安装解释器已经证明是一个我无法弄清楚的问题.我从php.net下载了PHP版本7.0.6,但它只是一个包含大量文件和文件夹的目录,没有可执行文件(例如Python 2.7或3.x只需在系统上安装解释器).
如何将PHP解释器加载到PhpStorm中?
我正在使用基于 SendGrid API v3 的 Webhook。Webhook 完全设置了 SendGrid 发布到的端点,但我需要能够接收解析的数据并将其存储在使用 PHP 的数据库中,但不知道如何做到这一点。
我在启动数据检索或 POST 之前使用过 API,但是当 API 服务器是一个 POST 时,我如何捕获通过 Webhook 端点解析的数据?到目前为止,我有一些简单的方法,但我真的不清楚如何解决这个问题:
<?php
$json = file_get_contents('https://example.com/webhook.php');
$json_decoded = json_decode($json, true);
$var_dump(json_decoded);
?>
Run Code Online (Sandbox Code Playgroud)
我曾尝试向主持人发送多封电子邮件,但每次拨打此电话时我都会返回NULL.
我正在尝试main()在Python 2.7.11中创建一个类文件并运行它,但Python声称我需要传递main()一个参数.
def main(self):
howManyBadCrops = BadCropsDetector() # My class
# a bunch of stuff goes here that runs the module....
if __name__ == "__main__":
main()
Run Code Online (Sandbox Code Playgroud)
为什么会这样?这是我的终端输出:
Traceback (most recent call last):
File "badCropsDetector.py", line 11, in <module>
class BadCropsDetector:
File "badCropsDetector.py", line 66, in BadCropDetector
main()
TypeError: main() takes exactly 1 argument (0 given)
Run Code Online (Sandbox Code Playgroud) python ×3
python-2.7 ×3
php ×2
dictionary ×1
installation ×1
interpreter ×1
iteration ×1
json ×1
minimax ×1
phpstorm ×1
post ×1
recursion ×1
sendgrid ×1
typeerror ×1
webhooks ×1