New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature(HERO) Add randomly selected standard AI to bots #26
Feature(HERO) Add randomly selected standard AI to bots #26
Conversation
Note: I have been unable to configure my pc to run |
Thanks so much for the contribution! Looking through the code, everything looks good, but I think that public/js/game/Game.js still needs to be changed to make this all come together. So, if you can make some changes there incorporating what you have already done, we can take a look then and see if it works. |
I'm a bit confused about what you are asking to have changed. 119 Hero.prototype.move = function(gameData, helpers) {
120 // Select a random brain for this hero
121 var brains = Object.keys(Hero.brains);
122 this.move = Hero.brains[brains[ brains.length * Math.random() << 0 ]];
123 return this.move(gameData, helpers);
124 }; This is the move function. It is a lazy loader that will choose a random brain the first time it is called and then replace 79 var botsFunction = gameData.activeHero.move;
80 var botsMove = botsFunction(gameData, helpers);
81 handleHeroTurn.call(gameData, botsMove);
82 this.clientSideGame[turnKeeper] = JSON.parse(JSON.stringify(gameData)); This is the modified bit in Game.js. Here the bot's I haven't been able to get bower to install and
Installing bower gives many pages worth of similar errors. I am on Win 8.1. If you have any ideas on how to resolve this, please let me know! |
There seems to be some helpful solutions here, npm/npm#3664 |
🤦 My version of NPM was pretty old. I updated it and life is better. |
Everything checks out. I might suggest a future enhancement of changing the bot names from "Random" to the selected brain. |
DOH! |
They are removed now. |
Awesome. Thank you! |
Feature(HERO) Add randomly selected standard AI to bots
Testing against real competition is much more useful than just all Blind Men. This branch adds
Hero.prototype.move()
and 'Hero.brains' topublic/game_classes/Hero.js'. When
moveis called it randomly selects from the available
Hero.brains` and uses that brain for all decisions for the duration of the current game.