Search

Monday, August 13, 2012

Day 5: Starting the engine.



Well, this post will be like thinking loud.


  • First I will need a method play for the engine. It will need a board as a parameter. This method will return an integer that will have the position where it should play.
  • Then it should see what possible moves are (all where the state is 0). For this I will create a method getPossibleMoves, and will have the board as the only parameter.
  • Finally the engine will select one position randomly and play it. So I will create another method makeMove with the array of possible moves.
  • the mainloop of the game should receive the move and send it to the board that should have a setMove method with the integer of the position and the "color" integer.
First, the creation of the play method. It should receive the board.


Let's start with the method getPossibleMoves, this method will return an array of integers. Those integers should be the different positions. This method will be in the Actors class, because it will be taken both from the engine and from the human player.

 

Well, now I have all the possible moves and the machine have to pick one and return the number. For now it will be a random number.

 

 Now in the board a setMove method is needed. It will take an integer with the position and the color and put the stone in the board



And now, the mainLoop's method startGame:




And here we are:

9x9:

19x19:





No comments:

Post a Comment