예제 #1
0
	def doMove(self, current_board, player):
		board = copy.deepcopy(current_board)

		if player == 1: opponent = 2
		else: opponent = 1
		
		node = Node(board, "", 0, player)
			
		node =  self.statespace( node, 0, player, player, opponent);

		bestscore = -100
		wins_score = -1 
		move = 0
		print "New Round"

		for child in node.childs:
			print "Child value=", child.value, "score=", child.wins_score
			if child.value > bestscore:
				if rules.isMoveLegal(board, child.board.last_move):
					bestscore = child.value
					move = child.board.last_move
			elif child.value == bestscore:
				if child.wins_score > wins_score:
					wins_score = child.wins_score
					move = child.board.last_move

		
		
		return move
예제 #2
0
파일: treeai.py 프로젝트: 3D1T0R/4st-attack
    def doMove(self, current_board, player):
        board = copy.deepcopy(current_board)
        # Build tree
        searchtree = []

        node = Node(board, "", 0, player)

        node = self.statespace(node, 0, player)

        print node
        print node.value

        bestscore = -10
        move = 0
        for child in node.childs:
            print "Child value=", child.value
            if child.value > bestscore:
                if rules.isMoveLegal(board, child.board.last_move):
                    bestscore = child.value
                    move = child.board.last_move

        return move

        #while 1:
        #		for move in range(7):
        #print "move", move
        #			if rules.isMoveLegal(board, move):
        #				searchtree.append(self.makeBoard(move, board, player))

        #		for state in searchtree:
        #			for move in range(7):
        #				if rules.isMoveLegal(board, move):
        #	                               state.append(self.makeBoard(move, board, player))
        #		print searchtree

        return 0
예제 #3
0
파일: human.py 프로젝트: laya/gcompris-1
 def setmove(self, trigger, event, number):
     if rules.isMoveLegal(self.board, number):
         self.move = number
         return widget.DONE
예제 #4
0
파일: treeai.py 프로젝트: 3D1T0R/4st-attack
 def listMoves(self, board, player):
     options = []
     for move in range(7):
         if rules.isMoveLegal(board, move):
             options.append(self.makeBoard(move, board, player))
     return options
예제 #5
0
 def doMove(self, board, player):
     while 1:
         move = int(random() * 7)
         if rules.isMoveLegal(board, move):
             return move
예제 #6
0
파일: human.py 프로젝트: GNOME/gcompris
 def setmove(self, trigger, event, number):
   if rules.isMoveLegal(self.board, number):
     self.move = number
     return widget.DONE