Giter Site home page Giter Site logo

javierbyte / clashjs Goto Github PK

View Code? Open in Web Editor NEW
243.0 16.0 85.0 10.23 MB

Javascript AI battle game. Play by creating a javascript function to command your battleship.

Home Page: https://clashjs.com/

License: BSD 3-Clause "New" or "Revised" License

HTML 5.14% JavaScript 89.31% CSS 5.55%
ai game javascript learning battle-game

clashjs's Introduction

Hola, I'm Javier! πŸ‘‹

I'm a Software Developer from MΓ©xico πŸ‡²πŸ‡½ living in Berlin, Germany πŸ‡©πŸ‡ͺ. I enjoy creating frontend experiments, design tools and games. Learn more about my projects on my website javier.xyz.

Recent projects:

  • Brutalita Sans, an experimental monospace font and font editor, edit in your browser and download the font.
  • PINTR, create plotter-like line drawings from your images.
  • Sombras.app, create art with shadows. Play with shadows, lights, 3D objects.

clashjs's People

Contributors

andrew-paymark avatar aspidites avatar codinglogan avatar codingpains avatar danieloram avatar frederickfogerty avatar javierbyte avatar jladuval avatar kiwiandroiddev avatar meelelijan avatar neftaly avatar pandaman4125 avatar psiphi75 avatar qizhiyu avatar ripjaw415 avatar tomachinz 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  avatar

Watchers

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

clashjs's Issues

Are the bots running as web workers?

From the README.md,

We can run the functions as WebWorkers

I was curious about how this is done so I searched through the code but I can't find web workers being used. Am I missing something?

extra player state?

Looking at the overview, and the fact that the AI is run inside a webworker/sandboxed, my naive assumption (I don't know enough about web workers) is that there's no way to store arbitrary states of mind between turns.

Killed and win rate info in Player State

Why the information - killed, death, win rate (the information increased by every new round) aren't included in the Player State? These might be useful, for example, the strategy can be

  1. kill the most dangerous enemy first
  2. avoid the most dangerous enemy first
  3. don't kill the weakest enemy when you have only one ammo
  4. (more)

A more complex Turn Base Mechanism

Just. The game mechanics should avoid to accidentally benefit players by its random nature. The order of execution of the AIs should not benefit any player. The position of the newly create coins should try to be as just for everyone.

This issue targets the constraint:

The game mechanics should avoid to accidentally benefit players by its random nature.

In a nutshell: A Player benefits significantly, when Ammo is dropped the closest to them.

The ClashJS World is too limited and too much information is leaked to a Player through the ai method's arguments. A Player can calculate the best possible series of steps at the beginning of the Game when the first Ammo appears, even if multiple Ammo is dropped, a Player can calculate whether they will survive or stalemate.

A Players set of moves are limited to:

  • Idle
  • Turn (4 possible directions)
  • Move
  • Shoot

However, clearly all moves will attempt to go towards Ammo, a Kill or Evade

  • A move towards Ammo when there is no other player with Ammo, or the number of steps to Ammo without being in danger of other Players who could also reach Ammo, A Player can determine whether they will reach it in time or not.
  • For a Kill to be successful you must be positioned at a vantage point and/or your enemy/target must be positioned at a disadvantage (facing back), otherwise any Player may successfully avoid a Shot.
  • Evade is very powerful, if the Player manages to reach a 1 on 1, they have essentially guaranteed a stalemate unless they where positioned at a disadvantage.

Proposed Solution

Similar to the Finally Fantasy 7 Turn Based Mechanism.

Give each player a Agility property ranging from 0 to 1.

Instead of ordering turns randomly, order them by a Player's Agility value, the one with the highest Agility will move first.

At first, each Players Agility can be subtracted randomly by 0.01 to .2

Have a Base Rate of Recovery for the Agility.
For example: .3 on every new turn.

Give each move a Agility cost. Agility Point = AP
For example:

  • Turn: -.1 AP
  • Move: -.4 AP
  • Shoot: -.2 AP
  • Idle: +.1 AP

Base the ClashJS World around Agility Points.
For example:

  1. A Move costs .-4 AP plus, -.17 x <numberOfAmmo>
  2. A Turn may have an extra -.05 AP cost if it is a 180 degree turn, instead of 90.
  3. Terrain Tiles may add/remove Agility Points to the total Rate of Recovery, and/or add/remove ancost to a move
  4. Recovery/Booster Items, that restore Agility Points.
  5. Per Round/Per Game/Temporary Effect Items that modify the cost for a Player's move, like a Laser Upgrade that reduces its cost or a Rocker Upgrade that reduces the cost to Move.
    For example:
    • A Space Dust Tile adds a 20% increase in the cost to make a Move.
    • A Habitable Planet Tile doubles the Base Rate of Recovery, while a Player remains on the Tile.
    • A Giant Meteor Tile or NP* that simply blocks a Player's movement and Laser Shots.

NP* = Not Player, AI Enemy. Like Playing Mario Smash

I believe this solution will eliminate randomly benefiting Players based on their: initial position and Ammo drop locations.

A Player will not be able to determine another Player's moves with certainty since they may have more Agility Points, and thus evade a Shot at point blank, since they will be able to move more often.

This will effectively force Players to write true AI code, as the complexity that is required to predict a Winning Game, is nearly impossible.

Lets discuss :)

Fail to run the demo

Hello. I can't run the demo. When I run "npm run dev", I get these messages:

lilideMacBook-Air:clashjs lili$ npm run dev

[email protected] dev /Users/lili/code/gameai/clashjs
webpack-dev-server --progress --profile --colors --hot

46% 3/5 build modulesevents.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRNOTAVAIL
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1139:19)
at listen (net.js:1182:10)
at net.js:1280:9
at GetAddrInfoReqWrap.asyncCallback as callback
at GetAddrInfoReqWrap.onlookup as oncomplete

npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dev: webpack-dev-server --progress --profile --colors --hot
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script 'webpack-dev-server --progress --profile --colors --hot'.
npm ERR! This is most likely a problem with the react-hot-boilerplate package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --progress --profile --colors --hot
npm ERR! You can get their info via:
npm ERR! npm owner ls react-hot-boilerplate
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/lili/code/gameai/clashjs/npm-debug.log

The messages in the npm-debug.log are as follows:
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'run', 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink /usr/local/bin/node
5 verbose run-script [ 'predev', 'dev', 'postdev' ]
6 info predev [email protected]
7 info dev [email protected]
8 verbose unsafe-perm in lifecycle true
9 info [email protected] Failed to exec dev script
10 verbose stack Error: [email protected] dev: webpack-dev-server --progress --profile --colors --hot
10 verbose stack Exit status 1
10 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
10 verbose stack at EventEmitter.emit (events.js:110:17)
10 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
10 verbose stack at ChildProcess.emit (events.js:110:17)
10 verbose stack at maybeClose (child_process.js:1015:16)
10 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
11 verbose pkgid [email protected]
12 verbose cwd /Users/lili/code/gameai/clashjs
13 error Darwin 14.5.0
14 error argv "node" "/usr/local/bin/npm" "run" "dev"
15 error node v0.12.4
16 error npm v2.10.1
17 error code ELIFECYCLE
18 error [email protected] dev: webpack-dev-server --progress --profile --colors --hot
18 error Exit status 1
19 error Failed at the [email protected] dev script 'webpack-dev-server --progress --profile --colors --hot'.
19 error This is most likely a problem with the react-hot-boilerplate package,
19 error not with npm itself.
19 error Tell the author that this fails on your system:
19 error webpack-dev-server --progress --profile --colors --hot
19 error You can get their info via:
19 error npm owner ls react-hot-boilerplate
19 error There is likely additional logging output above.
20 verbose exit [ 1, true ]

Could some can tell me how to fix this problem

lack of Information on new round

There is no information for Player to know whether it is a new round or end of current round

why? this is a useful information when it is a new round, everything can be reset.

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.