Horsemeet——(博弈论)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_44056753/article/details/99643772

Traditional games such as chess or checkers with slight modifications, are also played in Binary Casino. However, not many people play them, as these games are often referred as boring. The visitors are more attracted to more dynamic games which cause adrenaline rushes. To attract players to traditional games, your boss wants to introduce a chess-based game called Horsemeet. The rules of the game are:

The game is played by two players on a 8×8 chessboard. One player plays a white knight and the other player plays a black knight. The players alternate in moves, the white knight moves first. In each move a knight is moved from its current position to a random valid position. Valid position within the chessboard is a position, which is two tiles away in one coordinate and one tile away in other coordinate from the original position. All moves to a valid position are equally probable. The first knight to move to a tile already occupied by the other knight wins.

In order to check whether this game could be at least partially interesting to visitors you have to determine the probability of victory for knights at given start positions. If the probabilities of victory for both knights differs by less than 10−6, the outcome of such configuration is a draw.

Input

The first line of input contains two integers A and B (1≤A,B≤8), the start position of the white knight. The second line of each input consists of two integers C and D (1≤C,D≤8), the start position of the black knight. You can assume both positions are distinct.

Output

Output the knight with a higher probability of victory: “white” or “black”. In case of equal probabilities output “draw”.

Examples

Input

1 1
4 7

Output

white

Input

1 1
8 8

Output

black

题意

在一张8*8的棋盘上下棋,只有两枚棋子,白棋先走,每次棋子必须移动,不能呆在原地不动,哪方可以吃掉对方即为获胜。给你白棋和黑棋的坐标,判断谁会取得胜利。

分析

白棋和黑棋一定有一个优势方,有一个劣势方,优势方肯定是想尽办法靠近对面取得胜利,而劣势方则是尽可能的远离对面,比赛中有的队伍用概率或bfs写的,非常复杂。其实看两枚棋子之间的距离(不是物理意义上的距离,结合题意理解)就可以判断胜负。如果是奇数则白方(先行方)胜利,否则黑方胜利。这里有一点一直不明白,题目中提到了平局的可能,但我分析的在棋局中不可能出现平局的情况,两方一定存在优势和劣势,只有在开始时黑白双方的棋子位置一样可以平局,但是这种情况太违背常理,所以比赛时也没有处理平局的情况,直接判断胜负,本来以为会wa,但谁知道ac了,这个地方一直不太理解。

#include <iostream>
using namespace std;

int main()
{
    int m,n;
    int a,b;
    cin>>m>>n;
    cin>>a>>b;
    int len1,len2;
    len1=m-a;
    len2=n-b;
    if(len1<0)
        len1=-len1;
    if(len2<0)
        len2=-len2;
    if((len1+len2)%2==0)
        cout<<"black\n";
    else
        cout<<"white\n";
}

猜你喜欢

转载自blog.csdn.net/weixin_44056753/article/details/99643772