Difference between revisions of "New tie paradigm"

From WikiManual
Jump to: navigation, search
(Tie Physics)
m (Fixed typos)
 
(36 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
For the C++ version (2.5), all old tie sysvars are thrown out.  Here's the comprehensive list of all the new tie commands and sysvars:
 
For the C++ version (2.5), all old tie sysvars are thrown out.  Here's the comprehensive list of all the new tie commands and sysvars:
 +
 +
== Basics ==
 +
''Soft'' ties, such as birth ties and ties under 100 cycles old, act as springy telescoping rods.  They will constantly push to return to their creation length, though this force is damped to achieve stability.
 +
 +
''Hard'' ties are totally rigid bodies, with a set length.  Bots can "flash" the tie for a cycle, allowing it to change length.  Bots apply a force along the length of the tie.  After this, the tie ceases to exist for a cycle, allowing the bots on either end to move to a new position.  The tie then reappears, and carries on as normal.
 +
 +
Ties connect to bots using a [http://science.howstuffworks.com/bearing1.htm radial bearing], so that the rotation of the tie and the rotation of the bot are independent of each other.  Bots can "freeze" the the bearings of hard ties, basically locking the tie and the bot together.  This can be done to "freeze" the relative angles of a tie with respect to the bot.
 +
 +
Bots can apply forces to two hard ties to change the angle between them, rather similar to how muscles are used to move bones in the human body (the specifics of this are still in progress).
  
 
== Commands ==
 
== Commands ==
Line 9: Line 18:
 
:When settie isn't set, writetie removes an extra value from the stack to represent the tie being pointed to.  ie: -1 10 .up writetie to write to tie -1.
 
:When settie isn't set, writetie removes an extra value from the stack to represent the tie being pointed to.  ie: -1 10 .up writetie to write to tie -1.
  
:If a negative memory location is specified (ie: 10 -1 writetie) substance transfer is initiated.  10 -1 writetie would transfer 10 units of energy from the tie being pointed to.  If settie is unset, this vesion also takes an additional value form the stack.
+
:If a negative memory location is specified (ie: 10 -1 writetie) substance transfer is initiated.  10 -1 writetie would transfer 10 units of energy from the tie being pointed to.  If settie is unset, this version also takes an additional value form the stack.
*settie - Sets the current tie that the DNA is looking at.  When a new tie is set, all the sysvars update for the new information from that tie.  Negative nubmers specify a physical tie in the internal array.  Positive numbers specifies a tie phase.  Multiple ties can be addressed through a single tie phase.
+
*settie - Sets the current tie that the DNA is looking at.  When a new tie is set, all the sysvars update for the new information from that tie.  Negative numbers specify a physical tie in the internal array.  Positive numbers specifies a tie phase.  Multiple ties can be addressed through a single tie phase.
 
*nexttie - settie's to the next tie.  If settie is currently set to negative (ie: internal arrays) it finds the next tie in the internal array.  If the present tie is already at the end, it moves back to the beginning.  If the present tie is positive, nexttie finds the next valid tie phase, looping back to the lowest tie phase if it's already at the highest.  If settie is unset (ie: set to 0) nexttie pushes it to first internal tie (ie: a negative).
 
*nexttie - settie's to the next tie.  If settie is currently set to negative (ie: internal arrays) it finds the next tie in the internal array.  If the present tie is already at the end, it moves back to the beginning.  If the present tie is positive, nexttie finds the next valid tie phase, looping back to the lowest tie phase if it's already at the highest.  If settie is unset (ie: set to 0) nexttie pushes it to first internal tie (ie: a negative).
  
 
== Sysvars ==
 
== Sysvars ==
*readtielen - A read sysvar.  Reads back the length of the current tie.
+
*tielen - A read/write sysvar.  reads back the ties natural length.  If this value is overwritten, the ties natural length is set to the new value.
 
 
*writetielen - A read/write sysvar.  reads back the ties natural length.  If this value is overwritten, the ties natural length is set to the new value.
 
  
 
*tieangle - A read sysvar.  Reads back the relative angle of the tie with respect to the bot's eye.
 
*tieangle - A read sysvar.  Reads back the relative angle of the tie with respect to the bot's eye.
Line 26: Line 33:
 
*currtie - The value that settie is set to.  A read sysvar.
 
*currtie - The value that settie is set to.  A read sysvar.
  
*tieK - A read/write sysvar, set to the present spring coefficient.  Overwrite and set the spring coefficient of the current tie to a new value (and pay the difference in potential energy).
+
*numties - Returns the number of physical ties connected to the bot.
 
 
*tieB - A read/write sysvar, set to the present damping constant.  Overwrite and set the damping constant of the current tie to a new value.(and pay the difference in potential energy).
 
 
 
*tietype - Set the kind of constraints the tie uses.  example:
 
*# - Spring (apply a damped spring force)
 
*# - Rope (offer no resistance until the natural length is reached, then create infinite resistance)
 
*# - Repulsor (offer no resistance as long as length is greater than the natural length.  If the length is less than the natural length, create an infinite repulsive force).
 
*# - Rod - keep the ties length exactly at the natural length using constraints.  Will basically be like a rigid rod is connecting the bots, making the bots into a rigid body.
 
 
 
*numties - Returns the number of phsyical ties connected to the bot.
 
 
 
*birthtietype - Similar to tietype, sets the type of tie that birth ties turn into when they harden.  If 0 is specified, birth ties atrophy after 100 cycles.
 
  
 
*recentport, recentphase - Returns the phase and port of the most recently formed tie ''with a cycle delay''.
 
*recentport, recentphase - Returns the phase and port of the most recently formed tie ''with a cycle delay''.
Line 46: Line 41:
  
 
== Tie Notes ==
 
== Tie Notes ==
*Ports - The internal array index is referred to as a tie's "port".  Each tie has a unique port.  Each port may or may not have a tie.  Port ranges are set by the number of ties in existance when a new tie is formed.  Ties always fill in the first gap in the internal tie array.
+
*Ports - The internal array index is referred to as a tie's "port".  Each tie has a unique port.  Each port may or may not have a tie.  Port ranges are set by the number of ties in existence when a new tie is formed.  Ties always fill in the first gap in the internal tie array.
  
 
*Phase - The phase of a tie is a way of addressing multiple ties at once.  Each tie has a unique phase.  Phases may exist anywhere in the mod range [1,200].  That is, 1 = 201 = 401.
 
*Phase - The phase of a tie is a way of addressing multiple ties at once.  Each tie has a unique phase.  Phases may exist anywhere in the mod range [1,200].  That is, 1 = 201 = 401.
  
*Length - Max tie length will be 1000, after which all ties become 100% rigid and acts like a stiff rod.  This includes birth ties.  A later feature will be that the max tie length is a function of the amount of material (nrg) used in its construction.  Ties' diameter will stretch and shrink as the tie does.  Ties won't be allowed to go below a certain diameter.  This diameter will also effect the bandwidth (that is, the max throughput) allowed in sharing/stealing substances.
+
*Length - Ties cannot be longer than 1000 twips (a typical bot is 120 twips in diameter).  This includes birth ties.  Later the max tie length will be a function of the amount of material (nrg) used in its construction.  Ties' diameter will stretch and shrink as the tie does.  Ties won't be allowed to go below a certain diameter.  This diameter will also effect the bandwidth (that is, the max throughput) allowed in sharing/stealing substances.
  
 
*Birth Ties - Spring ties that after 100 cycles die off or harden depending on the value set on birthtietype.  Birth ties are only formed between a mother and child bot at the moment of reproduction.
 
*Birth Ties - Spring ties that after 100 cycles die off or harden depending on the value set on birthtietype.  Birth ties are only formed between a mother and child bot at the moment of reproduction.
  
 
== Tie Physics ==
 
== Tie Physics ==
Tie physics has been alot of work, and alot of calculus, but I think the below is accurate.  It still will need to be double checked, as it's been many months since I did the work.
+
Tie physics has been a lot of work, and a lot of calculus, but I think the below is accurate.  It still will need to be double checked, as it's been many months since I did the work.
 
 
Fluid forces on ties can be segmented into two seperate parts: those that cause rotation of the tie and those that cause translation of the tie.
 
 
 
Ties are defined by two endpoints, the two bots:
 
 
 
AB = vector formed by bot(B).pos - bot(A).pos
 
  
*a = velocity of bot A with respect to the tie, a scalar quantity, bot(A).vel cross AB
+
Fluid forces on ties can be segmented into two separate parts: those that cause rotation of the tie and those that cause translation of the tie.
*b = velocity of bot A with respect to the tie, a scalar quantity, bot(B).vel cross AB (or maybe it's the other way around, I forget)
 
*p = density of fluid
 
*r = radius of tie
 
*xc = center of gravity for tie.
 
*L = length of tie
 
*v(x) = velocity of tie at x distance away from a = a + (b-a)x/L
 
*V = v hat = the average absolute value of velocity of the tie as a whole.
 
*CD(v^) = Drag coefficient for the tie using average velocity
 
  
V = <u> a * |a| - b * |b|</u>
+
Ties are defined by two endpoints, the two bots.
::2(a-b)
 
  
 +
===Quantities===
 +
*(note, for ease of expression sign(a) has been expressed as <math>\hat{a}</math> for scalars)
 +
*<math>\vec{ab} = bot(B).\vec{pos}  -  bot(A).\vec{pos}</math>
 +
*<math>a</math> = velocity of bot A with respect to the tie, a scalar quantity = <math> bot(A).\vec{vel} \times \LARGE \frac{ \vec{ab}}{||ab||}</math>
 +
*<math>b</math> = velocity of bot B with respect to the tie, a scalar quantity = <math> bot(B).\vec{vel} \times \LARGE \frac{ \vec{ab}}{||ab||}</math>
 +
*<math>\rho</math> = density of fluid given in mass per cubic twip <math> \LARGE \frac{Mass}{twip^3}</math>
 +
*<math>r</math> = radius of tie
 +
*<math>x_c</math> = center of gravity for tie. = <math>\LARGE \frac{L * mass2} {mass1 + mass2}</math>
 +
*<math>L</math> = length of tie
 +
*<math>v(x)</math> = velocity of tie at <math>x</math> distance away from bot a<math>= a + (b-a)\frac{x}{L}</math>
 +
*<math>\bar{v}</math> = the average absolute value of velocity of the tie as a whole.
 +
*<math>CD(\bar{v})</math> = Drag coefficient for the tie using average velocity
 +
*<math>\LARGE \bar{v} = \frac{\int_0^L{|v(x)|}}{L}</math>
 
Maple gives:
 
Maple gives:
 
  int( abs(v(x)) / L, x = 0..L); =  
 
  int( abs(v(x)) / L, x = 0..L); =  
                          2              2
+
                        2              2
                     L (-b  signum(b) + a  signum(a))
+
                     (-b  signum(b) + a  signum(a))
 
                 1/2 --------------------------------
 
                 1/2 --------------------------------
 
                                   -b + a
 
                                   -b + a
 +
or <math>\LARGE \frac{a^2 \hat{a} -b^2 \hat{b}}{2(a-b)}</math>
  
 +
=== Translational Drag ===
 +
Translational drag slows a tie moving through the liquid.  For instance, if two bots are moving with identical velocity vectors that are not parallel to the tie between them, translational drag on the tie would serve to slow these two bots down.
  
=== Translational ===
+
<math>\Large Force_{Drag} = \rho r CD(\bar{v}) \int_0^L{v(x)^2 \hat{v(x)} dx}</math>
Drag Force = p * r * CD(V) * Integral(v(x)^2 sgn(v(x)) dx) from 0 to L
 
  
 
if a != b then Integral =  
 
if a != b then Integral =  
<u>L(|a^3| - |b^3|)</u>
+
<math>\LARGE
::::::3(a - b)
+
\frac
 +
{L(a^3 \hat{a} - b^3 \hat{b})}
 +
{3(a-b)}</math>
  
 
if a = b then Integral =  
 
if a = b then Integral =  
L * a * |a|
+
<math>L a^2 \hat{a}</math>
  
 
Translational force is divided up between bot A and B depending on their masses and distance from xc.
 
Translational force is divided up between bot A and B depending on their masses and distance from xc.
Line 108: Line 105:
 
  a^2*signum(a)*L
 
  a^2*signum(a)*L
  
=== Rotational ===
+
=== Rotational Drag ===
 +
Rotational Drag only effects the rotational inertia of the tie, not it's translational motion.  Basically it slows a spinning tie down.
 +
 
 
This is much more of a head scratcher, but this is what I came up with:
 
This is much more of a head scratcher, but this is what I came up with:
  
Force Drag = p * r * CD(V) * Integral(v(x)^2 sgn(v(x)) (x - xc) dx) from 0 to L
+
<math>Force_{Drag} = \LARGE \rho r CD(\bar{v}) \int_0^L{v(x)^2 \hat{v(x)} (x - x_c) dx}</math>
  
 
Maple 5.1 gives the above Integral as:
 
Maple 5.1 gives the above Integral as:
Line 122: Line 121:
 
               3                  /        2
 
               3                  /        2
 
         + 4 a  signum(a) xc b)  /  (-b + a)
 
         + 4 a  signum(a) xc b)  /  (-b + a)
                                /
 
  
where xc = (mass2 * L) / (mass1 + mass2)
+
this is the above (hopefully, there might be a typo) in more readable math:
 +
<math>\HUGE \frac{L}{12} \frac{3 b^4 \hat b L - 4 b^3 \hat b a L - 4 b^4 \hat b x_c + 4 b^3 \hat b x_c a - 4 a^4 \hat a x_c + a^4 \hat a L + 4 a^3 \hat a x_c b}{(a-b)^2}</math>
 +
 
 +
and factoring out <math>b^3 \hat b</math> and <math>a^3 \hat a</math>:
 +
 
 +
<math>\HUGE \frac{L}{12} \frac{ b^3 \hat b (3bL - 4aL - 4bx_c + 4ax_c) + a^3 \hat a (4ax_c + aL + 4bx_c)}{(a-b)^2}</math>
 +
 
  
 
Rotational Drag is also divided up between bot A and B depending on their masses and distance from xc.
 
Rotational Drag is also divided up between bot A and B depending on their masses and distance from xc.
 +
 +
Note that if a = b, Rotational Drag is 0 (since the tie isn't rotating).
 +
 +
=== Rigid Tie velocity normalization ===
 +
Rigid ties means that bots' velocities will be normalized across the tie in addition to their positions being kept within a certain constraint.
 +
 +
Here's how the velocity normalization works:
 +
 +
*<math>\vec{vel_a}</math> = velocity of bot a
 +
*<math>\vec{vel_b}</math> = velocity of bot b
 +
 +
# Find velocity parallel to ab.
 +
#*<math>A = \vec{vel_a} \frac {\vec{ab}} {||\vec{ab}||} </math>
 +
#*<math>B = \vec{vel_b} \frac {\vec{ab}} {||\vec{ab}||} </math>
 +
# <math>Momentum = A * mass_A + B * mass_B</math>
 +
# <math>\vec{VEL} = \LARGE \frac{Momentum} {mass_A + mass_B}</math>
 +
#
 +
#*<math>\vec{vel_a} = \vec{vel_a} + \frac {\vec{ab}} {||\vec{ab}||} </math> <math>(\vec{VEL} - A \frac {\vec{ab}} {||\vec{ab}||})</math>
 +
#*<math>\vec{vel_b} = \vec{vel_b} + \frac {\vec{ab}} {||\vec{ab}||} </math> <math>(\vec{VEL} - B \frac {\vec{ab}} {||\vec{ab}||})</math>
 +
 +
=== Conclusion ===
  
 
The exact way in which the drags are divided up I haven't worked out yet, but I don't imagine it should be too terribly difficult (jinxed myself :P).
 
The exact way in which the drags are divided up I haven't worked out yet, but I don't imagine it should be too terribly difficult (jinxed myself :P).
  
The main theoretical issue I have is with the possibility that I'm doubling up the forces by calculating both the translational and rotational Drag seperately and applying them seperately, but I don't think this is the case, and even if it is it's just increasing by a constant factor, which is a minor issue.
+
The main theoretical issue I have is with the possibility that I'm doubling up the forces by calculating both the translational and rotational Drag separately and applying them separately, but I don't think this is the case, and even if it is it's just increasing by a constant factor, which is a minor issue.
 +
 
 +
== Tie physics (redone) ==
 +
=== Notations and definitions ===
 +
A tie between botA and botB is uniquely specified by the position and velocity of its endpoints, the bots' centers. Let's call:
 +
*'''r<sub>A</sub>''' and '''r<sub>B</sub>''' the position of botA and botB (<tt>botA.pos</tt> and <tt>botB.pos</tt> in the code)
 +
*'''v<sub>A</sub>''' and '''v<sub>B</sub>''' their velocities (<tt>botA.vel</tt> and <tt>botB.vel</tt> in the code)
 +
*L = ||'''r<sub>B</sub>'''-'''r<sub>A</sub>'''|| the length of the tie and '''u''' the unit vector such that '''r<sub>B</sub>'''-'''r<sub>A</sub>''' = L '''u'''.
 +
*'''n''' the ?/2-rotation of '''u''', so that ('''u''', '''n''') is a direct orthonormal base. We'll denote the components of any vector '''x''' in this base as '''x''' = x<sub>T</sub> '''u''' + x<sub>N</sub>'''n'''
 +
Let's also label the points of the ties by a parameter x in [0;1]. '''r'''(x) = '''r<sub>A</sub>''' +L x '''u''' and the corresponding velocity is '''v'''(x) = (1-x)'''v<sub>A</sub>''' + x '''v<sub>B</sub>'''.
 +
 
 +
Now, the drag force acting on an infinitesimal portion of the tie between the positions '''r'''(x) and '''r'''(x+dx) is '''dF''' = -L dx . f |'''v'''.'''n'''|<sup>&alpha; - 1</sup> ('''v'''.'''n''') '''n''', with &alpha; = 1 if viscosity is the dominating influence on drag and &alpha; = 2 if it's turbulence. f is a coefficient defining the magnitude of drag, it is assumed independent of the length of the tie.
 +
 
 +
Assuming that the tie is massless, we can then solve the equations of motions for the tie to get the forces applied on the bots: both the sum of the forces and the sum of the torques applied to it are zero.
 +
 
 +
=== Drag forces ===
 +
Let's call '''F'''<sub>A</sub> and '''F'''<sub>B</sub> the forces applied by the tie on the bots. The tie is subjected to forces -'''F'''<sub>A</sub>, -'''F'''<sub>B</sub> and <math>{\bf F}=\int {\bf dF}</math>. We have '''F''' = '''F'''<sub>A</sub> + '''F'''<sub>B</sub>.
 +
 
 +
<math> {\bf F} = -\int_0^1 L f |w_A + x (w_B - w_A)|^{\alpha - 1} (w_A + x (w_B - w_A)) dx {\bf n}</math>
 +
 
 +
<math> {\bf F} = -\frac{L f}{(\alpha + 1)(w_B - w_A)} (|w_B|^{\alpha - 1} w_B^2 - |w_A|^{\alpha - 1} w_A^2 ) {\bf n}</math>
 +
 
 +
Let's compute the torques about A: <math>{\bf T} = \vec{AB} \wedge {\bf F}_B</math> with <math>{\bf T} = \int \vec{AM} \wedge {\bf dF}</math>
 +
 
 +
<math>T = -\int_0^1 L x . L f |w_A + x (w_B - w_A)|^{\alpha - 1} (w_A + x (w_B - w_A)) dx </math>
 +
We get:
 +
<math> -T = L^2 f \frac{\epsilon_B w_B^{\alpha + 1}}{(\alpha + 1)(w_B-w_A)}- L^2 f\frac{\epsilon_B w_B^{\alpha + 2} - \epsilon_A w_A^{\alpha + 2}}{(\alpha + 1)(\alpha + 2)(w_B-w_A)^2}</math> with &epsilon; = sign(w<sup>&alpha;+1</sup>).
 +
 
 +
If &alpha; = 1, all the signs are positive and we have:
 +
<math> -T = L^2 f\frac{w_B^2}{2(w_B-w_A)}- L^2 f\frac{w_B^3 - w_A^3}{6(w_B-w_A)^2}</math>
 +
 
 +
<math> -T = L^2 f\frac{w_B^2}{2(w_B-w_A)}- L^2 f\frac{w_B^2 + w_B w_A + w_A^2}{6(w_B-w_A)}</math>
 +
 
 +
<math> -T = L^2 f\frac{2 w_B^2 - w_B w_A - w_A^2}{6(w_B-w_A)}</math>
 +
 
 +
<math> -T = \frac{L^2 f}{6}(2 w_B + w_A)</math>
 +
 
 +
Thus, finally, <math>F_B = -\frac{L f}{6}(2 w_B + w_A)</math> and <math>F_A = -\frac{L f}{6}(2 w_A + w_B)</math>.
 +
 
 +
If &alpha; = 2, it gets more complicated and we must distinguish between two cases:
 +
 
 +
If w<sub>A</sub> and w<sub>B</sub> have the same sign,
 +
<math> -T = L^2 f  \frac{w_B^3}{3(w_B-w_A)}- L^2 f \epsilon_A \frac{w_B^4 -  w_A^4}{12(w_B-w_A)^2}</math>
 +
 
 +
<math> -T = L^2 f \epsilon_A \frac{w_B^3}{3(w_B-w_A)}- L^2 f \epsilon_A \frac{w_B^3 + w_B^2 w_A + w_B w_A^2 + w_A^3}{12(w_B-w_A)}</math>
 +
 
 +
<math> -T = L^2 f \epsilon_A \frac{3 w_B^3 - w_B^2 w_A - w_B w_A^2 - w_A^3}{12(w_B-w_A)}</math>
 +
 
 +
<math> -T = \frac{L^2 f \epsilon_A}{12}(3 w_B^2 + 2 w_B w_A + w_A^2)</math> and <math> F_B = -\frac{L f \epsilon}{12}(3 w_B^2 + 2 w_B w_A + w_A^2)</math>
 +
 
 +
If w<sub>A</sub> and w<sub>B</sub> have opposite signs,
 +
<math> -T = L^2 f \epsilon_A \frac{- w_B^3}{3(w_B-w_A)}- L^2 f\epsilon_A \frac{- w_B^4 - w_A^4}{12(w_B-w_A)^2}</math>
 +
 
 +
<math> -T = L^2 f \epsilon_B \frac{3 w_B^4 - 4 w_B^3 w_A - w_A^4}{12(w_B-w_A)^2}</math> and <math> F_B = -L f \epsilon_B \frac{3 w_B^4 - 4 w_B^3 w_A - w_A^4}{12(w_B-w_A)^2}</math> , with no possible simplification.

Latest revision as of 19:19, 14 February 2014

For the C++ version (2.5), all old tie sysvars are thrown out. Here's the comprehensive list of all the new tie commands and sysvars:

Basics

Soft ties, such as birth ties and ties under 100 cycles old, act as springy telescoping rods. They will constantly push to return to their creation length, though this force is damped to achieve stability.

Hard ties are totally rigid bodies, with a set length. Bots can "flash" the tie for a cycle, allowing it to change length. Bots apply a force along the length of the tie. After this, the tie ceases to exist for a cycle, allowing the bots on either end to move to a new position. The tie then reappears, and carries on as normal.

Ties connect to bots using a radial bearing, so that the rotation of the tie and the rotation of the bot are independent of each other. Bots can "freeze" the the bearings of hard ties, basically locking the tie and the bot together. This can be done to "freeze" the relative angles of a tie with respect to the bot.

Bots can apply forces to two hard ties to change the angle between them, rather similar to how muscles are used to move bones in the human body (the specifics of this are still in progress).

Commands

  • readtie - If settie is set (ie: not 0) writetie takes 1 value from the stack, representing the memory location to be read from, and places a value on the stack representing the value at that location through the tie. If settie is positive, and points to a phase representing more than one tie, the returned values are averaged for each robot thus pointed to.
.nrg readtie will read the value stored in .nrg from the bot connected through the current tie.
  • writetie - If settie is set (ie: not 0) writetie takes 2 values from the stack. 10 .up writetie will place 10 at the location specified (.up) in whichever bots are at the other end of the tie(s) settie addresses.
When settie isn't set, writetie removes an extra value from the stack to represent the tie being pointed to. ie: -1 10 .up writetie to write to tie -1.
If a negative memory location is specified (ie: 10 -1 writetie) substance transfer is initiated. 10 -1 writetie would transfer 10 units of energy from the tie being pointed to. If settie is unset, this version also takes an additional value form the stack.
  • settie - Sets the current tie that the DNA is looking at. When a new tie is set, all the sysvars update for the new information from that tie. Negative numbers specify a physical tie in the internal array. Positive numbers specifies a tie phase. Multiple ties can be addressed through a single tie phase.
  • nexttie - settie's to the next tie. If settie is currently set to negative (ie: internal arrays) it finds the next tie in the internal array. If the present tie is already at the end, it moves back to the beginning. If the present tie is positive, nexttie finds the next valid tie phase, looping back to the lowest tie phase if it's already at the highest. If settie is unset (ie: set to 0) nexttie pushes it to first internal tie (ie: a negative).

Sysvars

  • tielen - A read/write sysvar. reads back the ties natural length. If this value is overwritten, the ties natural length is set to the new value.
  • tieangle - A read sysvar. Reads back the relative angle of the tie with respect to the bot's eye.
  • tie - Attempts to form a tie with the specified phase. Since phases are limited to [1, 200], a value greater than 200 will be modded by 200. A negative value's sign will be flipped then modded 200.
  • deltie - If settie is set and the number stored is non negative, the current tie(s) selected are deleted. If settie is not set, the tie phase (positive values) or tie index (negative values) matching the value is deleted.
  • currtie - The value that settie is set to. A read sysvar.
  • numties - Returns the number of physical ties connected to the bot.
  • recentport, recentphase - Returns the phase and port of the most recently formed tie with a cycle delay.

Sharing

MB sharing as it was in 2.4 and before does not exist. MB sharing uses the same mechanism that tie feeding uses, though ties that have hardened have a drastically increased bandwidth.

Tie Notes

  • Ports - The internal array index is referred to as a tie's "port". Each tie has a unique port. Each port may or may not have a tie. Port ranges are set by the number of ties in existence when a new tie is formed. Ties always fill in the first gap in the internal tie array.
  • Phase - The phase of a tie is a way of addressing multiple ties at once. Each tie has a unique phase. Phases may exist anywhere in the mod range [1,200]. That is, 1 = 201 = 401.
  • Length - Ties cannot be longer than 1000 twips (a typical bot is 120 twips in diameter). This includes birth ties. Later the max tie length will be a function of the amount of material (nrg) used in its construction. Ties' diameter will stretch and shrink as the tie does. Ties won't be allowed to go below a certain diameter. This diameter will also effect the bandwidth (that is, the max throughput) allowed in sharing/stealing substances.
  • Birth Ties - Spring ties that after 100 cycles die off or harden depending on the value set on birthtietype. Birth ties are only formed between a mother and child bot at the moment of reproduction.

Tie Physics

Tie physics has been a lot of work, and a lot of calculus, but I think the below is accurate. It still will need to be double checked, as it's been many months since I did the work.

Fluid forces on ties can be segmented into two separate parts: those that cause rotation of the tie and those that cause translation of the tie.

Ties are defined by two endpoints, the two bots.

Quantities

  • (note, for ease of expression sign(a) has been expressed as \hat{a} for scalars)
  • \vec{ab} = bot(B).\vec{pos}  -  bot(A).\vec{pos}
  • a = velocity of bot A with respect to the tie, a scalar quantity = Failed to parse (unknown function "\LARGE"): bot(A).\vec{vel} \times \LARGE \frac{ \vec{ab}}{||ab||}
  • b = velocity of bot B with respect to the tie, a scalar quantity = Failed to parse (unknown function "\LARGE"): bot(B).\vec{vel} \times \LARGE \frac{ \vec{ab}}{||ab||}
  • \rho = density of fluid given in mass per cubic twip Failed to parse (unknown function "\LARGE"): \LARGE \frac{Mass}{twip^3}
  • r = radius of tie
  • x_c = center of gravity for tie. = Failed to parse (unknown function "\LARGE"): \LARGE \frac{L * mass2} {mass1 + mass2}
  • L = length of tie
  • v(x) = velocity of tie at x distance away from bot a= a + (b-a)\frac{x}{L}
  • \bar{v} = the average absolute value of velocity of the tie as a whole.
  • CD(\bar{v}) = Drag coefficient for the tie using average velocity
  • Failed to parse (unknown function "\LARGE"): \LARGE \bar{v} = \frac{\int_0^L{|v(x)|}}{L}

Maple gives:

int( abs(v(x)) / L, x = 0..L); = 
                       2              2
                    (-b  signum(b) + a  signum(a))
                1/2 --------------------------------
                                 -b + a

or Failed to parse (unknown function "\LARGE"): \LARGE \frac{a^2 \hat{a} -b^2 \hat{b}}{2(a-b)}

Translational Drag

Translational drag slows a tie moving through the liquid. For instance, if two bots are moving with identical velocity vectors that are not parallel to the tie between them, translational drag on the tie would serve to slow these two bots down.

Failed to parse (unknown function "\Large"): \Large Force_{Drag} = \rho r CD(\bar{v}) \int_0^L{v(x)^2 \hat{v(x)} dx}

if a != b then Integral = Failed to parse (unknown function "\LARGE"): \LARGE \frac {L(a^3 \hat{a} - b^3 \hat{b})} {3(a-b)}

if a = b then Integral = L a^2 \hat{a}

Translational force is divided up between bot A and B depending on their masses and distance from xc.

Integrals are found using Maple 5.1 and simplifying. Maple gives Integral =

int( v(x) * abs(v(x)), x = 0..L) = 
                         3              3
                    L (-b  signum(b) + a  signum(a))
                1/3 --------------------------------
                                 -b + a


If a = b, the limit is given as

a^2*signum(a)*L

Rotational Drag

Rotational Drag only effects the rotational inertia of the tie, not it's translational motion. Basically it slows a spinning tie down.

This is much more of a head scratcher, but this is what I came up with:

Failed to parse (unknown function "\LARGE"): Force_{Drag} = \LARGE \rho r CD(\bar{v}) \int_0^L{v(x)^2 \hat{v(x)} (x - x_c) dx}

Maple 5.1 gives the above Integral as:

int( v(x) * abs(v(x)) * (x - xc), x = 0..L) = 
            4                  3                    4
 1/12 L (3 b  signum(b) L - 4 b  signum(b) a L - 4 b  signum(b) xc
             3                     4                 4
        + 4 b  signum(b) xc a - 4 a  signum(a) xc + a  signum(a) L
             3                   /         2
        + 4 a  signum(a) xc b)  /  (-b + a)

this is the above (hopefully, there might be a typo) in more readable math: Failed to parse (unknown function "\HUGE"): \HUGE \frac{L}{12} \frac{3 b^4 \hat b L - 4 b^3 \hat b a L - 4 b^4 \hat b x_c + 4 b^3 \hat b x_c a - 4 a^4 \hat a x_c + a^4 \hat a L + 4 a^3 \hat a x_c b}{(a-b)^2}

and factoring out b^3 \hat b and a^3 \hat a:

Failed to parse (unknown function "\HUGE"): \HUGE \frac{L}{12} \frac{ b^3 \hat b (3bL - 4aL - 4bx_c + 4ax_c) + a^3 \hat a (4ax_c + aL + 4bx_c)}{(a-b)^2}


Rotational Drag is also divided up between bot A and B depending on their masses and distance from xc.

Note that if a = b, Rotational Drag is 0 (since the tie isn't rotating).

Rigid Tie velocity normalization

Rigid ties means that bots' velocities will be normalized across the tie in addition to their positions being kept within a certain constraint.

Here's how the velocity normalization works:

  • \vec{vel_a} = velocity of bot a
  • \vec{vel_b} = velocity of bot b
  1. Find velocity parallel to ab.
    • A = \vec{vel_a} \frac {\vec{ab}} {||\vec{ab}||}
    • B = \vec{vel_b} \frac {\vec{ab}} {||\vec{ab}||}
  2. Momentum = A * mass_A + B * mass_B
  3. Failed to parse (unknown function "\LARGE"): \vec{VEL} = \LARGE \frac{Momentum} {mass_A + mass_B}
    • \vec{vel_a} = \vec{vel_a} + \frac {\vec{ab}} {||\vec{ab}||} (\vec{VEL} - A \frac {\vec{ab}} {||\vec{ab}||})
    • \vec{vel_b} = \vec{vel_b} + \frac {\vec{ab}} {||\vec{ab}||} (\vec{VEL} - B \frac {\vec{ab}} {||\vec{ab}||})

Conclusion

The exact way in which the drags are divided up I haven't worked out yet, but I don't imagine it should be too terribly difficult (jinxed myself :P).

The main theoretical issue I have is with the possibility that I'm doubling up the forces by calculating both the translational and rotational Drag separately and applying them separately, but I don't think this is the case, and even if it is it's just increasing by a constant factor, which is a minor issue.

Tie physics (redone)

Notations and definitions

A tie between botA and botB is uniquely specified by the position and velocity of its endpoints, the bots' centers. Let's call:

  • rA and rB the position of botA and botB (botA.pos and botB.pos in the code)
  • vA and vB their velocities (botA.vel and botB.vel in the code)
  • L = ||rB-rA|| the length of the tie and u the unit vector such that rB-rA = L u.
  • n the ?/2-rotation of u, so that (u, n) is a direct orthonormal base. We'll denote the components of any vector x in this base as x = xT u + xNn

Let's also label the points of the ties by a parameter x in [0;1]. r(x) = rA +L x u and the corresponding velocity is v(x) = (1-x)vA + x vB.

Now, the drag force acting on an infinitesimal portion of the tie between the positions r(x) and r(x+dx) is dF = -L dx . f |v.n|α - 1 (v.n) n, with α = 1 if viscosity is the dominating influence on drag and α = 2 if it's turbulence. f is a coefficient defining the magnitude of drag, it is assumed independent of the length of the tie.

Assuming that the tie is massless, we can then solve the equations of motions for the tie to get the forces applied on the bots: both the sum of the forces and the sum of the torques applied to it are zero.

Drag forces

Let's call FA and FB the forces applied by the tie on the bots. The tie is subjected to forces -FA, -FB and Failed to parse (syntax error): {\bf F}=\int {\bf dF} . We have F = FA + FB.

Failed to parse (syntax error): {\bf F} = -\int_0^1 L f |w_A + x (w_B - w_A)|^{\alpha - 1} (w_A + x (w_B - w_A)) dx {\bf n}

Failed to parse (syntax error): {\bf F} = -\frac{L f}{(\alpha + 1)(w_B - w_A)} (|w_B|^{\alpha - 1} w_B^2 - |w_A|^{\alpha - 1} w_A^2 ) {\bf n}

Let's compute the torques about A: Failed to parse (syntax error): {\bf T} = \vec{AB} \wedge {\bf F}_B with Failed to parse (syntax error): {\bf T} = \int \vec{AM} \wedge {\bf dF}

T = -\int_0^1 L x . L f |w_A + x (w_B - w_A)|^{\alpha - 1} (w_A + x (w_B - w_A)) dx We get:  -T = L^2 f \frac{\epsilon_B w_B^{\alpha + 1}}{(\alpha + 1)(w_B-w_A)}- L^2 f\frac{\epsilon_B w_B^{\alpha + 2} - \epsilon_A w_A^{\alpha + 2}}{(\alpha + 1)(\alpha + 2)(w_B-w_A)^2} with ε = sign(wα+1).

If α = 1, all the signs are positive and we have:  -T = L^2 f\frac{w_B^2}{2(w_B-w_A)}- L^2 f\frac{w_B^3 - w_A^3}{6(w_B-w_A)^2}

 -T = L^2 f\frac{w_B^2}{2(w_B-w_A)}- L^2 f\frac{w_B^2 + w_B w_A + w_A^2}{6(w_B-w_A)}

 -T = L^2 f\frac{2 w_B^2 - w_B w_A - w_A^2}{6(w_B-w_A)}

 -T = \frac{L^2 f}{6}(2 w_B + w_A)

Thus, finally, F_B = -\frac{L f}{6}(2 w_B + w_A) and F_A = -\frac{L f}{6}(2 w_A + w_B).

If α = 2, it gets more complicated and we must distinguish between two cases:

If wA and wB have the same sign,  -T = L^2 f  \frac{w_B^3}{3(w_B-w_A)}- L^2 f \epsilon_A \frac{w_B^4 -  w_A^4}{12(w_B-w_A)^2}

 -T = L^2 f \epsilon_A \frac{w_B^3}{3(w_B-w_A)}- L^2 f \epsilon_A \frac{w_B^3 + w_B^2 w_A + w_B w_A^2 + w_A^3}{12(w_B-w_A)}

 -T = L^2 f \epsilon_A \frac{3 w_B^3 - w_B^2 w_A - w_B w_A^2 - w_A^3}{12(w_B-w_A)}

 -T = \frac{L^2 f \epsilon_A}{12}(3 w_B^2 + 2 w_B w_A + w_A^2) and  F_B = -\frac{L f \epsilon}{12}(3 w_B^2 + 2 w_B w_A + w_A^2)

If wA and wB have opposite signs,  -T = L^2 f \epsilon_A \frac{- w_B^3}{3(w_B-w_A)}- L^2 f\epsilon_A \frac{- w_B^4 - w_A^4}{12(w_B-w_A)^2}

 -T = L^2 f \epsilon_B \frac{3 w_B^4 - 4 w_B^3 w_A - w_A^4}{12(w_B-w_A)^2} and  F_B = -L f \epsilon_B \frac{3 w_B^4 - 4 w_B^3 w_A - w_A^4}{12(w_B-w_A)^2} , with no possible simplification.