⬆️ ⬇️

Writing Reversi game in Python + PyQt4

We were asked to somehow write a small project - a Reversi game.

And since now I am learning Python, I decided to write on it. Together with the PyQt4 graphic library.

Well, what is the matter for? Create SVN and go! (Moved to Github )



Here is a miracle I did:

Screenshot game



According to Wikipedia (I completely agree with her)

The game uses a square board measuring 8 × 8 cells (all cells can be of the same color) and 64 special pieces painted from different sides in contrasting colors, for example, white and black. Board cells are numbered from the upper left corner: verticals - in Latin letters, horizontals - in numbers. One player plays white, the other black. When making a move, the player puts the chip on the cell of the board with “his” color up.

At the beginning of the game, 4 chips are put in the center of the board: black on d5 and e4, white on d4 and e5.

  • Black makes the first move. Next, the players take turns.
  • When making a move, a player must place his chip on one of the cells of the board in such a way that between this put chip and one of the chips of its color already on the board there is a continuous row of opponent's chips, horizontal, vertical or diagonal (in other words, a continuous row of chips the opponent turned out to be “closed” by the player’s chips from two sides). All opponent's pieces that are in the "closed" row on this turn are turned over to the other side (change color) and are transferred to the player who has walked.
  • If as a result of one move, more than one row of the opponent's chips “closes” at the same time, then all the chips that are on all the “closed” rows are turned over.
  • The player has the right to choose any of the possible moves for him. If a player has possible moves, he cannot refuse to move. If the player has no valid moves, the move is transferred to the opponent.
  • The game stops when all the chips are put on the board or when no player can make a move. At the end of the game, the counting of chips of each color is carried out, and the player whose chips on the board are displayed more is declared the winner. If the number of chips is equal, a draw is counted.




I know Python at a basic level. He wrote something under the Google App Engine (for example, a crutch for himself to get a convenient RSS channel for a YouTube user, but this is not the point). Something just like that. Something for the project Euler (excellent site must be said). In general, it was played :)



I didn't deal with Qt. But to understand, as it turned out, is not at all difficult.

The basis of the foundations , in Russian. As well as documentation here and here . Along with the PyQT4 distribution, there is a good base of examples that also helped me figure it out.

')

There is no sense in stopping the installation and configuration of the interpreter and the libraries, it is already chewed a lot and there are no pitfalls to me.

As I already wrote, I did not work with Qt before. And the first difficulty was to deal with the widget system, how user interaction is built in general. But in principle, it is quite easy to understand, referring to the examples and documentation.

The next difficulty was to write a simple AI. The idea was spied somewhere in the wilds of the Internet and adapted for reversi.

Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  1. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  2. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  3. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  4. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  5. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  6. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  7. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  8. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  9. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  10. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  11. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  12. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  13. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  14. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  15. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  16. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  17. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  18. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  19. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  20. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  21. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  22. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  23. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  24. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  25. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  26. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  27. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  28. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  29. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  30. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  31. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  32. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  33. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  34. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  35. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player
  36. Copy Source | Copy HTML def compStep (player): table = [ [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 5 , 3 , 1 , 1 , 3 , 5 , 2 ], [ 2 , 6 , 4 , 3 , 3 , 4 , 6 , 2 ], [ 8 , 8 , 6 , 5 , 5 , 6 , 8 , 8 ], [ 1 , 8 , 2 , 2 , 2 , 2 , 8 , 1 ] ] pX = [ 0 ] * 61 pY = [ 0 ] * 61 minE = 9 maxE = 0 NP = 0 for row in range ( 8 ): for col in range ( 8 ): E = eated(row, col, player) if (minE > table[row][col]) & (E < 255 ) & (E > 0 ): minE = table[row][col] NP = 0 maxE = 0 if (minE == table[row][col]) & (E < 255 ): if E > maxE: maxE = E NP = 1 pX[NP] = row pY[NP] = col elif E == maxE: NP = NP + 1 pX[NP] = row pY[NP] = col E = 1 makeStep(player, pX[E], pY[E]) area[pX[E]][pY[E]] = player




Source code, if interested, you can feel for yourself. Who knows, there will be no problems with the launch (you need the pyqt4 library).

http://reversi-free0u.googlecode.com/svn/trunk/main.py



UPDATE: Now the code is available on Github . For performance I can not vouch.



Especially for windows. Exe'shnik.

http://reversi-free0u.googlecode.com/files/Reversi.7z



Packaged with py2exe. I ran into two problems.



First:

First, the images of the cell and the chips in the game were images inserted into the game. And the packaged application did not see them successfully.

The problem was solved simply by drawing images with Qt tools (I was just too lazy to do this initially).



Second:

Successfully packaged application started with me, but refused to work on another computer. After a little search, it turned out that this problem is also easily solved :)

It turned out that there is not enough visual studio libraries.

I have not seriously used Python 2.6 with py2exe, also I have no experience

little experiment showed this approach

(I tested only on XP machines, not Vista!):



I deinstalled python 2.6 (since I had installed it for all users) and

installed it again 'for me only'. This installation copied the msvcr90.dll

and Microsoft.VC90.CRT.manifest files into the c: \ python26 folder.



Then I ran py2exe over a very simple script ('print "Hi"') which created

an executable. This executable worked fine on a machine where msvcr90.dll

was installed in Windows \ SxS (or how it's called), but did NOT run on another

machine where msvcr90.dll is not installed in Windows \ SxS.



Then I copied the msvcr90.dll and Microsoft.VC90.CRT.manifest files into the dist

folder where py2exe had created my executable. Now the exe works on both machines.



WxPython script py2exe crashed because

it tried to load msvcp90.dll (IIRC), but it didn't find it (it seems only to be installed

in the Windows \ SxS folder). This may be a bug in py2exe.
That is the most difficult thing to put to the program library and manifest file.



The main disadvantage is the large size of the resulting application. But there's nothing to be done. All the same, python is an interpreted language.



What gave me this weekend spent on the game?

For this topic I received an invite


Transferred to a collective blog. In this life you have to try everything 8)



upd: slightly changed variable names in sources



upd2: for the afflicted, python version 2.6.4

Source: https://habr.com/ru/post/87009/



All Articles