Permalink
Browse files

Merge pull request #1 from superjoe30/master

fixed color enum.
  • Loading branch information...
2 parents ca06d82 + 931a3e0 commit 174c9716288824116d819f9fd5b03180f6a1d491 @thejoshwolfe committed Jun 2, 2011
Showing with 32 additions and 1 deletion.
  1. +31 −0 andyai/andyai.go
  2. +1 −1 blokus.go
View
@@ -0,0 +1,31 @@
+package andyai
+
+// TODO: move this to blokus package that andyai imports
+type BlokusState struct {
+ WhoseTurn int // which player the game is waiting on
+ [][]int Board // 2d grid of colored cells
+ [4][]int PiecesLeft // for each player, list of pieces left
+}
+
+func TakeTurn(BlokusState state) {
+ // returns move, heuristic score for each player
+ func getBestMove(BlokusState state) {
+ list_of_possible_moves := generateMoveList(state, state.WhoseTurn)
+ best_score := nil
+ best_move := nil
+ for move in list_of_possible_moves {
+ test_board = doMove(test_board, move)
+ while not gameOver(test_board) {
+ enemy_move = getBestMove(test_board)
+ test_board = doMove(test_board, enemy_move)
+ }
+ board_score = boardScore(test_board)
+ if best_score == nil || board_score > best_score {
+ best_score = board_score
+ best_move = move
+ }
+ }
+ }
+ best_move, scores = getBestMove(state)
+ return best_move
+}
View
@@ -4,7 +4,7 @@ const BoardSize = 20
// order of players
const (
- Blue = 0
+ Blue = iota
Yellow
Red
Green

0 comments on commit 174c971

Please sign in to comment.