jamro / jsbattle Goto Github PK
View Code? Open in Web Editor NEWJavaScript Programming Game (inspired by RoboCode)
Home Page: http://jsbattle.jmrlab.com
License: MIT License
JavaScript Programming Game (inspired by RoboCode)
Home Page: http://jsbattle.jmrlab.com
License: MIT License
It would make debugging a bit easier if UI remembered "Debug View" and "Tempo" options after refreshing the page :)
Hi, I'm planning to use jsbattle for my introductory programming courses. For this, I would like to add two features : one would be to add a Blockly editor below the regular one and the other one would be to make localy created tanks available for all connected students. I'm able to customize Blockly for it to generate correct AI scripts, but wondering if anyone has suggestions about the best way to go for integration, and also about making tanks persistents... Thank you for any help !
jsbattle/packages/jsbattle-engine/src/engine/UltimateBattleDescriptor.js
Lines 109 to 120 in 57cf4a4
so, createUltimateBattleDescriptor
always have zero timeLimit
jsbattle/packages/jsbattle-engine/src/engine/Simulation.js
Lines 432 to 437 in 57cf4a4
It would be great to have the ability to choose tanks for the battle from the list. Especially when we had lots of tanks programmed.
Reported in #24 by Lapin-Blanc
Hi again, well, I just tried to build the project (without any modifications), and already getting some errors. What I've done
git clone https://github.com/jamro/jsbattle.git
cd jsbattle
npm install
npm run build
at the end of the build process, I get this error
jsbattle-webpage: Error: No ENV "JSBATTLE_GA_CODE" is defined. Replacement for "GA:XX-XXXXXXXXX-X" in static/index.html cannot be done
I've also tried with the bundled .tar.gz (latest version)
npm version is 6.9.0
start a battle with dummy and kamikaze. watch state object of dummy in debug view. whenever dummy is hit by kamikaze, state.collisions.enemy is still set to false
execution of gulp test
returns:
[08:45:49] Starting 'webpage.test'...
[08:45:49] Test Server started http://localhost:8070
[08:45:50] 'webpage.test' errored after 500 ms
[08:45:50] Error in plugin 'gulp-casperjs-local'
Message:
1
[08:45:50] 'test' errored after 6.11 s
[08:45:50] Error in plugin 'gulp-casperjs-local'
Message:
1
[08:45:50] Test Server stopped
It would be great to have team battle available. There should be statistic form each fight visible after each round - each tank score could be sum-up to discover the team winner.
Only "dummy" works, rest of the bots returns error now.
http://jsbattle.jmrlab.com/
this regex: ^[\w-]+@([\w-]+.)+[\w-]+$
this email: [email protected] won't work.
this stackoverflow questions contains a better regex:
https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript
stack trace:
(node:13902) UnhandledPromiseRejectionWarning: ValidationError: Entity validation error!
at Service.settings.entityValidator (/home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/moleculer-db/src/index.js:951:28)
at /home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/moleculer-db/src/index.js:669:76
at Array.map ()
at Service.validateEntity (/home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/moleculer-db/src/index.js:669:32)
at Service._create (/home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/moleculer-db/src/index.js:787:16)
at Service.handler (/home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/moleculer-db/src/index.js:220:17)
at /home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/moleculer/src/utils.js:182:22
at /home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/jsbattle-server/app/lib/auditMiddleware.js:7:16
at /home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/moleculer/src/middlewares/action-hook.js:91:23
at Service.module.exports (/home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/jsbattle-server/app/services/userStore/actions/findOrCreate.js:44:14)
at /home/ubuntu/.nvm/versions/node/v14.15.1/lib/node_modules/jsbattle/node_modules/jsbattle-server/app/services/apiGateway/lib/configPassport.js:86:20
(node:13902) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 25072)
HI, just wondering whether it would be a better idea to replace bullet list with bullet dict.
As a game session progresses, the bullet list is becoming larger. In theory, the penlty of the for loop also becomes larger.
Changing to dict may slightly improve the performance (according to my not-at-all-scientifc benchmark)
Generate changelog automatically https://github.com/semantic-release/semantic-release
I didn't see it in the documentation, so I don't know if it is a doc missing or a feature request...
Is it possible to inject my own tank from either another location (local folder or a github repository)?
How could I share my tank to run somewhere else (at friends) ?
Hi there!
I have an issue that league is not running. Seems to be scheduled, but the queue is not processed and queue reaches configured limit.
[2022-10-05T18:26:00.847Z] DEBUG gateway-jsbattle-cluster-333444/BROKER: Call action locally. { action: 'leagueScheduler.scheduleBattle', requestID: '14a0b730-624c-4a59-92cb-6ac0921b5850' } [2022-10-05T18:26:00.847Z] DEBUG gateway-jsbattle-cluster-333444/BROKER: Call action locally. { action: 'league.pickRandomOpponents', requestID: '14a0b730-624c-4a59-92cb-6ac0921b5850' } [2022-10-05T18:26:00.847Z] DEBUG gateway-jsbattle-cluster-333444/BROKER: Call action locally. { action: 'league.get', requestID: '14a0b730-624c-4a59-92cb-6ac0921b5850' } [2022-10-05T18:26:00.848Z] DEBUG gateway-jsbattle-cluster-333444/BROKER: Call action locally. { action: 'league.get', requestID: '14a0b730-624c-4a59-92cb-6ac0921b5850' } [2022-10-05T18:26:00.849Z] DEBUG gateway-jsbattle-cluster-333444/BROKER: Call action locally. { action: 'queue.write', requestID: '14a0b730-624c-4a59-92cb-6ac0921b5850' } [2022-10-05T18:26:00.849Z] DEBUG gateway-jsbattle-cluster-333444/LEAGUESCHEDULER: Unable to schedule battle: Requested limit of 5 items exceeded for topic ubdPlayer
What can be a reason? Where should I look at? Probably workers are for some reason not running, but I am not sure how to check it (e.g. what the expected process should be called).
Here is my config.json:
{ "loglevel": "debug", "skipEnv": false, "cluster": { "enabled": true, "name": "jsbattle-cluster", "transporter": { "type": "TCP", "options": { "udpDiscovery": true } } }, "data": { "adapter": "nedb", "path": "./jsbattle-data" }, "web": { "host": "0.0.0.0", "baseUrl": "https://BBB", "corsOrigin": [ "https://BBB" ] }, "auth": { "admins": [ { "provider": "github", "username": "XXX" } ], "providers": [ { "name": "github", "clientID": "XXX", "clientSecret": "YYY" } ] }, "league": { "scheduleInterval": 30000, "timeLimit": 20000, "teamSize": 3, "obfuscate": true, "historyDuration": 259200000, "cutOffFightCount": 100, "cutOffWinRatio": 0.05 }, "ubdPlayer": { "queueLimit": 5, "queueQueryTime": 5000, "speed": 1, "timeout": 60000 }, "battleStore": { "defaultExpireTime": 604800000, "cleanupInterval": 3600000 } }
When trying to logout, the page displays a white page and an error prompt as stated above
Error:
TypeError: req.logout is not a function at /home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/jsbattle-server/app/services/apiGateway/lib/configPassport.js:108:11 at Layer.handle [as handle_request] (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/layer.js:95:5) at next (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/layer.js:95:5) at /home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/index.js:341:12) at next (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/index.js:275:10) at initialize (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/passport/lib/middleware/initialize.js:89:5) at Layer.handle [as handle_request] (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/index.js:323:13) at /home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/index.js:341:12) at next (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/index.js:275:10) at cookieParser (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/cookie-parser/index.js:71:5) at Layer.handle [as handle_request] (/home/lukilukeskywalker/.nvm/versions/node/v12.2.0/lib/node_modules/jsbattle/node_modules/express/lib/router/layer.js:95:5)
Any Idea of how to record battle server side and be able to broadcast later for replay on client browser ?
The goal would be to get a server where to perform battle to allow leaderboard and avoid cheating.
Note : Amazing job. The best robojs on github.
The battle instructions say:
Time for the first duel! The opponent is not difficult - it will stand still and wait for you. You just need to find and destroy it.
I have tested it with the script from https://jsbattle.jmrlab.com/docs/manual/algorithms_aiming.html#put-everything-together
importScripts('lib/tank.js')
tank.init(function(settings, info) {
});
tank.loop(function(state, control) {
if(!state.radar.enemy) {
control.RADAR_TURN = 1
} else {
control.RADAR_TURN = 0
control.SHOOT = 1
let targetAngle = Math.deg.atan2(state.radar.enemy.y - state.y, state.radar.enemy.x - state.x)
let radarAngle = Math.deg.normalize(targetAngle - state.angle)
let radarAngleDiff = Math.deg.normalize(radarAngle - state.radar.angle)
control.RADAR_TURN = 0.3 * radarAngleDiff
let bodyAngleDiff = Math.deg.normalize(targetAngle - state.angle)
control.TURN = 0.5 * bodyAngleDiff
let targetDistance = Math.distance(state.x, state.y, state.radar.enemy.x, state.radar.enemy.y)
let distanceDiff = targetDistance - 150
control.THROTTLE = distanceDiff/100
let gunAngle = Math.deg.normalize(targetAngle - state.angle)
let gunAngleDiff = Math.deg.normalize(gunAngle - state.gun.angle)
control.GUN_TURN = 0.3 * gunAngleDiff
}
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.