错误:“‘选择退出’中的预期命令”疏散模拟

问题描述 投票:0回答:1

我正在编写代码并遇到错误。我收到一条错误消息,指出“‘选择退出’中的预期命令”,问题似乎出在“初始化乘客”过程中的“选择退出补丁-此处”行中。我检查了代码,一切似乎都是正确的,所以我不确定是什么导致了问题。

编辑:您遇到的错误似乎与 lput 函数有关,该函数需要一个列表作为输入,但收到的是数字 0。

error while passenger 1 running LPUT
  called by procedure CHOOSE-EXIT
  called by procedure INITIALIZE-PASSENGERS
  called by procedure SETUP
  called by Button 'setup' 

这个错误已经在下面的尾部评论中解释过:

observer> type lput 42 [ 0 1 2 "..." ] ; anItem followed by aList

observer: [0 1 2 "..." 42]


然而,如果
lput
被调用,无论来自哪个调用者,都是由完全相同的源代码调用的,但是现在,使用错误的值/类型,修改后的代码已存储到相同的参数中,
我们从完全相同的代码中收到:
observer> type lput 42 0               ; anItem followed by anInteger

ERROR: LPUT expected this input to be a list, but got a number instead


或类似的:
observer> type lput 42 "not aList"     ; anItem followed by aString 

ERROR: LPUT expected this input to be a list, but got a string instead


这意味着,
你的代码在这里以某种方式调用了一个
lput
-clause,但是使用了错误的参数数据类型(内容)(现在的任务是通过
show
/
type
调试第一个和第二个参数传递的实际值,像这样:下面源代码中的子句)
;;;;;; DEBUG set possible-exits lput exitUnderTest possible-exits

所以你确切地知道什么数据内容和在哪里崩溃了
type word who "'ll TRY: possible-exits lput exitUnderTest possible-exits\n"

type word "WITH:" word exitUnderTest  "IN exitUnderTest\n"
我检查过“选择退出”过程是否正确定义,一切似乎都很好。我不明白为什么会收到此错误消息。您能否就可能出现的问题或如何解决此问题提供一些建议?




MCVE 语法需要一些修改,请随意进一步改进它(其他组件,如
type word "WITH:" word possible-exits "IN possible-exits\n"
在 MCVE 中仍然缺失):

set possible-exits lput exitUnderTest possible-exits ;; TRY lput EXEC'd

根据下面的评论 - MCVE 代码,没有将变量

type "EXEC'd...\n\n"
至少定义为模型修复,是不完整的(如果您稍后添加了一些其他代码部分,但未在上面的 MCVE 中发布,则你去吧,现在必须删除模型修复或解决新代码部分引入的新错误/适当添加新代码部分):

simulation netlogo cellular-automata
1个回答
0
投票

© www.soinside.com 2019 - 2024. All rights reserved.