小编Jod*_*992的帖子

为什么我的Minimax无法扩展并正确移动?

我正在Pacman的基本游戏中的Python 2.7.11中实现minimax。Pacman是最大化代理,而一个或多个幽灵(取决于测试布局)是最小化代理。

我必须实现minimax,以便可能有多个以上的最小化代理,并且它可以创建n层(深度)的树。例如,第1层将是每个幽灵转弯以最小化终端状态实用程序的可能移动,以及pacman进行转弯以最大化幽灵已经最小化的东西。在图形上,层1如下所示:

层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)

python recursion artificial-intelligence minimax python-2.7

6
推荐指数
1
解决办法
3109
查看次数

为什么我的值词典需要浅拷贝才能正确更新?

我工作的一个AgentPython中2.7.11使用一类马尔可夫决策过程(MDP)来搜索最优策略πGridWorld.我正在GridWorld使用以下Bellman方程为所有状态的100次迭代实现基本值迭代:

在此输入图像描述

  • T(s,a,s')是通过采取动作 a从当前状态 s成功转换到后继状态 s'的概率函数.
  • R(s,a,s')是从 s转换到 s'的奖励.
  • γ(γ)是折扣因子,其中 0≤γ≤1.
  • V k(s')是一个递归调用,一旦达到 s'就重复计算.
  • V k + 1(s)代表在经历足够的 k次迭代之后, V k迭代值将收敛并变得等于 V k + 1

这个等式来源于取得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

5
推荐指数
1
解决办法
146
查看次数

如何将解释器添加到PhpStorm 2016.1.1

我是PHP的新手,但对JetBrains IDE非常熟悉,所以我选择PhpStorm作为我的IDE来学习.我可以很好地创建PHP文件,但是找到并安装解释器已经证明是一个我无法弄清楚的问题.我从php.net下载了PHP版本7.0.6,但它只是一个包含大量文件和文件夹的目录,没有可执行文件(例如Python 2.7或3.x只需在系统上安装解释器).

如何将PHP解释器加载到PhpStorm中?

php installation interpreter jetbrains-ide phpstorm

1
推荐指数
1
解决办法
3752
查看次数

如何从 Webhook 获取数据以存储在数据库中?

我正在使用基于 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.

php post json webhooks sendgrid

1
推荐指数
1
解决办法
1万
查看次数

TypeError:main()只取1个参数(给定0)

我正在尝试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 program-entry-point typeerror python-2.7

0
推荐指数
1
解决办法
8238
查看次数