-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
52 lines (39 loc) · 1.88 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from game import Game
from player import Player
from gameController import GameController
from rnnModel import ConnectFourModelRNN
from nnModel import ConnectFourModelNN
playerOneVal= -1
playerTwoVal = 1
def main():
firstGame = Game()
secondGame = Game()
thirdGame = Game()
fourthGame = Game()
#create players
print("Creating Players")
playerOne = Player(playerOneVal, strategy='random')
playerTwo = Player(playerTwoVal, strategy='random')
playerThree = Player(playerOneVal, strategy='random')
playerFour = Player(playerTwoVal, strategy='random')
#get training data
print("Creating Training Data")
gameControllerNN = GameController(firstGame, playerOne, playerTwo)
gameControllerNN.simulateManyGames(14500)
gameControllerRNN = GameController(secondGame, playerThree, playerFour)
gameControllerRNN.simulateManyGames(13000)
NNmodel = ConnectFourModelNN(42, 3, 50, 100)
NNmodel.train(gameControllerNN.getTrainingHistory())
RNNmodel = ConnectFourModelRNN(42, 3, 50, 100)
RNNmodel.train(gameControllerRNN.getTrainingHistory())
#Create the Deep Q-Learning Agents
print("Creating Agents")
playerOneNeural = Player(playerOneVal, strategy='model', model = NNmodel,predicting = True)
playerTwoRNN = Player(playerTwoVal, strategy='model', model = RNNmodel, predicting = True)
#Play the game
gameControllerFinal = GameController(thirdGame,playerOneNeural,playerTwoRNN)
print("Playing 500 Games: Deep Q-Learrning with MLP as first player and Deep Q-Learning with RNN as second player")
gameControllerFinal.simulateManyGames(500)
gameControllerFinal = GameController(fourthGame, playerTwoRNN, playerOneNeural)
print("Playing 500 Games: Deep Q-Learrning with RNN as first player and Deep Q-Learning with MLP as second player")
gameControllerFinal.simulateManyGames(500)