Closed einsteinsfool closed 7 years ago
Have you run the unit tests to make sure they still pass?
npm test
No, I didn't run the tests. I'll comment after I run them.
I think you can't just return -1 or 1 by random, because the function must be deterministic and return the same value every time for every input. And random numbers are based on time which changes. Read the last bullet point here.
All tests pass. I'll run them before every PR from now, thanks.
You could generate a random number before calling sort, and append it to each player name before hashing (instead of the node modules). That way the tie will be broken differently every time the function is called.
Right. :D Good, idea. Fixed and tested both with npm and myself (once I was stolen from and once AI was stolen from).
Thanks again for another pr!
Sometimes I can make a decision based on knowing that AI will assasinate or coup the first player from the list if there is more than 1 player with most incluences and cash. I think I shouldn't be able to do that and that AIs should be less predictable. For more explanation check out comments in sort function.
After pulling this, a
npm install
is needed as I added a new module "md5" for calculating hash functions.