How to realize Gobang algorithm by python
In this article, the editor introduces in detail "how to achieve Gobang algorithm in python". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to achieve Gobang algorithm in python" can help you solve your doubts.
If will win chess if index-fun.
< 0 or pos[index-fun][2] != p[2]: #当前点击的格子是第一行 或 不在第一行,在假设的首个格子中 print('----------第一个格子') for i in range(1,5): # (1-4) if index + (fun * i) = 4: if p[2] == 1: print('最后一下为第一个格子--黑赢') ShowAllChess()#显示所有已经放置了的棋子 ResultShow(1) if p[2] == 2: print('最后一下为第一个格子--白赢') ShowAllChess()#显示所有已经放置了的棋子 ResultShow(2) elif index + fun >191 or pos [index + fun] [2]! = p [2]: # the grid currently clicked is the last line or not in the last line In the last grid, print ('- last grid') for i in range (1 if 5): # (1-4) if pos [index-(fun * I)] [2] = = p [2]: chessValue = chessValue + 1 if chessValue > = 4: if p [2] = = 1: print ('the last one is the last grid-black wins') ShowAllChess () # shows all the pieces that have been placed ResultShow (1) if p [2] = = 2: print ('the last one is the last grid-win for nothing ') ShowAllChess () # shows all the pieces that have been placed ResultShow (2) else: # not the first and not the last That is, what is currently clicked is the pawn in the middle of the five beads, the print ('- middle grid')''the first cycle to detect whether there are similar pieces in the upper-middle lattice' 'for i in range (1-3): # (1-3) three cycles If index-(fun * I) > = 0 and pos [index-(fun * I)] [2] = = p [2]: chessValue = chessValue + 1 elif index-(fun * I) > = 0 and (pos [index-(fun * I)] [2]! = p [2]\ and pos [index-(fun * I)] [2] ]! = 0): # the logic here is that the top is the opponent chess piece chessValue = 0 # the number of beads is returned to zero 'for i in range (1): # (1-3) three cycles if index + (fun * I)