(可能有点复杂)
我有一个非常复杂的数组。由于技术原因,我需要将最后一次 update 的“ 位置”(在c中为指针)存储在阵列上(请参见下面)。
如何在纯JS 中做到这一点?
(长而清晰)
我正在进行一种强化学习,我在阵列上遇到了问题,该阵列用于存储我的系统< em>刚刚学会。
我的程序是学习(或从事井字游戏)。它将学到的东西存储在下面描述的数组中:
var learningArray = [
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/],
[/* What has been played? (Object)*/, /* What has been play following this turn? (Array)*/]
];
该数组由较小的数组组成。每个较小的数组由两个元素组成:
我每次更新后都会更新我的数组。因此,通常,它存储游戏的每回合。在玩了几场之后,它可能会存储游戏每回合的所有可能性(接下来我将计算获胜的可能性)。
注意: 当然,我的数组首先包含9个元素,因为井字游戏的游戏网格上有9个正方形。
假设我刚刚更新了数组的 元素。我需要存储该元素的位置,以便在下一次更新时写以下回合。
我喜欢c ++和c,因为 pointers 非常有用且易于使用。解决此问题的方法是在c中为最后一个更新的元素定义指针。简单容易
但是,JS 不支持指针(or everything is done to think it)。这里没有解决方案...
我该如何解决我的问题?
如果您有任何疑问或意见,请告诉我