There is a condition in the game X_0:

if (a[1]=gmr1) and (a[2]=gmr1) and (a[3]=gmr1) then pobed:=1; if (a[4]=gmr1) and (a[5]=gmr1) and (a[6]=gmr1) then pobed:=1; if (a[7]=gmr1) and (a[8]=gmr1) and (a[9]=gmr1) then pobed:=1; if (a[1]=gmr1) and (a[5]=gmr1) and (a[9]=gmr1) then pobed:=1; if (a[3]=gmr1) and (a[5]=gmr1) and (a[7]=gmr1) then pobed:=1; 

Comparison of cells. gmr1 = gamer1 . How to make a tie condition? a [] - array stores cells. gmr1 - player 1. Draw condition - no 3x matching combinations (i.e., three identical cells - vertical, diagonal, horizontal) With this arrangement, it immediately goes: Draw.

 if (pobed=0) and (a[1]<>gmr1) and (a[2]<>gmr1) and (a[3]<>gmr1) and (a[4]<>gmr1) and (a[5]<>gmr1) and (a[8]<>gmr1) and (a[7]<>gmr1) and (a[8]<>gmr1) and (a[9]<>gmr1) and (a[1]<>gmr1) and (a[5]<>gmr1) and (a[9]<>gmr1) and (a[3]<>gmr1) and (a[5]<>gmr1) and (a[7]<>gmr1) then pobed:=3; // ничья 
  • one
    And when will people learn to properly formulate their questions? .. What kind of game? What does the variable gmr1 ? What does an a[] array store? And, actually, what should be the condition of a draw? - KiTE

1 answer 1

 pobed:=-1; // неопределённый результат // ищем условие победы gmr1 - pobed=1 // ищем условие победы gmr2 - pobed=2 if (pobed=-1) and (a[1]<>empty) and (a[2]<>empty) and (a[3]<>empty) and ... and (a[9]<>empty) then pobed:=0; // ничья 

empty - empty cell