【发布时间】:2013-10-15 19:10:56
【问题描述】:
我正在为安卓开发一个井字游戏。用户将与计算机对战。我对游戏的大部分时间都完成了,但只是卡在了最后一个问题上。我尝试了很多,但找不到合适的随机方法来选择一个空的随机方块。 这就是我声明我的 9 个按钮的方式。
btn00 = (Button) findViewById(R.id.button);
btn01 = (Button) findViewById(R.id.button2);
btn01 = (Button) findViewById(R.id.button3);
btn10 = (Button) findViewById(R.id.button4);
btn11 = (Button) findViewById(R.id.button5);
btn12 = (Button) findViewById(R.id.button6);
btn20 = (Button) findViewById(R.id.button7);
btn21 = (Button) findViewById(R.id.button8);
btn22 = (Button) findViewById(R.id.button9);
请帮帮我。提前致谢!
【问题讨论】:
-
你不想让电脑玩家按照游戏逻辑来玩,而不是随意选择一个空方格吗?
-
@Dr.Avalanche 我只是一个 14 岁的孩子。我已经对逻辑进行了编程,但第一步我希望计算机选择一个随机方。请帮帮我!
标签: java android tic-tac-toe