Giter VIP home page Giter VIP logo

jsbattle's Introduction

JsBattle - JavaScript Programming Game

Codeship Status for jamro/jsbattle npm version Technical debt License lerna

Screen shot

About

JsBattle is inspired by Robocode. It is a game for JavaScript developers. The goal is to program artificial intelligence of a tank that will destroy all opponents and win the competition.

Demo

Give JsBattle a try and play the demo here: http://jsbattle.jmrlab.com

Documentation

Read more in /packages/jsbattle or at jsbattle.jmrlab.com/docs

jsbattle's People

Contributors

jamro avatar redbugz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsbattle's Issues

The email Regex is not allowing users with '.' in their email to login

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)

team battle

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.

UltimateBattleDescriptor haven't cloned timeLimit

clone() {
let result = new UltimateBattleDescriptor();
result.setRngSeed(this.getRngSeed());
result.setTeamMode(this.getTeamMode());
let aiList = this.getAiList();
let aiClone;
for(let ai of aiList) {
aiClone = ai.clone();
result.addAiDefinition(aiClone);
}
return result;
}

so, createUltimateBattleDescriptor always have zero timeLimit

createUltimateBattleDescriptor() {
if(this._customFinishCondition) {
throw new Error('Cannot create UBD for battles with custom battle finish condition!');
}
return this._ultimateBattleDescriptor.clone();
}

Bullet List -> Bullet Dict

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)

Level 4: Dummy Duel - fails to detect enemy

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
  }
});

choose tanks to battle

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.

Error: No ENV "JSBATTLE_GA_CODE" is defined. Replacement for "GA:XX-XXXXXXXXX-X" in static/index.html cannot be done

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

blockly + shared robots

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 !

League not starting

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 } }

Can'r run in docker?

Tryied different way to dockrize jsbattle server, seems always crash at following place:

image

is there special setting or config we shall be aware of, to make it running in docker?

BTW, we have fixed the --no-sandbox issue.

casper-js tests are not working

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

TypeError: req.logout is not a function

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.