I am trying to write a Reversi game in Python. Can someone give me some basic ideas and strategies that are simple, good and easy to use?
I would appreciate any help because I went a little far, but got stuck between the codes, and it became more complicated. I think in some part I overdid it, and it was pretty simple. So...
Reversi is an elegantly simple game. I am going to use psuedo C # / Java langauge to explain some concepts, but you can port them to Python.
To break it down into the simplest components, you have two main things:
A 2-dimensional array that represents the playing field:
gameBoard[10,10]
- , :
enum tile { none, white, black }
, gameBoard, :
for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { // The Piece to draw would be at gameBoard[i,j]; // Pixel locations are calculated by multiplying the array location by an offset. DrawPiece(gameBoard[i,j],i * Width of Tile, j * width of tile); } }
, , , , .
, , , , , . ( , .)
, 10 , , . , , .
, .
wikipedia /othello. , - , . , 2- , , , , . , , , , , wikipedia , .
AI , - Alpha-Beta. , ai, , , 8 9 . fancier , negamax negascout, , , . , , AI Othello - . , , Java-. - .
2D-. [[0] * 8] * 8, [[0 _ [0] * 8] _ [0] * 8]
1 -1 ( , ). , * = - 1 , . (, (, ))
,
" " . Reversi/Othello , , .
, , "", , .
. tic-tac-toe -, , , othello, 2 .
/ ?
, PHP, Idea AI , Tic-tac-toe, .
You don't even need a linear array. Two 64-bit java values are enough (one for white fragments, one for black. Assert (white and black) == 0.
You can make the game stronger by counting not pieces that are connected to an angle, but parts that cannot be taken.