JoyCog

Hex Artifact Content
Login

Artifact eda3b4d9754708d6c6098de4f84fc994927aea4fce5dbee31f0394953377a7fe:


0000: 23 20 4a 6f 79 43 6f 67 0a 0a 41 20 6c 69 74 74  # JoyCog..A litt
0010: 6c 65 20 6c 65 61 72 6e 69 6e 67 20 65 78 65 72  le learning exer
0020: 63 69 73 65 20 69 6e 20 5b 4a 6f 79 5d 28 68 74  cise in [Joy](ht
0030: 74 70 3a 2f 2f 77 77 77 2e 6b 65 76 69 6e 61 6c  tp://www.kevinal
0040: 62 72 65 63 68 74 2e 63 6f 6d 2f 63 6f 64 65 2f  brecht.com/code/
0050: 6a 6f 79 2d 6d 69 72 72 6f 72 2f 69 6e 64 65 78  joy-mirror/index
0060: 2e 68 74 6d 6c 29 2e 20 49 74 27 73 20 61 20 22  .html). It's a "
0070: 74 72 69 76 69 61 6c 22 20 28 49 74 20 77 61 73  trivial" (It was
0080: 6e 27 74 20 66 6f 72 20 6d 65 21 29 20 70 72 6f  n't for me!) pro
0090: 67 72 61 6d 6d 65 20 74 68 61 74 20 74 61 6b 65  gramme that take
00a0: 73 20 61 20 6c 69 73 74 20 6f 66 20 28 74 77 6f  s a list of (two
00b0: 29 20 63 68 61 69 6e 73 65 74 20 67 65 61 72 73  ) chainset gears
00c0: 20 61 6e 64 20 61 20 6c 69 73 74 20 6f 66 20 73   and a list of s
00d0: 70 72 6f 63 6b 65 74 73 20 61 6e 64 20 74 68 65  prockets and the
00e0: 6e 20 63 61 6c 63 75 6c 61 74 65 73 20 61 6c 6c  n calculates all
00f0: 20 74 68 65 20 72 61 74 69 6f 73 20 72 65 70 6f   the ratios repo
0100: 72 74 69 6e 67 20 6f 75 74 20 74 68 65 20 72 65  rting out the re
0110: 73 75 6c 74 73 20 61 73 20 61 20 73 6f 72 74 65  sults as a sorte
0120: 64 20 6c 69 73 74 20 6f 66 20 72 61 74 69 6f 73  d list of ratios
0130: 20 61 6e 64 20 67 65 61 72 20 70 61 69 72 73 3a   and gear pairs:
0140: 0a 0a 09 3e 20 5b 33 34 20 35 30 5d 20 5b 31 32  ...> [34 50] [12
0150: 20 31 33 20 31 35 20 31 37 20 31 39 20 32 31 20   13 15 17 19 21 
0160: 32 33 20 32 36 5d 20 6a 6f 79 63 6f 67 2e 0a 09  23 26] joycog...
0170: 3e 20 5b 5b 31 2e 33 30 37 36 39 20 32 36 20 33  > [[1.30769 26 3
0180: 34 5d 20 5b 31 2e 34 37 38 32 36 20 32 33 20 33  4] [1.47826 23 3
0190: 34 5d 20 5b 31 2e 36 31 39 30 35 20 32 31 20 33  4] [1.61905 21 3
01a0: 34 5d 20 5b 31 2e 37 38 39 34 37 20 31 39 20 33  4] [1.78947 19 3
01b0: 34 5d 20 2e 2e 2e 20 5d 0a 0a 49 20 64 65 63 69  4] ... ]..I deci
01c0: 64 65 64 20 74 6f 20 64 6f 20 74 68 69 73 20 61  ded to do this a
01d0: 73 20 49 20 77 61 73 20 69 6e 74 72 69 67 75 65  s I was intrigue
01e0: 64 20 61 62 6f 75 74 20 77 68 61 74 20 74 68 65  d about what the
01f0: 20 74 68 65 6f 72 65 74 69 63 61 6c 20 70 72 6f   theoretical pro
0200: 67 72 65 73 73 69 6f 6e 20 6f 66 20 67 65 61 72  gression of gear
0210: 73 20 73 68 6f 75 6c 64 20 62 65 20 6f 6e 20 6d  s should be on m
0220: 79 20 62 69 6b 65 20 28 79 6f 75 20 63 6f 75 6c  y bike (you coul
0230: 64 20 6e 65 76 65 72 20 73 68 69 66 74 20 6c 69  d never shift li
0240: 6b 65 20 74 68 69 73 20 69 6e 20 70 72 61 63 74  ke this in pract
0250: 69 63 65 29 2e 20 54 68 65 72 65 20 69 73 20 6d  ice). There is m
0260: 6f 72 65 20 6f 76 65 72 6c 61 70 20 74 68 61 6e  ore overlap than
0270: 20 49 20 74 68 6f 75 67 68 74 2e 0a 0a 4f 6e 65   I thought...One
0280: 20 70 6f 73 73 69 62 6c 65 20 65 78 74 65 6e 73   possible extens
0290: 69 6f 6e 20 49 20 63 6f 75 6c 64 20 64 6f 20 69  ion I could do i
02a0: 73 20 74 6f 20 64 69 73 63 6f 75 6e 74 20 74 68  s to discount th
02b0: 65 20 72 61 74 69 6f 73 20 61 74 20 74 68 65 20  e ratios at the 
02c0: 65 78 74 72 65 6d 65 73 20 6f 66 20 63 68 61 69  extremes of chai
02d0: 6e 20 61 6e 67 6c 65 2c 20 65 2e 67 2e 20 62 69  n angle, e.g. bi
02e0: 67 67 65 73 74 20 66 72 6f 6e 74 20 67 65 61 74  ggest front geat
02f0: 20 61 6e 64 20 62 69 67 67 65 73 74 20 72 65 61   and biggest rea
0300: 72 20 73 70 72 6f 63 6b 65 74 2e 20 42 75 74 20  r sprocket. But 
0310: 77 72 61 70 70 69 6e 67 20 6d 79 20 68 65 61 64  wrapping my head
0320: 20 61 72 6f 75 6e 64 20 4a 6f 79 20 68 61 73 20   around Joy has 
0330: 62 65 65 6e 20 68 61 72 64 2c 20 73 6f 20 49 27  been hard, so I'
0340: 6c 6c 20 6e 6f 74 20 64 6f 20 74 68 61 74 20 74  ll not do that t
0350: 6f 6f 20 73 6f 6f 6e 2e 0a 0a 23 23 20 49 6e 73  oo soon...## Ins
0360: 74 61 6c 6c 69 6e 67 20 2f 20 55 73 69 6e 67 0a  talling / Using.
0370: 0a 31 2e 20 47 65 74 20 61 6e 64 20 63 6f 6d 70  .1. Get and comp
0380: 69 6c 65 20 4a 6f 79 20 66 72 6f 6d 20 5b 4b 65  ile Joy from [Ke
0390: 76 69 6e 20 41 6c 62 72 65 63 68 74 27 73 20 6d  vin Albrecht's m
03a0: 69 72 72 6f 72 5d 28 68 74 74 70 3a 2f 2f 77 77  irror](http://ww
03b0: 77 2e 6b 65 76 69 6e 61 6c 62 72 65 63 68 74 2e  w.kevinalbrecht.
03c0: 63 6f 6d 2f 63 6f 64 65 2f 6a 6f 79 2d 6d 69 72  com/code/joy-mir
03d0: 72 6f 72 2f 69 6e 64 65 78 2e 68 74 6d 6c 29 20  ror/index.html) 
03e0: 28 49 20 77 65 6e 74 20 77 69 74 68 20 22 63 75  (I went with "cu
03f0: 72 72 65 6e 74 20 6a 6f 79 2e 74 61 72 2e 67 7a  rrent joy.tar.gz
0400: 22 29 0a 0a 23 23 23 20 49 6e 74 65 72 61 63 74  ")..### Interact
0410: 69 76 65 6c 79 0a 0a 32 2e 20 53 74 61 72 74 20  ively..2. Start 
0420: 61 6e 20 69 6e 74 65 72 61 63 74 69 76 65 20 4a  an interactive J
0430: 6f 79 20 73 65 73 73 69 6f 6e 20 66 72 6f 6d 20  oy session from 
0440: 77 69 74 68 69 6e 20 74 68 65 20 64 69 72 65 63  within the direc
0450: 74 6f 72 79 20 77 68 65 72 65 20 6a 6f 79 20 77  tory where joy w
0460: 61 73 20 63 6f 6d 70 69 6c 65 64 20 73 6f 20 74  as compiled so t
0470: 68 61 74 20 75 73 72 6c 69 62 2c 20 69 6e 69 6c  hat usrlib, inil
0480: 69 62 20 61 6e 64 20 61 67 67 6c 69 62 20 61 72  ib and agglib ar
0490: 65 20 6c 6f 61 64 65 64 20 61 75 74 6f 6d 61 74  e loaded automat
04a0: 69 63 61 6c 6c 79 2c 20 65 2e 67 3a 20 60 2e 2f  ically, e.g: `./
04b0: 6a 6f 79 60 0a 33 2e 20 49 6d 70 6f 72 74 20 6a  joy`.3. Import j
04c0: 6f 79 63 6f 67 20 6c 69 6b 65 20 73 6f 3a 20 60  oycog like so: `
04d0: 2f 70 61 74 68 2f 74 6f 2f 6a 6f 79 63 6f 67 2e  /path/to/joycog.
04e0: 6a 6f 79 20 69 6e 63 6c 75 64 65 2e 60 0a 34 2e  joy include.`.4.
04f0: 20 52 75 6e 20 61 73 20 60 5b 33 34 20 35 30 5d   Run as `[34 50]
0500: 20 5b 31 32 20 31 33 20 31 35 20 31 37 20 31 39   [12 13 15 17 19
0510: 20 32 31 20 32 33 20 32 36 5d 20 6a 6f 79 63 6f   21 23 26] joyco
0520: 67 2e 60 0a 0a 23 23 23 20 46 72 6f 6d 20 74 68  g.`..### From th
0530: 65 20 43 6f 6d 6d 61 6e 64 20 4c 69 6e 65 0a 0a  e Command Line..
0540: 35 2e 20 45 64 69 74 20 74 68 65 20 72 65 6c 61  5. Edit the rela
0550: 74 69 76 65 20 70 61 74 68 20 69 6e 20 74 68 65  tive path in the
0560: 20 6a 6f 79 63 6f 67 63 6c 2e 6a 6f 79 20 66 69   joycogcl.joy fi
0570: 6c 65 0a 36 2e 20 63 64 20 74 6f 20 74 68 65 20  le.6. cd to the 
0580: 6a 6f 79 20 65 78 65 63 75 74 61 62 6c 65 20 64  joy executable d
0590: 69 72 65 63 74 6f 72 79 20 28 73 6f 20 75 73 72  irectory (so usr
05a0: 6c 69 62 2c 20 69 6e 69 6c 69 62 20 61 6e 64 20  lib, inilib and 
05b0: 61 67 67 6c 69 62 20 61 72 65 20 6c 6f 61 64 65  agglib are loade
05c0: 64 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 29  d automatically)
05d0: 0a 37 2e 20 43 61 6c 6c 20 61 73 20 60 2e 2f 6a  .7. Call as `./j
05e0: 6f 79 20 2f 70 61 74 68 2f 74 6f 2f 6a 6f 79 63  oy /path/to/joyc
05f0: 6f 67 63 6c 2e 6a 6f 79 20 33 34 20 35 30 20 31  ogcl.joy 34 50 1
0600: 32 20 31 33 20 31 35 20 31 37 20 31 39 20 32 31  2 13 15 17 19 21
0610: 20 32 33 20 32 36 60 2e 20 49 2e 65 20 74 68 65   23 26`. I.e the
0620: 20 66 69 72 73 74 20 74 77 6f 20 61 72 67 75 6d   first two argum
0630: 65 6e 74 73 20 61 72 65 20 74 68 65 20 66 72 6f  ents are the fro
0640: 6e 74 20 63 68 61 69 6e 72 69 6e 67 20 74 68 65  nt chainring the
0650: 20 72 65 73 74 20 61 72 65 20 74 68 65 20 63 61   rest are the ca
0660: 73 73 65 74 74 65 0a                             ssette.