gpt4 book ai didi

java - 斯卡恩的骰子游戏 :the comp_overall_score is not getting updated

转载 作者:太空宇宙 更新时间:2023-11-04 12:44:00 24 4
gpt4 key购买 nike

下面的代码是计算机玩游戏的部分代码。问题是计算机播放时 comp_overall_score 没有更新。请帮忙。

 while(comp_turn_score < 20)
{
//roll logic
rollValue = rolldice();
Log.v("\nComputer Roll:",Integer.toString(rollValue));
if(rollValue != 1)
{
comp_turn_score += rollValue;
updateLabel("Computer's Turn Score: " + comp_turn_score);

return;
}
else //computer roll a 1
{
//reset turn score to 0 and give control to user
comp_turn_score = 0;
updateLabel("\nComputer rolled a 1! Your's Turn");
rollb.setEnabled(true);
}
}

//computer holds
comp_overall_score+= comp_turn_score;
updateLabel("\nComputer Holds! Your's Turn");
if(checkWinner()) return;
rollb.setEnabled(true);

}
private void updateLabel(String s)
{
lable.setText("\nYour score: " + user_overall_score + " Computer Score: " + comp_overall_score +" " + s);
}

最佳答案

  if(rollValue != 1)
{
comp_turn_score += rollValue;
updateLabel("Computer's Turn Score: " + comp_turn_score);

return;
}

删除返回语句,一切都会按计划进行。

关于java - 斯卡恩的骰子游戏 :the comp_overall_score is not getting updated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36528906/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com