Skip to content

Commit

Permalink
Fix bugs, update players styles and AI, better UI
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbyte committed Feb 7, 2016
1 parent 20106ed commit 7444c5e
Show file tree
Hide file tree
Showing 32 changed files with 41,291 additions and 36,784 deletions.
75,864 changes: 40,295 additions & 35,569 deletions dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions index.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<head> <head>
<meta charset='UTF-8'> <meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1, user-scalable=no'> <meta name='viewport' content='width=device-width, initial-scale=1, user-scalable=no'>

<title>ClashJS | AI Javascript Battle Game</title> <title>ClashJS | AI Javascript Battle Game</title>
<meta name='description' content='Javascript artificial intelligence battle game. Create a spaceship AI and kill your enemies!'>
<meta property='og:image' content='https://github.com/javierbyte/clashjs/raw/master/spec_assets/screenshot.jpg'/>

<link rel='stylesheet' href='styles.css'> <link rel='stylesheet' href='styles.css'>
<link href='favicon.ico' rel='icon' type='image/x-icon' /> <link href='favicon.ico' rel='icon' type='image/x-icon' />
</head> </head>
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
"homepage": "https://github.com/javierbyte/clashjs", "homepage": "https://github.com/javierbyte/clashjs",
"devDependencies": { "devDependencies": {
"babel-core": "^5.4.7", "babel-core": "^5.4.7",
"babel-eslint": "^3.1.9",
"babel-loader": "^5.1.2", "babel-loader": "^5.1.2",
"eslint-plugin-react": "^2.3.0",
"react-hot-loader": "^1.2.7", "react-hot-loader": "^1.2.7",
"standard": "^6.0.3",
"webpack": "^1.9.6", "webpack": "^1.9.6",
"webpack-dev-server": "^1.8.2" "webpack-dev-server": "^1.8.2"
}, },
"dependencies": { "dependencies": {
"eslint": "^1.1.0",
"eslint-plugin-react": "^2.7.1",
"lodash": "^3.10.0", "lodash": "^3.10.0",
"react": "^0.13.0", "react": "^0.13.0",
"seedrandom": "^2.4.2" "seedrandom": "^2.4.2"
Expand Down
17 changes: 9 additions & 8 deletions src/Players.js
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,11 @@
module.exports = { module.exports = {
javierbyte: require('./players/javierbyte.js'), codingpains: require('./players/codingpains.js'),
manuelmhtr: require('./players/manuelmhtr.js'),
// ericku: require('./players/ericku.js'),
// siegfried: require('./players/siegfried.js'),
horror: require('./players/horror.js'), horror: require('./players/horror.js'),
jgroom33: require('./players/jgroom33.js'), elperron: require('./players/elperron.js'),
will3: require('./players/will3.js'), yuno: require('./players/yuno.js'),
tomachi: require('./players/tomachi.js'), xmontoya: require('./players/xmontoya.js'),
mel: require('./players/mel.js'), margeux: require('./players/margeux.js')
merica: require('./players/merica.js'), }
astaroth: require('./players/astaroth.js')
};
15 changes: 3 additions & 12 deletions src/clashjs/ClashCore.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var DIRECTIONS = ['north', 'east', 'south', 'west'];


class ClashJS { class ClashJS {
constructor(playerDefinitionArray, currentStats, evtCallback) { constructor(playerDefinitionArray, currentStats, evtCallback) {
this._totalRounds = playerDefinitionArray.length * 5; this._totalRounds = playerDefinitionArray.length * 2 + 5;
this._rounds = 0; this._rounds = 0;
this._gameStats = currentStats || {}; this._gameStats = currentStats || {};
this._evtCallback = evtCallback; this._evtCallback = evtCallback;
Expand Down Expand Up @@ -83,9 +83,8 @@ class ClashJS {
if (this._sudeenDeathCount > (250 * this._alivePlayerCount)) { if (this._sudeenDeathCount > (250 * this._alivePlayerCount)) {
this._handleCoreAction('DRAW'); this._handleCoreAction('DRAW');
return this._evtCallback('DRAW'); return this._evtCallback('DRAW');
// return this.getState();
} }
let clonedStates = _.clone(this._playerStates, true); let clonedStates = _.cloneDeep(this._playerStates, true);
if (this._alivePlayerCount <= 3) { if (this._alivePlayerCount <= 3) {
this._sudeenDeathCount++; this._sudeenDeathCount++;
} }
Expand All @@ -96,19 +95,12 @@ class ClashJS {
}); });


if (this._playerStates[this._currentPlayer].isAlive) { if (this._playerStates[this._currentPlayer].isAlive) {

console.info({
userState: clonedStates[this._currentPlayer],
enemiesState: otherPlayers,
gameEnv: _.clone(this._gameEnvironment, true)
})

this._savePlayerAction( this._savePlayerAction(
this._currentPlayer, this._currentPlayer,
this._playerInstances[this._currentPlayer].execute( this._playerInstances[this._currentPlayer].execute(
clonedStates[this._currentPlayer], clonedStates[this._currentPlayer],
otherPlayers, otherPlayers,
_.clone(this._gameEnvironment, true) _.cloneDeep(this._gameEnvironment, true)
) )
); );
} }
Expand Down Expand Up @@ -152,7 +144,6 @@ class ClashJS {
let {wins, winrate} = playerStats; let {wins, winrate} = playerStats;
playerStats.winrate = Math.round(wins * 100 / this._rounds); playerStats.winrate = Math.round(wins * 100 / this._rounds);
}); });
console.log(this._playerStates);
if (this._rounds >= this._totalRounds) {return this._evtCallback('END');} if (this._rounds >= this._totalRounds) {return this._evtCallback('END');}
} }
} }
Expand Down
Loading

0 comments on commit 7444c5e

Please sign in to comment.