创建具有随机行和列的网格 [英] creatting a grid with random rows and collumns

查看:83
本文介绍了创建具有随机行和列的网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建一个动态创建网格的程序.行数应使用随机数生成器选择.列数也应使用随机数生成器选择.
箭头应最初位于网格的左下角位置.应将箭头编程为根据运行时将放置在屏幕底部文本框中的说明进行移动.一旦按钮"Go!"按下,箭头的动画应该开始.这应该以允许用户观察箭头运动的每个步骤的速度进行.
箭头仅允许访问白色框.允许垂直,水平和对角线移动.如果箭头到达蓝色框,则会显示一条错误消息,并且箭头应返回其起始位置.
o运动控制语言由三个命令组成:Ln,Rn和Fn. o Ln表示将箭头向左(逆时针)旋转n个位置,其中n是整数(整数).
o Rn表示将箭头右(顺时针)经过n个位置,其中n是整数(整数).
o Fn表示将箭头向前移动n个位置,其中n是整数(整数).
o示例命令可能是R2F3L2F1R2F4.

Create a program which dynamically creates a grid . The number of rows should be chosen using a random number generator. The number of columns should also be chosen using a random number generator.
The arrow should be initially positioned in the bottom left position on the grid. The arrow should be programmed to move in accordance with the instructions that will be placed into the textbox at the bottom of the screen at runtime. Once the button "Go!" is pressed, the animation of the arrow should begin. This should proceed at a pace that allows the user to observe each step of the arrows motion.
The arrow is only allowed to visit the white boxes. Vertical, horizontal and diagonal movements are permitted. Should the arrow reach blue box, an error message should be displayed and the arrow should return to its starting position.
o The movement control language is made up of three commands: Ln, Rn and Fn.,
o Ln means turn the arrow left (anticlockwise) through n positions, where n is an integer (whole number).
o Rn means turn the arrow right (clockwise) through n positions, where n is an integer (whole number).
o Fn means move the arrow forward through n positions, where n is an integer (whole number).
o A sample command might be R2F3L2F1R2F4.

推荐答案

请参阅我对问题的评论.首先,您真的需要为自己正确地解决问题.

我最近对遥远相似的问题的回答可能会帮助您感觉所涉及的内容:
验证近距离扫雷VB.NET [ ^ ].

您的游戏很可能也可以表现为非常简单的细胞自动机.您需要基于此概念对游戏进行清晰的说明.

您还可能需要关于有限状态机(FSM)的想法:
http://en.wikipedia.org/wiki/Finite-state_machine [
Please see my comment to the question. You really need to formulate the problem correctly, first of all, for yourself.

My recent answer to remotely similar question might help you feel what''s involved:
Verify Close Mines Minesweeper VB.NET[^].

Most likely, you game also can be presented as a very simple cellular automaton. You need to have a clear specification of the game based on this notion.

You can also need an idea on finite-state machines (FSM):
http://en.wikipedia.org/wiki/Finite-state_machine[^].

—SA


这篇关于创建具有随机行和列的网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆