Fix some bugs
This commit is contained in:
parent
85ddb7b80f
commit
01001d94f2
|
@ -17,6 +17,11 @@
|
|||
"@types/babel-types": "*"
|
||||
}
|
||||
},
|
||||
"abbrev": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
||||
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
|
||||
},
|
||||
"accepts": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
|
||||
|
@ -630,6 +635,14 @@
|
|||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
|
||||
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
|
||||
},
|
||||
"nopt": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz",
|
||||
"integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=",
|
||||
"requires": {
|
||||
"abbrev": "1"
|
||||
}
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
|
@ -999,6 +1012,14 @@
|
|||
"resolved": "https://registry.npmjs.org/token-stream/-/token-stream-0.0.1.tgz",
|
||||
"integrity": "sha1-zu78cXp2xDFvEm0LnbqlXX598Bo="
|
||||
},
|
||||
"touch": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
|
||||
"integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
|
||||
"requires": {
|
||||
"nopt": "~1.0.10"
|
||||
}
|
||||
},
|
||||
"traverse": {
|
||||
"version": "0.3.9",
|
||||
"resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"express": "^4.16.4",
|
||||
"express-fileupload": "^1.1.3-alpha.1",
|
||||
"pug": "^2.0.3",
|
||||
"touch": "^3.1.0",
|
||||
"unzip": "^0.1.11"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ for real_ai in ai_manager.__all__:
|
|||
# It is made to be fast and not to be used by humans. It especially doesn't
|
||||
# display and window and doesn't listen to any keystrokes.
|
||||
|
||||
width = 40
|
||||
height = 40
|
||||
width = 10
|
||||
height = 10
|
||||
|
||||
def run_battle(ai1, ai2):
|
||||
games = 50
|
||||
|
|
33
server.js
33
server.js
|
@ -3,16 +3,17 @@ const fs = require('fs');
|
|||
const process = require('process');
|
||||
const pathtools = require('path');
|
||||
const express = require('express');
|
||||
const fileUpload = require("express-fileupload");
|
||||
const fileUpload = require('express-fileupload');
|
||||
const { spawn } = require('child_process');
|
||||
const pug = require('pug');
|
||||
const unzip = require('unzip');
|
||||
const touch = require('touch');
|
||||
|
||||
// Consts
|
||||
const port = 8000;
|
||||
const pythonPath = "/home/pytron/miniconda3/envs/pytron/bin/python"
|
||||
const aisPath = "pytron_run/ai_manager/"
|
||||
const aisPathOld = "pytron_run/ai_manager_old"
|
||||
const pythonPath = '/home/pytron/miniconda3/envs/pytron/bin/python'
|
||||
const aisPath = 'pytron_run/ai_manager/'
|
||||
const aisPathOld = 'pytron_run/ai_manager_old'
|
||||
|
||||
// Create the directories to store the files
|
||||
try { fs.mkdirSync(aisPath); } catch { }
|
||||
|
@ -35,19 +36,19 @@ function runPython() {
|
|||
p.stdout.on('data', (data) => {
|
||||
let content = data.toString().split('\n');
|
||||
for (let line of content) {
|
||||
console.log("run.py: " + line);
|
||||
console.log('run.py: ' + line);
|
||||
}
|
||||
});
|
||||
|
||||
p.stderr.on('data', (data) => {
|
||||
let content = data.toString().split('\n');
|
||||
for (let line of content) {
|
||||
console.log("run.py: " + line);
|
||||
console.log('run.py: ' + line);
|
||||
}
|
||||
});
|
||||
|
||||
p.on('close', (code) => {
|
||||
process.stdout.write("Python finished executing");
|
||||
process.stdout.write('Python finished executing');
|
||||
if (pythonShouldRun) {
|
||||
process.stdout.write(' but another request arrive, so we will relaunch it\n');
|
||||
pythonShouldRun = false;
|
||||
|
@ -111,7 +112,10 @@ function startServer() {
|
|||
console.log(err);
|
||||
}
|
||||
let parsed = parse(data);
|
||||
res.render('index', parsed);
|
||||
res.render('index', {
|
||||
data: parsed,
|
||||
running: pythonRunning,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -147,15 +151,20 @@ function startServer() {
|
|||
|
||||
fs.mkdirSync(path);
|
||||
|
||||
let zipfile = pathtools.join(path, "archive.zip");
|
||||
let zipfile = pathtools.join(path, 'archive.zip');
|
||||
req.files.archive.mv(zipfile, (err) => {
|
||||
if (err !== null) {
|
||||
console.log(err);
|
||||
}
|
||||
fs.createReadStream(zipfile)
|
||||
.pipe(unzip.Extract({path}))
|
||||
.on('close', () => {
|
||||
// Touch __init__.py
|
||||
touch(pathtools.join(path, '__init__.py'), () => {
|
||||
// Trigger python_run
|
||||
runPython();
|
||||
res.send('yo');
|
||||
res.redirect('/');
|
||||
});
|
||||
})
|
||||
.on('error', () => {
|
||||
res.send('an error occured while extracting the archive')
|
||||
|
@ -179,8 +188,8 @@ function main() {
|
|||
runPython();
|
||||
break;
|
||||
default:
|
||||
console.log("Unknown option: " + process.argv[2]);
|
||||
console.log("Usage: node server.js start|python")
|
||||
console.log('Unknown option: ' + process.argv[2]);
|
||||
console.log('Usage: node server.js start|python')
|
||||
process.exit(1);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -3,25 +3,29 @@ extends base
|
|||
block content
|
||||
section.section
|
||||
.container
|
||||
if running
|
||||
.columns.is-centered
|
||||
.column.is-narrow.is-desktop
|
||||
h5.title.is-5 Some battles are running...
|
||||
.columns.is-centered
|
||||
.column.is-narrow.is-desktop
|
||||
table.table.is-bordered.is-striped.is-narrow.is-hoverable
|
||||
tr
|
||||
th
|
||||
for ai in ais
|
||||
for ai in data.ais
|
||||
th.has-text-centered= ai.name
|
||||
for ai1 in ais
|
||||
for ai1 in data.ais
|
||||
tr
|
||||
th.has-text-centered= ai1.name
|
||||
for ai2 in ais
|
||||
for ai2 in data.ais
|
||||
if ai1.name == ai2.name
|
||||
td
|
||||
else if battles[ai1.name + "/" + ai2.name] > battles[ai2.name + "/" + ai1.name]
|
||||
td.has-text-success= battles[ai1.name + "/" + ai2.name]
|
||||
else if battles[ai1.name + "/" + ai2.name] < battles[ai2.name + "/" + ai1.name]
|
||||
td.has-text-danger= battles[ai1.name + "/" + ai2.name]
|
||||
else if data.battles[ai1.name + "/" + ai2.name] > data.battles[ai2.name + "/" + ai1.name]
|
||||
td.has-text-success= data.battles[ai1.name + "/" + ai2.name]
|
||||
else if data.battles[ai1.name + "/" + ai2.name] < data.battles[ai2.name + "/" + ai1.name]
|
||||
td.has-text-danger= data.battles[ai1.name + "/" + ai2.name]
|
||||
else
|
||||
td= battles[ai1.name + "/" + ai2.name]
|
||||
td= data.battles[ai1.name + "/" + ai2.name]
|
||||
.column.is-narrow.is-desktop
|
||||
table.table.is-bordered.is-striped.is-hoverable
|
||||
tr
|
||||
|
@ -30,7 +34,7 @@ block content
|
|||
th.has-text-centered Nulls
|
||||
th.has-text-centered Defeats
|
||||
th.has-text-centered Score
|
||||
for ai in sortedAis
|
||||
for ai in data.sortedAis
|
||||
tr
|
||||
td.has-text-centered
|
||||
strong= ai.name
|
||||
|
|
Loading…
Reference in New Issue