Another Psuedocode Implementation Question?

Hello there. I have another psuedocode problem. The following photo shows the section of the psuedocode that has me stumbled. The thing is that when I try to execute this part of the entire psuedocode, it says that the gameOn function is undefined. Why is this? Can anyone help out?
Here's my attempted psuedocode implementation:
while gameOn == true
if turn < 0
[r,c] = getmove(G,-1);

답변 (1개)

Walter Roberson
Walter Roberson 2017년 11월 2일

0 개 추천

You failed to do steps 4 and 6 and 7. gameOn is defined in step 6.

댓글 수: 4

Matt Amador
Matt Amador 2017년 11월 2일
편집: Matt Amador 2017년 11월 2일
I'm sorry, here is the rest of the first half of the code. Matter of fact, here's the other half of the psuedocode as well.
G = [0 0 0, 0 0 0, 0 0 0];
turn = 1;
rand(5)
if rand < 0.5
turn = -1;
end
gameon = true;
plotTicTacToe(G)
while gameOn == true
if turn < 0
[r,c] = getmove(G,-1);
You set gameon to true, but you compare gameOn to true.
So then should I just leave the while as:
while gameOn
As long as you make sure you initialize gameOn (upper-case O) instead of gameon (lower-case O) either one is fine.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2017년 11월 2일

댓글:

2017년 11월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by