@@ -57,17 +57,18 @@ object TicTacToeLearning {
5757 frame.setDefaultCloseOperation(JFrame .EXIT_ON_CLOSE )
5858 frame.setSize(180 , 180 )
5959
60- val ticTacToeWorldTabularBothRandom = new TicTacToeWorld (true , true , true )
61- val ticTacToeWorldNeuralNetBothRandom = new TicTacToeWorld (false , true , true )
62- val ticTacToeWorldTabularRandom = new TicTacToeWorld (true , false , true )
63- val ticTacToeWorldNeuralNetRandom = new TicTacToeWorld (false , false , true )
64- val ticTacToeWorldTabularTabular = new TicTacToeWorld (true , false , false )
65- val ticTacToeWorldNeuralNetNeuralNet = new TicTacToeWorld (false , false , false )
66- val worlds = Array (ticTacToeWorldTabularBothRandom, ticTacToeWorldNeuralNetBothRandom, ticTacToeWorldTabularRandom, ticTacToeWorldNeuralNetRandom, ticTacToeWorldTabularTabular, ticTacToeWorldNeuralNetNeuralNet)
60+ val ticTacToeWorldTabularBothRandom = new TicTacToeWorld (true , true , true , true )
61+ val ticTacToeWorldNeuralNetBothRandom = new TicTacToeWorld (false , false , true , true )
62+ val ticTacToeWorldTabularRandom = new TicTacToeWorld (true , true , false , true )
63+ val ticTacToeWorldNeuralNetRandom = new TicTacToeWorld (false , false , false , true )
64+ val ticTacToeWorldTabularTabular = new TicTacToeWorld (true , true , false , false )
65+ val ticTacToeWorldNeuralNetNeuralNet = new TicTacToeWorld (false , false , false , false )
66+ val ticTacToeWorldNeuralNetTabular = new TicTacToeWorld (false , true , false , false )
67+ val worlds = Array (/* ticTacToeWorldTabularBothRandom, ticTacToeWorldNeuralNetBothRandom, ticTacToeWorldTabularRandom, ticTacToeWorldNeuralNetRandom, ticTacToeWorldTabularTabular, ticTacToeWorldNeuralNetNeuralNet, */ ticTacToeWorldNeuralNetTabular)
6768 for (ticTacToeWorld <- worlds) {
6869 var numberTrainEpisodes = Parameters .tabularNumberTrainEpisodes
6970 val numberTestEpisodes = Parameters .numberTestEpisodes
70- if (ticTacToeWorld.tabular == true ) {
71+ if (ticTacToeWorld.agent1Tabular == true ) {
7172 println(s " === Tabular Q Learning epsilon= ${Parameters .epsilon} alpha= ${Parameters .tabularAlpha}" )
7273 }
7374 else {
@@ -160,7 +161,7 @@ object TicTacToeLearning {
160161 println(s " Playing a training session with ${numberEpisodes} episodes " )
161162 val stats : IndexedSeq [Double ] = IndexedSeq .fill(numberEpisodes){0.0 }
162163 var episodeCounter = 0
163- val ticTacToeWorld = new TicTacToeWorld (tabular, playerXRandom, playerORandom)
164+ val ticTacToeWorld = new TicTacToeWorld (tabular, tabular, playerXRandom, playerORandom)
164165 while (episodeCounter < numberEpisodes) {
165166 stats(episodeCounter) = playEpisode(ticTacToeWorld, epsilon, " X" )
166167 episodeCounter += 1
@@ -211,10 +212,11 @@ object TicTacToeLearning {
211212
212213
213214/** A TicTacToeWorld contains an Agent and an Environment as well as the TicTacToePanel responsible for drawing the two on screen. */
214- class TicTacToeWorld (_tabular : Boolean , agent1Random : Boolean , agent2Random : Boolean ) {
215- def tabular = _tabular
216- val agent1 = new Agent (" X" , _tabular, agent1Random)
217- val agent2 = new Agent (" O" , _tabular, agent2Random)
215+ class TicTacToeWorld (_agent1Tabular : Boolean , _agent2Tabular : Boolean , agent1Random : Boolean , agent2Random : Boolean ) {
216+ def agent1Tabular = _agent1Tabular
217+ def agent2Tabular = _agent2Tabular
218+ val agent1 = new Agent (" X" , agent1Tabular, agent1Random)
219+ val agent2 = new Agent (" O" , agent2Tabular, agent2Random)
218220 val agents = List (agent1, agent2)
219221 val environment = new Environment (agent1, agent2)
220222 val ticTacToePanel = new TicTacToePanel (this )
0 commit comments