Chess game seat algorithm

1, an example mahjong
players A, B, C, D seat as
         C 2
D Bl. 3
        A 0

first acquires all players server location: Index = 0,1,2,3
added now viewing angle of B
is: a shift = B.index 1 - 0 = 1, one position described
new seats number:
B = B.index - 1-1 of shift = 0 =
C = C.index - shift = 2-1. 1 =
D = D .index - shift 2 = 3-1 =
a = A.index - shift = 0 - 1 = -1 if it is negative, then the total number of + 4: 3 = 4 + -1

Similarly: C Perspective
shift C.index bits 2-0 = 2 =

C = C.index - 2-2 shift = 0 =
D = D.index - shift = 3-2. 1 =
A = A.index - shift = 0 - 2 = -2, if it is negative, then the total number of + 4: -2 + 2 = 4
B = B.index - shift = 1--2 = -1 if it is negative, then the total number of + 4: -1 + 4 = 3


Similarly: Angle D of
the shift D.index 3-0 = = 3
D = D.index - shift = 3 - 3 = 0
A = A.index - Shift = 0 - . 3 = -3, if it is negative, then the total number of +. 4: -3. 4 = 1 +
B = B.index - Shift = 1 - . 3 = -2, if negative, then the total number of + 4: -2 + 4 = 2
C = C.index - shift = 2 - . 3 = -1 if it is negative, then the total number of + 4: -1 + 4 = 3

2 doudizhu Similarly algorithm position
C 2. 1 B
             A0

first acquires all players server location: Index = 0,1,2
added now viewing angle of B
is: shift = B.index 1 - 0 = 1, a moving position described
new seat serial number:
B = B.index - 1-1 of shift = 0 =
C = C.index - shift = 2-1. 1 =
a = A.index - shift = 0 - 1 = -1 if it is negative , the total number of + 3: -1 + 3 = 2

Similarly: C Perspective
shift = 2-0 C.index = 2
C = C.index - shift = 2 - 2 = 0
a = A.index - shift = 0 - 2 = -2, if it is negative, then the total number of + 3: 1 -2 + 3 =
B = B.index - Shift = 1 - 2 = -1 if it is negative, then the total number of + 3: -1 + 3 = 2

 

 

Source: https: //bbs.egret.com/thread-47694-1-1.html

Guess you like

Origin www.cnblogs.com/gao88/p/11371418.html