owenashurst / agar.io-clone

Agar.io clone written with Socket.IO and HTML5 canvas
MIT License
2.88k stars 1.12k forks source link

failing to computer the log_{base} of a number #478

Closed ndo360 closed 7 years ago

ndo360 commented 7 years ago

Salutations! it seems that anytime I try to use 'gulp run' I get this error:

C:\Users\17clinen\Desktop\agar.io-clone-master\agar.io-clone>gulp run [12:30:02] Using gulpfile ~\Desktop\agar.io-clone-master\agar.io-clone\gulpfile. js [12:30:02] Starting 'lint'... [12:30:02] Starting 'move-client'... [12:30:03] Finished 'lint' after 935 ms [12:30:03] Starting 'build-server'... [12:30:03] Starting 'test'... [12:30:03] Finished 'test' after 2.03 ms [12:30:03] Starting 'todo'... [12:30:03] Finished 'todo' after 2.01 ms

util.js

massToRadius

  √ should return non-zero radius on zero input
  √ should convert masses to a circle radius
#validNick
  √ should allow empty player nicknames

[12:30:03] Finished 'build-server' after 276 ms √ should allow ascii character nicknames √ should disallow unicode-dependent alphabets √ should disallow spaces in nicknames

log

  1) should compute the log_{base} of a number
#getDistance
  √ should return a positive number

7 passing (35ms) 1 failing

1) util.js #log should compute the log_{base} of a number:

  AssertionError: expected 2.0000000000000004 to deeply equal 2
  + expected - actual

  -2.0000000000000004
  +2

  at Context.<anonymous> (C:\Users\17clinen\Desktop\agar.io-clone-master\aga

r.io-clone\test\util.js:86:31) at callFn (C:\Users\17clinen\Desktop\agar.io-clone-master\agar.io-clone\no de_modules\mocha\lib\runnable.js:326:21) at Test.Runnable.run (C:\Users\17clinen\Desktop\agar.io-clone-master\agar. io-clone\node_modules\mocha\lib\runnable.js:319:7) at Runner.runTest (C:\Users\17clinen\Desktop\agar.io-clone-master\agar.io- clone\node_modules\mocha\lib\runner.js:422:10) at C:\Users\17clinen\Desktop\agar.io-clone-master\agar.io-clone\node_modul es\mocha\lib\runner.js:528:12 at next (C:\Users\17clinen\Desktop\agar.io-clone-master\agar.io-clone\node _modules\mocha\lib\runner.js:342:14) at C:\Users\17clinen\Desktop\agar.io-clone-master\agar.io-clone\node_modul es\mocha\lib\runner.js:352:7 at next (C:\Users\17clinen\Desktop\agar.io-clone-master\agar.io-clone\node _modules\mocha\lib\runner.js:284:14) at Immediate. (C:\Users\17clinen\Desktop\agar.io-clone-master\a gar.io-clone\node_modules\mocha\lib\runner.js:320:5)

events.js:160 throw er; // Unhandled 'error' event ^ Error: 1 test failed.

Can anyone help? I can't seem to find a solution. -Cheers Noah C

Roeefl commented 7 years ago

Hi Noah,

There seems to be a precision problem in src/server/lib/util.js in the log method.

For now I've used this to round the numbers up to 5 decimal points and be able to run the project:

// overwrite Math.log function exports.log = (function () { var log = Math.log; return function (n, base) { var rough = log(n) / (base ? log(base) : 1); return (Math.round(rough * 1e5) / 1e5); }; })();

However I think a real solution should be proposed to take place.

Almenon commented 7 years ago

Ran into same problem, thanks for the solution @Roeefl

realJoshByrnes commented 7 years ago

Ran into the same issue also. Do we have something in common? I'm running on an ARM chipset.

TomK32 commented 7 years ago

Thinkpad X240 on an 64bit arch distro here and I have the same problem. Good to see the jokes about rounding errors kept in high regard ;)

t1016d commented 7 years ago

[Intel Core i5-6200U on 64bit arch] I have the same problem, and Roeefl's solution worked. (But not sure if this would trigger any another problems)