Initial commit

parents
'use strict';
const fs = require('fs');
const solutionFile = process.argv[2];
if(!solutionFile)
process.exit(1);
try
{
let solution = JSON.parse(fs.readFileSync(solutionFile).toString("utf8"));
let version = solution.solutionVersion;
const pm = require(`./pm_cores/pm-core-v${version}.min.js`);
pm.loadClassMapping();
let level = new pm.Class();
level = level.deserialize(solution.level, true);
let rm = new pm.RobotManager();
level.programDataCache = solution.solution;
level.load(false);
for (let map of level.maps)
map.spawnObjects();
level.activeMap.placeRobots(true);
rm.setLevel(level);
rm.testAllMapsSync();
if (rm.isWin)
{
process.exit(0);
}
else
{
process.exit(1);
}
}
catch (e)
{
console.log(`Work error: ${JSON.stringify(e)}`);
process.exit(1);
}
{
"name": "pm-core-runner",
"version": "1.0.0",
"author": "Nikita Besshaposhnikov",
"description": "PiktoMir core module runner",
"private": true,
"scripts": {
"test": "NODE_ENV=production node main.js test-solution.json"
},
"dependencies": {
},
"license": "MIT"
}
{"level":{"typeName":"RepairLevel","order":0,"name":"Задание 1","isTutorial":false,"tutorialScenario":{},"startRobotIndex":0,"robots":[{"typeName":"RepairRobot","useGreyCondition":false,"useLightBlueCondition":true,"useBlueCondition":true,"canBeIndicated":false,"id":0,"groupID":0,"childRobotID":-1,"currentMap":0,"state":0}],"programData":{"0":{"typeName":"ProgramData","canEditProgramPattern":false,"width":2,"height":6,"symbols":[[{"type":0,"value":"empty"},{"type":0,"value":"empty"}],[{"type":0,"value":"empty"},{"type":0,"value":"empty"}],[{"type":0,"value":"empty"},{"type":0,"value":"empty"}],[{"type":0,"value":"empty"},{"type":0,"value":"empty"}],[{"type":0,"value":"empty"},{"type":0,"value":"empty"}],[{"type":0,"value":"empty"},{"type":0,"value":"empty"}]]},"typeName":"map"},"globalRobotConfig":{"typeName":"map"},"maps":[{"typeName":"RepairMap","editWalls":true,"width":10,"height":5,"tileset":0,"mapElements":[[{"typeName":"RepairMapElement","walls":[false,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,true],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,false,true],"originalType":0,"startForRobot":-1,"startRobotData":{}}],[{"typeName":"RepairMapElement","walls":[false,true,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,true],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,true,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,true],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,true,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,false,true],"originalType":0,"startForRobot":-1,"startRobotData":{}}],[{"typeName":"RepairMapElement","walls":[false,true,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,true,false,true],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,true],"originalType":2,"startForRobot":0,"startRobotData":{"direction":0}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":2,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":2,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":2,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":2,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,true,true,false],"originalType":2,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,true,false,true],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,false,true],"originalType":0,"startForRobot":-1,"startRobotData":{}}],[{"typeName":"RepairMapElement","walls":[false,true,false,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,false,true],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,true,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,true],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,false,true,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[true,true,false,false],"originalType":1,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,false,true],"originalType":0,"startForRobot":-1,"startRobotData":{}}],[{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,false],"originalType":0,"startForRobot":-1,"startRobotData":{}},{"typeName":"RepairMapElement","walls":[false,false,true,true],"originalType":0,"startForRobot":-1,"startRobotData":{}}]],"objects":[]}],"startMapIndex":0,"taskList":{"typeName":"TaskList","tasks":{"typeName":"map","repair":{"typeName":"RepairTask","data":{"0":6}}}},"hint":{"typeName":"GlobalHint","text":""},"useMethodStack":true,"useProgramRecognizer":true,"isProgramDataEditable":true,"hash":1452785831969,"robotManagers":[],"id":"5a9674b2b0fa82269e27974d","version":16,"revision":1},"solution":{"0":{"typeName":"ProgramData","canEditProgramPattern":false,"width":2,"height":6,"symbols":[[{"type":0,"value":"r4_turn_left"},{"type":0,"value":"rep_repair"}],[{"type":0,"value":"r4_move"},{"type":0,"value":"rep_repair"}],[{"type":0,"value":"r4_move"},{"type":0,"value":"rep_repair"}],[{"type":0,"value":"r4_move"},{"type":0,"value":"rep_repair"}],[{"type":0,"value":"r4_move"},{"type":0,"value":"rep_repair"}],[{"type":0,"value":"r4_move"},{"type":0,"value":"rep_repair"}]]},"typeName":"map"},"solutionVersion":16}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment