Skip to content

Commit

Permalink
Update UI.js
Browse files Browse the repository at this point in the history
Changed the method to save the genomes, the older didn麓t work.
  • Loading branch information
Eduardo-Morales-Alberti committed Jan 1, 2018
1 parent 8e4fdea commit fcf9ab8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions UI.js
@@ -1,8 +1,8 @@
var contrib = require('blessed-contrib')
var blessed = require('blessed')
var contrib = require('blessed-contrib');
var blessed = require('blessed');
var fs = require('fs');

var screen = blessed.screen()
var screen = blessed.screen();

var UI = {};
var savegame = function(){
Expand Down Expand Up @@ -116,15 +116,20 @@ UI.init = function (gameManipulator, learner) {
align: 'center',
});

UI.btnSave.on('click', savegame())
screen.key(['o','O'], savegame());
UI.btnSave.on('click', function(){
savegame();
});

screen.key(['o','O'], function(){
savegame();
});

screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
});

screen.key(['s'], function (ch, key){
if (learner.state == 'STOP') {
if (learner.state === 'STOP') {
learner.state = 'LEARNING';
gameManipulator.focusGame();
learner.startLearning();
Expand All @@ -133,7 +138,7 @@ UI.init = function (gameManipulator, learner) {
}
});

screen.render()
screen.render();
};


Expand All @@ -149,7 +154,7 @@ UI.refreshFiles = function (){
};

// Populate tree
UI.logger.log('Reading genomes dir...')
UI.logger.log('Reading genomes dir...');
var files = fs.readdirSync('./genomes');
for (var k in files) {
if (files[k].indexOf('.json') >= 0) {
Expand Down Expand Up @@ -192,7 +197,7 @@ UI.render = function () {

if (UI.gm.gameOutput) {
var str = '';
str += 'Action: ' + UI.gm.gameOutputString + '\n'
str += 'Action: ' + UI.gm.gameOutputString + '\n';
str += 'Activation: ' + UI.gm.gameOutput;
UI.uiGenomes.setText(str);
} else {
Expand Down

0 comments on commit fcf9ab8

Please sign in to comment.