Esempio n. 1
0
def play(B):
	n = 1
	b = Board()

	while n:
		b.showBoard()
		moves = b.generateMoveStrings()
		print(moves)
		while True:
			move = input("Enter move:")
			#b.showBoard()
			if move in moves:
				b.makeMove(move)
				break

		if b.isCheckMate():
			b.showBoard()
			b.unMove()
			B.getReward(0)
			B.resetState()
			b = Board()
			n = int(input("Play again (1/0) :"))
			if n == 0:
				break
			else:
				continue
			
		if b.isDraw():
			b.showBoard()
			b.unMove()
			W.getReward(0.3)
			W.resetState()
			B.getReward(0.4)
			B.resetState()
			b = Board()
			n = int(input("Play again (1/0) :"))
			if n == 0:
				break
			
		B.makeMove(b)
		#b.showBoard()
		if b.isCheckMate():
			b.showBoard()
			B.getReward(1)
			B.resetState()
			b = Board()
			n = int(input("Play again (1/0) :"))
			
		if b.isDraw():
			b.showBoard()
			B.getReward(0.4)
			B.resetState()
			b = Board()
			n = int(input("Play again (1/0) :"))
Esempio n. 2
0
    def play(self, B):  #black agent
        n = 1
        b = Board()

        while n:
            b.showBoard()
            moves = b.generateMoveStrings()
            print(moves)
            while True:
                move = input("Enter move:")
                #b.showBoard()
                if move in moves:
                    b.makeMove(move)
                    break

            if b.isCheckMate():
                b.showBoard()
                b.unMove()
                b = Board()
                n = int(input("Play again (1/0) :"))
                if n == 0:
                    break
                else:
                    continue

            if b.isDraw():
                b.showBoard()
                b.unMove()
                b = Board()
                n = int(input("Play again (1/0) :"))
                if n == 0:
                    break

            B.makeMoveUtil(b, 1)
            #b.showBoard()
            if b.isCheckMate():
                b.showBoard()
                b = Board()
                n = int(input("Play again (1/0) :"))

            if b.isDraw():
                b.showBoard()
                b = Board()
                n = int(input("Play again (1/0) :"))