"Array exceed the predefined size"
2 次查看(过去 30 天)
显示 更早的评论
I'm running a simple program, and sometimes(yeah) i would be stuck in the following error:
What's more, it said that i wanted to create an array with size of 1x18446744073709551615 (17179869184.0GB)
OMG....
I'm just concating two arrays...
"player = [player,deck(1)]; deck = deck(2:end); "
From the environment section, i saw that the array was all fine, but when i click the botton to step, the program abort.
the player and deck are just two small arrays.
HELP.
3 个评论
回答(1 个)
Walter Roberson
2020-5-2
I am not seeing that error.
I had to guess what your shufflecards function does.
I encounter
Index exceeds the number of array elements (14).
Error in jackall (line 39)
action = P(sub2ind([N_PLAYER_VALUE,N_DEALER_VALUE,N_ACE],state(1)-11,state(2),state(3)+1));
Which makes sense. You do not initialize P, and you store into
P(sub2ind([N_PLAYER_VALUE,N_DEALER_VALUE,N_ACE],state(1,1)-11,state(1,2),state(1,3)+1)) = action;
which builds it out to a certain size. Then you
state = stateFromHand(player,dealer_showed);
which changes state, and you try to do
action = P(sub2ind([N_PLAYER_VALUE,N_DEALER_VALUE,N_ACE],state(1)-11,state(2),state(3)+1));
but since the first element of the state increased due to the additional card being taken into account, the right hand side is trying to index into P at a location beyond what you initialized.
3 个评论
Walter Roberson
2020-5-2
I did guess that shufflecards was randperm(52)
>> type shufflecards.m
function shuffled = shufflecards()
shuffled = randperm(52);
end
I used your exact code other than guessing (correctly) for shufflecards, and I encountered the error message I indicated above.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!