MIPS 组装双陆棋棋盘游戏故障..
我的架构类有一个作业,要在 MIPS 汇编中实现 31 个西洋双陆棋游戏,到目前为止我已经做了很多工作,并且我一直在使用 2 个数组来显示棋盘,例如我使用 0 来指示空字段和其他数字13 显示当前放置在该字段中的棋子数量,有白色棋子(使用正数表示)和红色棋子使用 1-15 的负数表示。 但是当我问我的教授时,他告诉我他希望棋盘在每次移动后都更新,并且应该看起来像这样:(请注意,在游戏开始时,所有棋子都放置在棋盘的末尾这是起始字段)
W1
W2
W3
W4
W5
W6
|
W15
R15
R14
R13
R12
R11
R10
|
R1
并且上面的棋盘应该在掷骰子后更新, 这意味着我将不得不使用某种数组来表示和移动这些 数字和字母。但我真的发现在单个数组中实现动态整数和字符很令人困惑。有什么建议吗? 感谢论坛。
I have an assignment for my architecture class which to implement a 31 backgammon game in MIPS assembly, I have done alot so far, and I have been using 2 arrays to display the board, I used 0s to indicate empty fields and other numbers for example 13 to display the number of checkers currently placed in that field, there are White checkers (represented using postive numbers) and Red Checkers are represented using negative numbers from 1-15.
But when I asked my professor , he told me that he wants the board to be updated after every move and it is supposed to look like this:(note that at the beginning of the game all the checkers are placed at the end of the board which is the starting field)
W1
W2
W3
W4
W5
W6
|
W15
R15
R14
R13
R12
R11
R10
|
R1
And the above board is supposed to be updated after dice roll ,
which means Im going to have to use some sort of array to represent and move those
numbers and letters. But im really finding it confusing to implement dynamic ints and characters in a single array. Any suggestions?
Thanks Forum.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,将字符(R 或 W)和整数值存储在单个数组中将非常困难。从技术上讲,您已经将所有棋子堆栈的完整表示存储在数组中。如果您将整数上的符号位视为跳棋的颜色,那么您已经解决了问题。这是一个例子:
所以你看到你已经存储了颜色,但是你使用的是符号位而不是字符。现在您所要做的就是确定该数字是否有符号,并在该数字的绝对值之前显示相应的字符。
You're correct, storing both characters (R or W) and the integer value in a single array would be very difficult. Technically, you already are storing the entire representation of all the stacks of checkers in your array. If you think of the sign bit on your integer as the color of the checkers, you've already solved the problem. Here's an example:
So you see you're already storing the color, but you're using the sign bit instead of a character. Now all you have to do is determine if the number is signed or not and display the corresponding character before the absolute value of the number.