[Question]
  [
Write a program or function that takes in a positive integer and prints or returns a stack of that many ASCII-art [turtles](https://en.wikipedia.org/wiki/Turtles_all_the_way_down), where each turtle is larger than the one above it.
Specifically, if the input is `1`, the output should be:
```
 __
/,,\o
```
If the input is `2`:
```
  __
o/,,\
 ____
/,__,\o
```
If the input is `3`:
```
   __
  /,,\o
  ____
o/,__,\
 ______
/,____,\o
```
If the input is `4`:
```
    __
  o/,,\
   ____
  /,__,\o
  ______
o/,____,\
 ________
/,______,\o
```
If the input is `5`:
```
     __
    /,,\o
    ____
  o/,__,\
   ______
  /,____,\o
  ________
o/,______,\
 __________
/,________,\o
```
And so on in the same pattern for larger inputs.
**Note that:**
* The head (the `o`) of the bottom turtle is always on the right. The heads of the turtles above then alternate back and forth.
* No lines may have trailing spaces.
* Superfluous leading spaces are not allowed. (i.e. the back of the bottom turtle should be at the start of the line.)
* A single optional trailing newline is allowed.
**The shortest code in bytes wins.**
  
[Answer]
## Batch, 256 bytes
```
@set i=echo 
@%i%off
set u=
for /l %%j in (2,2,%1)do call set i=%%i%%  
set/af=%1^&1
if %f%==1 %i% __&%i%/,,\o&set u=__
for /l %%j in (2,2,%1)do call:l
exit/b
:l
set i=%i:~0,-2%
%i%  _%u%_
%i%o/,%u%,\
%i% __%u%__
%i%/,_%u%_,\o
set u=__%u%__
```
Note that line 1 has a trailing space and line 4 has two trailing spaces. `i` therefore contains an `echo` command with the appropriate amount of indentation for each turtle. Meanwhile `u` contains the number of underscores in alternate turtles. A leading odd turtle is special-cased and then the rest of the turtles are output in pairs.
[Answer]
# C, 131 bytes
```
i,j;f(n){char _[3*n];memset(_,95,3*n);for(i=n;i--;printf("%*.*s\n%*s/,%.*s,\\%s\n",j+n+1,j+j,_,i,"o"+1-i%2,j+j-2,_,"o"+i%2))j=n-i;}
```
[Try it online.](http://ideone.com/Hx0MHR)
Defines a function that prints the turtles.
Heavily abuses printf's width and precision specifiers to get the spacing and repeating the underscores. Each turtle is printed using a single `printf` call:
```
printf("%*.*s\n%*s/,%.*s,\\%s\n",j+n+1,j+j,_,i,"o"+1-i%2,j+j-2,_,"o"+i%2)
```
I also have a different version that's 144 bytes with whitespace removed:
```
c,i;f(n){for(i=n;i--;){
    char*p=" _\n o/,_,\\o\n";
    int C[]={i+1,c=n+n-i-i,1,i&~1,i%2,1,1,c-2,1,1,1-i%2,1};
    for(c=0;p[c];)C[c]--?putchar(p[c]):++c;
}}
```
[Answer]
# Ruby, 100 bytes
Recursive solution. [Try it online!](https://repl.it/CjSe)
```
f=->n,i=1{f[n-1,i+1]if n>1;puts' '*i+?_*n*2,"%#{i-1}s/,#{?_*2*~-n},\\"%(i<2?'':'o '[i%2])+' o'[i%2]}
```
[Answer]
## 05AB1E, 45 bytes
```
Lvð¹y-©>×„__y×UXJ,„/,X¨¨„,\J'o®ÉiìëJ}ð®®É-×ì,
```
[Try it online](http://05ab1e.tryitonline.net/#code=THbDsMK5eS3CqT7Dl-KAnl9fecOXVVhKLOKAni8sWMKowqjigJ4sXEonb8Kuw4lpw6zDq0p9w7DCrsKuw4ktw5fDrCw&input=MTA)
[Answer]
# [V](http://github.com/DJMcMayhem/V), ~~57, 53~~ 49 bytes
```
i ³_
/,_,\oÀñHyjí_/___
ëPhjI ñdjí___
òkk$x^PXkk
```
Since this contains unprintable characters, here is a hexdump:
```
00000000: 6920 b35f 0a2f 2c5f 2c5c 6f1b c0f1 4879  i ._./,_,\o...Hy
00000010: 6aed 5f2f 5f5f 5f0a eb50 1668 6a49 20f1  j._/___..P.hjI .
00000020: 646a ed5f 5f5f 0af2 6b6b 2478 5e50 586b  dj.___..kk$x^PXk
00000030: 6b                                       k
```
[Try it online!](http://v.tryitonline.net/#code=aSDCs18KLyxfLFxvG8OAw7FIeWrDrV8vX19fCsOrUBZoakkgw7FkasOtX19fCsOya2skeF5QWGtr&input=&args=NQ)
Explanation:
```
i ³_\n/,_,\o<esc>       "Insert the original turtle with one extra underscore
Àñ                      "Arg1 times:
  Hyj                   "  Go the the beginning of the file, and yank a turtle
     í_/___             "  Extend the lenght of every turtle by two
ëP                      "  Move to the beginning of the file again, and paste the turtle we yanked
  <C-v>hjI              "  Move this turtle one to the right
           ñ            "Stop looping.
dj                      "Delete a turtle (since we have one too many)
  í___                  "Make every turtle shorter (since they are all too long)
ò                       "Recursively:
 kk                     "  Move up two lines
   $x                   "  Delete the last character on this line (an 'o')
     ^P                 "  And paste this 'o' at the beginning of the line
       X                "  Remove one space
        kk              "  Move up two lines again
```
[Answer]
## Perl, 92 bytes
**91 bytes code +1 for `-n`.**
Requires `-E` at no extra cost.
```
for$i(1..$_){say$"x$_._,$v=_ x(--$i*2),_.$/.$"x(--$_-1),$_%2?o:$"x!!$_,"/,$v,\\",$_%2?"":o}
```
### Usage
```
perl -nE 'for$i(1..$_){say$"x$_._,$v=_ x(--$i*2),_.$/.$"x(--$_-1),$_%2?o:$"x!!$_,"/,$v,\\",$_%2?"":o}' <<< 3
   __
  /,,\o
  ____
o/,__,\
 ______
/,____,\o
```
Thanks to [@Dada](https://codegolf.stackexchange.com/users/55508/dada) for -9 bytes with his re-work!
[Answer]
# [Cheddar](https://github.com/cheddar-lang/Cheddar/tree/release-1.0.0/src/stdlib/primitive/Array/lib), 105 bytes
```
n->(|>n).map(i->(1-i%2)*"o"+"\\,"+(n-i-1)*"__"+",/"+i%2*"o"+i/2*"  "+"\n"+(n-i)*"__"+(i+1)*" ").vfuse.rev
```
[Answer]
## [Retina](https://github.com/m-ender/retina), ~~97~~ ~~91~~ 88 bytes
Byte count assumes ISO 8859-1 encoding.
```
.+
  $&$*_$&$*_o
+`^( *?)(.)__(_+)(.)
$1 $4$3$2¶$&
 (.)__(_*) ?
  __$2¶$%`$1/,$2,\
Rm`^ 
```
[Try it online!](http://retina.tryitonline.net/#code=LisKICAkJiQqXyQmJCpfbworYF4oICo_KSguKV9fKF8rKSguKQokMSAkNCQzJDLCtiQmCiAoLilfXyhfKikgPwogIF9fJDLCtiQlYCQxLywkMixcClJtYF4g&input=MTI)
[Answer]
# Python 2, 116 Bytes
```
m=input()
for i in range(m):r=m-i;b=r%2;h='o';a='__';u=i*a;s=' '*r;print s+u+a+'\n'+s[:b-2]+h*-~-b+"/,"+u+",\\"+b*h
```
[Answer]
# **R**, 150 bytes
```
a=function(x,y=1){d=x-y;t=d%%2;cat(rep(" ",d+1),rep("_",2*y),"\n",rep(" ",d-t),"o"[t],"/,",rep("_",2*y-2),",\\","o"[!t],"\n",sep="");if(y<x)a(x,y+1)}
```
more cleanly (adds a byte)
```
a=function(x,y=1){
     d=x-y
     t=d%%2
     cat(rep(" ",d+1),rep("_",2*y),"\n",rep(" ",d-t),"o"[t],"/,",rep("_",2*y-2),",\\","o"[!t],"\n",sep="")
     if(y<x)a(x,y+1)
}
```
Basic structure recursively calls itself --telling itself both the final number to be called and the current level. Starts with a default for y=1, so it only needs one variable for initial call. Quickly defines two values that are frequently used. Then it just repeats everything the necessary number of times.
```
"o"[t],"o"[!t]
```
Each of these implicitly test whether to add the head to right or left and place it appropriately.
[Answer]
# TSQL, 189 bytes
Now with input acceptance - thanks to @PatrickRoberts
```
DECLARE @i INT=##i##,@ INT=0a:PRINT SPACE(@i-@)+REPLICATE('__',@+1)+'
'+SPACE((@i-@-1)/2*2)+IIF((@i-@-1)%2=1,'o/,','/,')+REPLICATE('__',@)+IIF((@i-@-1)%2=0,',\o',',\')SET
@+=1IF @i>@ GOTO a
```
**[Fiddle](https://data.stackexchange.com/stackoverflow/query/521281/turtles-all-the-way-down?i=5)**
[Answer]
# C, ~~328~~ ~~238~~ ~~234~~ 215 bytes:
```
B;M(w,j,R){j=w;if(j<=B){char b[j*2-1],k[j*2+1];b[j*2-2]=k[j*2]=0;memset(b,95,j*2-2);memset(k,95,j*2);R=(B+1-j)%2;printf("%*s\n%*s/,%s,\\%s\n",j*2+B+1-j,k,B-j,R?"":"o",b,R?"o":"");j++;M(j);}}main(){scanf("%d",&B);M(1);}
```
A recursive implementation using a lot of string formatting and the builtin `memset` function. Will try and golf this more over time as much as I can.
[C It Online! (Ideone)](http://ideone.com/z8Vs0k)
[Answer]
## Java 1.7, 238 bytes
A set of two functions: first iterates over input (# of turtles), second facilitates in constructing a sequence of repeated characters recursively (i.e. the leading spaces, the back and belly of the turtles).
```
String f(int n){String s="";for(int i=-1,x=-2;++i<n;){int m=(i+n)%2;s+=r(' ',n-i)+r('_',i*2+2)+"\n"+r(' ',n-i-(m==1?1:2))+(m==0?"o":"")+"/,"+r('_',x+=2)+",\\"+(m==1?"o":"")+"\n";}return s;}String r(char c,int n){return n>0?c+r(c,--n):"";}
```
Ungolfed:
```
class C {
    public static void main(String[] a) {
        System.out.println(new T().f(1));
        System.out.println(new T().f(2));
        System.out.println(new T().f(3));
        System.out.println(new T().f(4));
        System.out.println(new T().f(5));
    }
    static class T {
        String f(int n) {
            String s = "";
            for (int i = -1, x = 0; ++i < n; x+=2) {
                int m = (i + n) % 2;
                s += r(' ', n - i) + r('_', i * 2 + 2) + "\n" + r(' ', n - i - (m == 1 ? 1 : 2)) + (m == 0 ? "o" : "") + "/," + r('_', x) + ",\\" + (m == 1 ? "o" : "") + "\n";
            }
            return s;
        }
        String r(char c, int n) {
            return n > 0 ? c + r(c, --n) : "";
        }
    }
}
```
[Run it!](https://ideone.com/g3HmeK) (Ideone)
I've assumed it's okay to exclude the class definition from the byte count.
I may be able to golf this a little further by reversing the iteration order of the loop (build from bottom turtle up) and/or by going fully recursive like some of the other answers.
*Note to self: Java really lacks a built-in shorthand to repeat n characters...*
[Answer]
# Python, ~~137~~ ~~120~~ ~~113~~ 110 bytes
```
m=input()
for i in range(m):p=m-i;b=p%2;print' '*p+'__'*-~i+'\n'+' '*(p-2+b)+'o'*-~-b+'/,'+'__'*i+',\\'+'o'*b
```
Ungolfed:
```
m=input()
for i in range(m):
  p=m-i                              // Abstract m-i for a few bytes
  b=p%2                              // Determines every other turtle from bottom
  print' '*p + '__'*-~i + '\n' +    // The top of the turtle
       ' '*(p-2+b) +                // Leading spaces (-1 for every other turtle)
       '0'*-~-b +                   // Add a leading head to every other turtle
       '/,'+'__'*i +                // Body of the turtle
       ',\\'+'0'*b                  // Add a trailing head to every other turtle
```
The heads were hard.
[Answer]
# F#, ~~218~~ ~~207~~ ~~202~~ ~~196~~ 187 bytes.
Shaved most of these bytes by inlining variables
```
let R=String.replicate
let t n=let rec L i r k=if i<n then L(i+1)(R(k+i%2+1)" "+R((n-i)*2)"_"+"\n"+R k" "+R(i%2)"o"+"/,"+R(n*2-i*2-2)"_"+",\\"+R(1-i%2)"o"+"\n"+r)(k+i%2*2)else r in L 0""0
```
The logic is shamelessly stolen from this [Python answer](https://codegolf.stackexchange.com/a/88632/56157)
[Try it online.](https://ideone.com/swURzz)
[Answer]
# [CJam](http://sourceforge.net/projects/cjam/), 88 bytes
```
ri_[S\_'_*_+N+\O\"/,"\('_*_++','\+'o]\({_[(S+\(2>\(S\+)'O^c+\(-2<\(\('o\{;O}&\;]}*]-1%N*
```
Makes the biggest turtle first (because otherwise what would every other turtle stand on?), then gradually reduces the size until the smallest one is made. Works for any integer larger than 0.
[Try it online!](http://cjam.aditsu.net/#code=ri_%5BS%5C_'_*_%2BN%2B%5CO%5C%22%2F%2C%22%5C(S*_%2B%2B'%2C'%5C%2B'o%5D%5C(%7B_%5B(S%2B%5C(2%3E%5C(S%5C%2B)'O%5Ec%2B%5C(-2%3C%5C(%5C('o%5C%7B%3BO%7D%26%5C%3B%5D%7D*%5D-1%25N*&input=5)
[Answer]
## Python 2.7, ~~255~~ ~~238~~ 236 bytes
Even though this loses to both of the other Python 2 solutions, I liked my recursive approach:
```
def r(s,p):
 for(a,b)in p:s=a.join(s.split(b))
 return s
def t(w):
 i='_'*2*w;s='\n __%s\n/,%s,\o'%(i,i)
 if w:s=r(t(w-1),[('\n ','\n'),('Z/',' /'),('\\Z\n','\\\n'),(' /','o/'),('\\','\\o'),('o','Z')])+s
 return s
print t(input()-1)[1:]
```
edit1: dropped a few bytes by eliminating some replacements
edit2: shaved 2 bytes by saving the underscores as a variable
[Answer]
## Python 2, 147 bytes
```
n=input()
s=' ';r=[];i=k=0
while i<n:a=i%2;r=[s*k+s*a+s+'_'*(n-i)*2+s,s*k+'o'*a+'/,'+'_'*(n-i-1)*2+',\\'+'o'*(1-a)]+r;k+=a*2;i+=1
print'\n'.join(r)
```
[Try it online](http://ideone.com/fork/ZXj181)
[Answer]
## Python 2.7, ~~139~~ ~~114~~ ~~113~~ 130 bytes
I also liked Iguanodon's recursive approach so here's a slightly shorter attempt.
```
def t(n):
 if n>1:t(n-1)
 a=i-n;b=(a+1)%2;print' '*(a+1)+'__'*n+'\n'+' '*(a-1+b)+'o'*(not b)+'/,'+'__'*(n-1)+',\\'+'o'*b
i=input()
t(i)
```
**EDIT**
A mighty ~~25~~ ~~26~~ 9 bytes golfed due to some fantastic tips from Destructible Watermelon. Many thanks! ~~Think it may be the shortest Python answer now :-)~~
```
def t(n):
 if n>1:t(n-1)
 a=i-n;b=-~a%2;print' '*-~a+'__'*n+'\n'+' '*(a-1+b)+'o'*-~-b+'/,'+'__'*~-n+',\\'+'o'*b
i=input()
t(i)
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~105~~ ~~100~~ ~~97~~ ~~87~~ ~~85~~ 84 bytes
-21 bytes thanks to mazzy, the mad man
```
"$args"..1|%{' '*$_--+($m='__'*$i++)+'__'
' '*($_-$_%2)+("/,$m,\o","o/,$m,\")[$_%2]}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfmvkmZb/V9JJbEovVhJT8@wRrVaXUFdSyVeV1dbQyXXVj0@HsjL1NbW1AYxuUCSGkBZlXhVI01tDSV9HZVcnZh8JR2lfAhTSTMaJBdb@7@Wi0tNJU3BkEtJCcwwgjGMYQwTGMP0PwA "PowerShell – Try It Online")
Cleverly shifts variables using `$_--` to avoid using repeated `($_+1)` blocks to save several bytes. It also converts the single argument to a string which is then cast to an int when used in a range to iterate over through the number of turtles. Biggest trick is now having the 2nd level of a turtle's spacing only increase every other row by subtracting `$_%2` (i.e. 0 if even, 1 if odd) from the current row\_count. 
Otherwise, it's a lot of index math to get proper `_` and  counts, including a lag counter in the form of `$i++`, and now only a single list index to put the head on the correct side.
[Answer]
# ES6 (JavaScript), 140 bytes
**Code**
```
T=(i,h=0,p=1,R="repeat")=>(i>1?T(i-1,~h,p+1)+"\n":"")+" "[R](p)+'--'[R](i)+"\n"+" "[R](p-1+h)+(h?"o":"")+"/,"+'__'[R](i-1)+",\\"+(!h?"o":"")
```
**Test**
```
console.log(T(5));
     --
    /,,\o
    ----
  o/,__,\
   ------
  /,____,\o
  --------
o/,______,\
 ----------
/,________,\o
```
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 26 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
╷_×,×ｌ_×∔/×║o×⇵↔⁸¹－［  ×↔｝］
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXUyNTc3XyVENyUyQyVENyV1RkY0Q18lRDcldTIyMTQvJUQ3JXUyNTUxbyVENyV1MjFGNSV1MjE5NCV1MjA3OCVCOSV1RkYwRCV1RkYzQiUyMCUyMCVENyV1MjE5NCV1RkY1RCV1RkYzRA__,i=NQ__,v=8)
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 62 bytes
```
(⁰nεð*nd⇧\_*+,⁰nε⇩ð*⁰nε₂[\o|⁰‹n=[¤|ð]]‛/,nd\_*‛,\⁰nε₂[|\o+]Wṅ,
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%28%E2%81%B0n%CE%B5%C3%B0*nd%E2%87%A7%5C_*%2B%2C%E2%81%B0n%CE%B5%E2%87%A9%C3%B0*%E2%81%B0n%CE%B5%E2%82%82%5B%5Co%7C%E2%81%B0%E2%80%B9n%3D%5B%C2%A4%7C%C3%B0%5D%5D%E2%80%9B%2F%2Cnd%5C_*%E2%80%9B%2C%5C%E2%81%B0n%CE%B5%E2%82%82%5B%7C%5Co%2B%5DW%E1%B9%85%2C&inputs=4&header=&footer=)
Many turtles.
]