Timeline for Knight moves in Chess game
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 10, 2020 at 13:24 | history | edited | CommunityBot |
Commonmark migration
|
|
Sep 27, 2015 at 8:46 | comment | added | fpierrat | Thanks for this benchmark, you taught me testing is better than intuition for such matters :-) @Adwait Kumar: 1^2+2^2=5, so the hypothenuse^2=5 (hypothenuse=√5) | |
Sep 27, 2015 at 3:17 | comment | added | Adwait Kumar | Shouldn't it be 25 instead of 5? | |
Sep 27, 2015 at 2:45 | comment | added | rolfl | @fpierrat - I ran some benchmarks, and found that the pythagoras route is about 1/3 faster than the Math.abs for most people's testing, but, with a fully warmed up Java instance, the Math.abs starts to win out (by my calculation, after you have called the function about 400,000,000 times). The code I ran to test it, and the results I got, are here: pastebin.com/6yKk9Ji8 . That code uses the MicroBench harness I have put on GitHub here: github.com/rolfl/MicroBench - The test creates 20x20 boards, and computes each square against every other square. | |
Sep 27, 2015 at 1:30 | comment | added | fpierrat | @rolfl - I don't understand why it should be better to make 2 multiplications, one addition and one comparison rather than getting 2 absolute values and doing 4 comparisons: I had thougth absolute value (very simple bitwise operation) as well as comparison needed less execution time than a multiplication (or even 2 here). Moreover, the non-pythagoras solution is much easier to read and understand, without needing comments explaining what's being done... | |
Sep 26, 2015 at 15:43 | comment | added | rolfl | @undergroundmonorail - with the 'comments' in the surrounding description I can understand. I have added comments to the actual code now and renamed the variables. Should help a lot. | |
Sep 26, 2015 at 15:42 | history | edited | rolfl | CC BY-SA 3.0 |
comment appropriately
|
Sep 26, 2015 at 15:39 | comment | added | undergroundmonorail | your algorithm works but if i saw that code in the wild i'd have no idea what i was looking at | |
Sep 26, 2015 at 15:29 | history | answered | rolfl | CC BY-SA 3.0 |