编程介的小学生 2020-02-03 21:50 采纳率: 20.5%
浏览 179

New Game 策略游戏算法

Problem Description
While ZSTU’s acmers were coding, coach Yehr was so bored that he created a new game to kill time. And the game is called “Yehr Game” because of the inventer.
Yehr Game is a board game involving two players. It is played on a board with 40 squares arranged in an ten-by-four grid. At the beginning of the game each player controls four pieces: one acm, one bahamas, one cab and one daze. If one player has no pieces to move, he lost the game.
Setup:
Yehr Game is played on a rectangle board of ten rows and four columns. The pieces are divided, by convention, into red and black sets. The players are referred to as "Red" and "Black", and each begins the game with four pieces of the specified color. These consist of one acm, one bahamas, one cab and one daze.

Movement:
First, they setup their pieces on the board.
(1) the piece red acm can be placed on A1~,A2,A3,A4,A5;the piece black acm A6~A10;
(2) the piece red bahamas can place on B1~B5; the piece black Bahamas B6~B10;
(3) the piece red cab can place on C1~C5; the piece black cab C6~C10;
(4) the piece red daze cab can place on D1~D5; the piece black daze D6~D10;
Second, they determine who moves first by dice. After the initial move, the players alternately move one piece at a time.
Each chess piece has its own style of moving.
(1) Acm can only move one direction: red from left to right; black from right to left. Acm can only move to the next square. If one player’s acm moves to a square with the opponent acm, he win the game.
(2) Bahamas and cab can move two direction: from left to right or from right to left. And they can move any number of squares but may not leap over other pieces.
(3) Daze can only move one direction: red from right to left; black from left to right.Daze can only move to the next square. In order to win the game, every clever player places the red daze on d5 and the black on d6.
Of Course, we assume that all players are clever.

Input
The input contains several test cases.
Each test case contains three lines:
First line contains one integer number 0 or 1: 0 indicated red move first and 1 black first.
Second line contains four integer numbers r1, r2, r3, r4 indicating the four red pieces’ square. For example, r3=3 indicating the red cab on C3.
Third line contains four integer numbers k1, k2, k3, k4 indicating the four black pieces’ square. For example, k1=9 indicating the black acm on A9.
We assume that r4 is always 5, and K4 is 6.

Output
For each test case, if red win print Red in a single line, else print Black.

Sample Input
0
4 5 5 5
7 6 6 6

Sample Output
Red

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)