美国大学计算机专业大学一年期末作业 在15*15的格子里,在300步内,120秒内,看谁走过的格子数多,每个机器有自己的颜色,红或蓝. 1. 车子可以射斑点去攻击对手,射中对手的话,对手将走你的颜色,持续20步。 2. 可射斑点数为30。 3. 若撞到墙,游戏结束,你自动输了。 4. 若撞到另外一个车,游戏停止,画多格子的车胜。 5. 游戏版面包含有石头的格子,撞到的输,如墙 6. 射的斑点不能过石头 7. 每次控制算法下个格去哪它会接受周围5*5的格子。车子在中间格,指向面对方向。这个叫做短范围浏览。 8. 你的算法可以有限制次数的长范围浏览。范围为15*15。(看下面)你可以得到一个长范围浏览可以在你上一步行走时要求他。限制30个。 9. 游戏版面包含有雾的格子。如果雾没有笼罩石头,那任何车子将跟画其他格子一样画那个格子。然而,长范围浏览不能显示雾下面是什么。但短浏览可以显示什么在雾下面。雾会漂流,扩张,或者缩短在运行中。 10. 车子将在每个格子决定它的下一步怎么走。真快疯了……来大神指点一下,感激不尽!

解决方案 »

  1.   

    英文原版在这里:
    The Paintbot game is played on a 15 by 15 grid on which the two robots reside and compete. 
    Only one robot may occupy a square at a time. (If two robots try to occupy the same square at 
    the same time, they crash. There is more about this later.)  Robots may turn 90 degrees left, 90 
    degrees right, move forward one square, move backward one square, or stay in the same spot. In 
    addition, at any of these moves, the robot may fire a blob of paint, red or blue. At the beginning 
    of the game, all squares on the board are painted white (a neutral color) and each robot is 
    randomly assigned a paint color of red or blue. The game lasts for 300 moves, and both robots 
    move simultaneously.  During each turn or move of the simulation, the robot may make a move, 
    given by its control algorithm (the class you are writing). If the robot moves out of a square, the 
    square that it leaves is turned the robot’s color. The goal of the game is to have more squares on 
    the board painted your color than your robot opponent’s color. This is accomplished by moving 
    around the board and painting the squares. Thus, it is good to paint over squares colored your 
    opponents color, as it adds a square that is your color and takes one away from your opponent. 
    There are of course some wrinkles.  
    1. You may shoot a blob of paint, and if you hit your opponent’s robot, that robot will paint your 
    color instead of its own when it moves. This will last for 20 moves. Shooting takes place at the 
    end of the move. 
    2. You have only a limited number of paint blobs that you may shoot. This number is 30.  
    3. If you run into a wall, the game will end and your robot loses automatically.  4. If you run into the other robot, the game will end immediately and the robot with the most 
    squares painted its color at that point will win. 
    5. The game board contains squares that have rocks in them. Neither robot may enter these 
    squares, and running into a square with rocks will terminate the game with a loss for the player 
    that runs into the rock. (Just like running into a wall.)  
    6. You cannot fire through a rock.  
    7. Each time your control algorithm decides on the next move, it has access to its current 
    surroundings in the form of a 5 by 5 square. The robot you are controlling is at the center of the 
    square, and the direction it is facing is always considered “up.”  This is called a short-range or 
    local scan  
    8. Your control algorithm may also receive a limited number of long-range scans which gives the 
    contents of the entire 15 by 15 board.  A long-range scan is available to you with any move. You 
    are limited to 30 long-range scans.  
    10. At the beginning of the simulation, rocks are placed randomly on the board and the two robots in 
    competition are placed at a random position on the board.
      

  2.   

    第7点第8点没看懂什么意思,short-range , local scan  是什么意思呢?
      

  3.   

    short range就是5*5,local scan不清楚……
      

  4.   

    刚刚找到的,LocalScan是一个class,所有和这个程序相关的class信息都在这里:http://www.cs.iastate.edu/~cs227/assignments/assignment3/doc/paintbots/
      

  5.   

    还有请忽略掉第9条关于雾的设计,作业里没有这一条,中文是从网上找的,英文是我们学校的assignment3.pdf里面复制粘贴过来的
      

  6.   

    技术上没感觉到有难度的。应该JDK1.4之前的内容就足够了。
    你尝试着先一点点写着吧,遇到不会的解不开的在发帖问。自己做和看别人做收获差别是很大的。
    如果让我做,我会设计一个15*15的JLabel,225个Jlabel分别控制自己的格子显示相应的内容就行了。
    剩余的就是逻辑层的显示了。
      

  7.   

    这个虽然是Java作业,不过发到“人工智能”或者“算法”之类的板块可能更有帮助。