text:
Reverse Boustrophedon Text
Boustrophedon is a type of bi-directional text where successive lines alternate between reading left-to-right and right-to-left. Character direction was also mirrored with respect to reading direction. In reverse boustrophedon writing systems, characters were rotated 180 instead of mirrored.
Challenge
Write a program/function that accepts a string of text and a number of columns, and outputs the string formatted into the specified number of columns with alternating lines flipped upside down.
Input
Your program should accept two arguments:

S, the string of text to format
N, the number of columns

Output
Your program should output S wrapped in N columns with alternating lines flipped 180 degrees.

The reading direction of the first line is always left-to-right.
Don't worry about where to place line breaks, lines can be split at any character, no hypenation of words required.
You may assume input string will not contain any line breaks.

Here are the characters your program should support with their flipped counterparts:
Uppercase:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Z

Lowercase:
abcdefghijklmnopqrstuvwxyz
ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz

Punctuation:
&_?!"'.,
⅋‾¿¡„,˙'

Test Cases
S: The quick brown fox jumps over the lazy dog.
N: 30
Output:
The quick brown fox jumps over
                ˙ƃop ʎzɐl ǝɥʇ

S: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue.
N: 50
Output:
Lorem ipsum dolor sit amet, consectetur adipiscing
uǝɯǝlǝ ɯnʇɔᴉp ɔunN ˙nɔɹɐ oɹǝqᴉl lǝʌ ǝnbsᴉnQ ˙ʇᴉlǝ
tum lectus nec aliquet. Donec dolor nunc, sodales
lǝԀ ˙snɹnd ǝnbsᴉɹǝlǝɔs ʇᴉɹǝɹpuǝɥ 'snɔuoɥɹ ɹolop ʇɐ
lentesque vel sagittis libero, et rutrum leo. Null
sᴉʇɐuǝuǝʌ ǝɐʇᴉʌ 'ɯnʇɔᴉp ɐssɐɯ ʇǝ ɯᴉuǝ ǝʇɐʇndlnʌ ɯɐ
 augue lobortis. Fusce sollicitudin ultrices conse
ɔɐɟ puǝɟᴉǝlǝ ɹoʇɹoʇ uou ɔunu sᴉnb ɯnlnqᴉʇsǝΛ ˙ʇɐnb
ilisis. In at nunc elit. Aliquam pellentesque, lec
ʇǝɯ sᴉʇʇᴉƃɐs snʇɔǝl ɯɐnb 'ǝɹǝnsod ɯɐnbᴉlɐ sᴉnb snʇ
us, ut auctor sem quam a neque. Integer rhoncus lo
snʇǝɯ uᴉ ʇǝǝɹoɐl 'ᴉnp ᴉɯ ǝnbsǝʇuǝllǝԀ ˙lsᴉu sᴉʇɹoq
 quis, mollis accumsan est. Nunc dignissim tortor
u snʇɔnl 'ɯɐnbᴉlɐ snllǝʇ ʇn ʇ∩ ˙sndɯǝʇ puǝɟᴉǝlǝ ɔɐ
ulla quis, consectetur nunc. Suspendisse viverra m
˙ǝnƃnɐ ʇᴉɹǝɹpuǝɥ ʇǝ ɹnʇᴉqɐɹnƆ ˙ɯnʇuǝɯᴉpuoɔ ǝᴉʇsǝlo

Bash + GNU utilities, 204
fold -$1|sed 2~2{s/.\\+/printf\ %$1's "`echo "&"|rev`"/e
y/'`printf %s {A..Z} {a..z}`"&_?!\"'.,/∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz⅋‾¿¡„,˙'/
}"

N is given on the command line and S is given via STDIN:
$ echo "The quick brown fox jumps over the lazy dog." | ./boustrophedon.sh 30
The quick brown fox jumps over
                ˙ƃop ʎzɐl ǝɥʇ
$

Explanation

fold -N splits the input into lines of length N.
The rest of the processing is done by sed, line-by-line:

2~2 matches every other line, starting at line 2
s/.+/printf %'N's "`echo "&"|rev`"/e uses GNU Sed's exec feature to call a shell to reverse the line and left-pad it with up to N spaces
y/ABC.../∀qƆ.../ transform characters

Note ABC... is generated using a bash expansion and printf.  Also some fancy quoting for all the different characters.

Thanks @isaacg - I thought I tried double backticks, but I guess I missed that.

Japt, 182 179 bytes
Japt is a shortened version of JavaScript. Interpreter
Ur'.+".?"pV-1 ,@A++%2?SpV-Xl)+Xw m@"„\xA1⅋,'˙¿∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Z[\\]^‾`ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz"g(Q+"!&',.?"+65o124 m@Xd)a)bX)||X +R:X+R

How it works
             // Implicit: U = input string, V = input number, A = 10
Ur           // Take U and replace each group X of:
'.+".?"pV-1  //  at least one char, followed by up to V-1 other chars
             //   literally: RegExp("." + ".?".repeat(V-1))
@            // with: (@ is compiled to (X,Y,Z)=>)
A++%2?       //  If we're on an odd row:
SpV-Xl)+     //   Pad it with spaces, then concatenate it with
Xw m@        //   X reversed, with each character X mapped to:
"..."g       //   The character at position N in the string, where N is:
(Q+"!&',.?"  //    Build a string from a quote mark and these chars,
65o124 m@Xd)a) //   and all chars from A..z.
bX)          //    Return the index of X in this string.
||X          //   or if this number is outside the string, default to the original char.
+R           //   Either way, add a newline.
:X+R         //  Otherwise, return the original row text plus a newline.
             // Implicit: output last expression

There are a couple of problems, but they shouldn't affect the validity of the program:

User @Vɪʜᴀɴ has recently helped me implement Unicode Shortcuts, or single characters in the range 00A1-00FF that stand in for commonly-used several-char sequences. The problem with this is that it currently replaces inside strings, so we can't use ¡ directly in the string for now. The safe alternative, \xA1, is three bytes longer.
It's currently impossible to input a double-quote character. This will be fixed shortly.

Perhaps there's a way to shorten the string. Suggestions are welcome!

Nice!  I wanted to try to convert my solution to Japt later, but this takes the cake.

Javascript (ES6), 407 400 366 360 353 bytes
I'm counting only the first two "lines" in this snippet as the total count, as the rest of it is code to run it.

s=`ABCDEFGHIJKLMNOPQRSTUVWXYZ∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zabcdefghijklmnopqrstuvwxyzɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz&_?!"'.,⅋‾¿¡„,˙'`,f=(i,w)=>(i=i.match(RegExp(`.{1,${w}}`,"g")),i.map((c,x)=>x%2?" ".repeat(w-c.length)+[...c].reverse().map(b=>(d=s.indexOf(b),"A"<=b&&"z">=b?s[d+26]:" "==b?b:s[d+8])).join``:c).join`
`)

let input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue.";
console.log(f(input, 50));

Explanation
s=`A∀ .. ZZaɐ .. &⅋ ..`,                            //Character translation "map"
f=(i,w)=>                                           //Create a function named "f" that takes an (i)nput string and (w)idth
    (                                               //Implicitly return
        i=i.match(RegExp(`.{1,${w}}`,"g")),         //Cut string into arrays every w-th match of anything
        i.map((c,x)=>                               //Loop through each element in array by (c)ut at inde(x)
            x%2                                     //If the index is odd
                ?" ".repeat(w-c.length)                 //Output spaces for padding
                    +[...c].reverse()                   //Split this cut into each character, and read it backwards
                    .map((b,d)=>(                       //Translate each character
                        d=s.indexOf(b),                 //Save where this character appears in the mapping
                        "A"<=b&&"z">=b                  //If the character is a-zA-Z
                        ?s[d+26]                            //Print the flipped character by looking 26 characters ahead of where this character is found
                        :" "==b                             //Else, if it's a space
                            ?b                              //Output the space
                            :s[d+8]))                   //Else, print the flipped punctuation character (only 8 of these)
                    .join``                         //Join everything back into a continuous string
                :c                                  //Else just output the whole cut
            ).join`
`)                                                  //Finally join each cut by a newline

Thanks to Dendrobium for -6 bytes!
Thanks to the Closure Compiler for -34 bytes!
Thanks to ןnɟuɐɯɹɐןoɯ for -7 bytes!

You can reduce all your .split("")'s and .join("")'s to .split\`and.join``to shave off a few bytes. The.join("\n")can also be rewritten like the above with a literal newline instead of\n`.

Great tips, thank you very much!

You can take out the new keyword for the regex. Also use exec instead of match. Oh yeah, use [...c] instead of c.split``.

@ןnɟuɐɯɹɐןoɯ Nice, thank you!  I couldn't figure out how to use exec and keep it short though, since exec needs to be looped over to get all matches.

Oh, nevermind about exec...

CJam, 152
l~_q/\f{Se]}2/{)26,'Af+_el+"&_?!'.,"`+"∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz„⅋‾¿¡,˙'"erW%}%N*

Test it here.
I guess I should look into compressing that Unicode string a bit...

Compressing that Unicode string is hard - the code points are all over the place.  As an experiment, I tried 'zopfli'ing my entire entry (including sed bits) and ended up bigger. I'll be watching with interest to see how you tackle it :)

Pyth, 141 bytes
FNrZlKczQI%N2X.[" "Q_@KN++GrG1"&_?!\"'.,""ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Z⅋‾¿¡„,˙'")E@KN

Tested with an online Pyth Compiler.
How it Works
FNrZlKczQI%N2X.[" "Q_@KN)E@KN    █
                                 █
FN                               █ For N in
  r                              █  ├ Range
   Z                             █  |  ・Start: 0
                                 █  |  ・End:
    l                            █  |     Length of
     K                           █  |      └─K =
      c                          █  |         Split
       z                         █  |           ・String z
        Q                        █  |           ・By input int Q
         I%N2                    █  └─If divisible by 2
             X                   █     └─Translate
                                 █         ├─Source:
              .[                 █         | ├─Pad left
                " "              █         | |   ・With spaces
                   Q             █         | |   ・Until input int Q
                    _            █         | └──Reverse
                     @KN         █         |     ・Nth line of K
                        ++GrG1...█         ├─From: Normal  (See below)
                        "ɐqɔpǝ...█         └─To:   Flipped (See below)
                        )E@KN    █     Else print Nth line of K

Map
Normal
++                               █　Append:
  G                              █  1) a to z
   rG1                           █  2) A to Z
      "&_?!\"'.,"                █  3) Punctuation

Flipped (Nothing fancy)
"ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Z⅋‾¿¡„,˙'"

This is 108 characters long; however, the default way to measure the length of code-golf programs is in bytes. According to this page, the length of this answer is 141 bytes.

@ETHproductions Thanks. Changed.

Python, 453 363 bytes
s,n=input()
o="""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&_?!"'.,"""
p="""∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz⅋‾¿¡„,˙'""".decode('utf8')
s=map(''.join,zip(*[iter(s+' '*(n-1))]*n))
for i in range(len(s)):
 if i%2:s[i]=''.join(p[o.find(c)].encode('utf8')for c in s[i][::-1])
for l in s:print l

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Black and White Rainbows
Given an image that has only black and white pixels and an (x,y) location that's a white pixel, color the white pixels based on their minimal Manhattan distance from (x,y) in a path that only involves traversing other white pixels.
The hue of the colored pixels must be proportional to their distance from (x,y), so the pixel at (x,y) will have a hue of 0° (pure red) and the pixels farthest away from (x,y) will have a hue of 360° (also red), with the other hues blending seamlessly and linearly in between. The saturation and value must both be 100%.
If a white pixel is not connected to (x,y) through other white pixels then it must remain white.
Details

The input will consist of the file name of the image or the raw image data, plus the x and y integers.
The output image may be saved to a file or piped raw to stdout in any common image file format, or simply displayed.
The x value is 0 on the leftmost pixels, and increases going right. The y value is 0 in the topmost pixels and increases going down. (x,y) will always be in the image bounds.
Both full programs and functions are allowed.

The shortest code in bytes wins.
Examples
All these images have been downsized to save space. Click them to view at full size.
Input image:

(x,y) = (165,155) and (x,y) = (0,0)

Input image and output with (x,y) = (0,0):

Input image and output with (x,y) = (600,350):

Input image and output with (x,y) = (0,0):

Input image and output with (x,y) = (0,0):

Optional -30% bonus: use Euclidean distance. A suggestion for your algorithm is as follows (general outline):

Have a start pixel.
Flood-fill from that pixel.
For every pixel reached in the flood fill,
Move from the start pixel to that pixel in half-unit steps, in a straight line.
At each step, apply int() to the x and y coordinates. If the pixel at these coordinates is black, stop. Otherwise, continue. (This is a line-of-sight method.)
Any reached pixel that borders a white pixel and/or a pixel that was previously labeled with a significantly higher distance (i.e., +10) becomes a start pixel.

In a more meta sense, this algorithm spreads out to every pixel reachable in a straight line from start/already-colored pixels, then "inches" around edges. The "significantly higher distance" bit is intended to speed up the algorithm. Honestly, it doesn't really matter how you implement Euclidean distance, it just has to look pretty much like this.
This is what the first example looks like with Euclidean distance, using the algorithm above:
Input image and (x,y) = (165,155)

Many thanks to Calvin'sHobbies and trichoplax for helping write this challenge! Have fun!

I don't plan on golfing it but I made a Javascript version where you can mouse-over the image and the colors update instantly. The test images here are too big for it to run fast so I'd advise trying smaller images like this or this.

This is awesome! I suspect it is too efficient to be a good base for a golfed version=)

Mazes are so much easier to solve when they are colored like this!

The last example is really beautiful. Is the input image just noise?

@dylnan: If you're talking about the example right before the bonus, that's actually a maze. You can click on it to see it at full size.

Oh! I was confused about why there would be boundaries in noise

Matlab, 255 245 231 bytes
This expects the image name first, then y and then x.
I=@input;i=imread(I('','s'));[r,c]=size(i);m=zeros(r,c);m(I(''),I(''))=1;M=m;d=m;K=[1,2,1];for k=1:r*c;d(m&~M)=k;M=m;m=~~conv2(m,K'*K>1,'s');m(~i)=0;end;z=max(d(:));v=[1,1,3];imshow(ind2rgb(d,hsv(z)).*repmat(m,v)+repmat(~d&i,v),[])

I implemented the flood filling (or 'dijkstra for 4-neighbourhoods' if you want) roughly by first creating a mask where the seed pixel is set to 1 and with a distance accumulator (both of the size of the image) and then repeating following steps:

convolute the mask with a 4 neighbourhood kernel (this is the very inefficient part)
set all nonzero pixels of the mask to 1
set all the black pixels of the image to zero
set all values in the accumulator where the mask has changed in this step to k
increase k
repeat until there are no more changes in the mask (I actually do not check this condition, but just use the number of pixels in the image as an upper bound, which is usually a very bad upper bound, but this is codegolf=)

This leaves us with the manhattan distances of every pixel to the seed pixel in the distance accumulator. Then we create a new image by going throu the given range of colours and map the "first" hue to the value zero and the "last" hue to the maximal distance.
Examples

As a bonus, here a pretty picture of how the distance gets calculated. brighter = farther away.

This is the kind of stuff I'd want to print out for my daughter to draw on.

@rayryeng The templates are El'endia Starman's work, not mine=)

You still put colour to the images :D.  You did the last step.

I'm impressed. I could barely understand the challenge lol

Honestly, what I want to use it for is creating landscapes.

@zfrisch But I hope it is somewhat clearer now? If you need further explanation just ask=)

@corsiKa I'd be interested to see your results=)

@flawr: I actually stole two of them through Google. I don't know where Calvin got the huge maze.

Blitz 2D/3D, 3068 * 0.7 = 2147.6
This is the reference implementation for the Euclidean algorithm, golfed.
image=LoadImage("HueEverywhere_example1.png")
Graphics ImageWidth(image),ImageHeight(image)
image=LoadImage("HueEverywhere_example1.png")
x=0
y=0
w=ImageWidth(image)
h=ImageHeight(image)
Type start
Field x,y
Field dis#
Field nex.start
End Type
Type cell
Field x,y
Field dis#
End Type
Type oldCell
Field x,y
Field dis#
End Type
initCell.start=New start
initCell\x=x
initCell\y=y
initCell\dis=1
Dim array#(w,h)
imgBuff=ImageBuffer(image)
LockBuffer(imgBuff)
s.start=First start
colr=col(0,0,0)
colg=col(0,0,1)
colb=col(0,0,2)
newcol=colr*256*256+colg*256+colb
WritePixelFast(s\x,s\y,newcol,imgBuff)
While s<>Null
c.cell=New cell
c\x=s\x
c\y=s\y
c\dis=s\dis
While c<>Null
For dy=-1To 1
For dx=-1To 1
If dx*dy=0And dx+dy<>0
nx=c\x+dx
ny=c\y+dy
ndis#=s\dis+Sqr#((nx-s\x)*(nx-s\x)+(ny-s\y)*(ny-s\y))
If nx >= 0And nx<w And ny >= 0And ny<h
If KeyHit(1)End
pixcol=ReadPixelFast(nx,ny,imgBuff)
If pixcol<>-16777216
If array(nx,ny)=0Or ndis<array(nx,ny)
check=1
steps=Ceil(dis)*2
For k=0 To steps
r#=k*1./steps
offx#=Int(s\x+(c\x-s\x)*r)
offy#=Int(s\y+(c\y-s\y)*r)
pixcol2=ReadPixelFast(offx,offy,imgBuff)
If pixcol2=-16777216
check=0
Exit
EndIf
Next
If check
array(nx,ny)=ndis
newCell.cell=New cell
newCell\x=nx
newCell\y=ny
newCell\dis=ndis
EndIf
EndIf
EndIf
EndIf
EndIf
Next
Next
o.oldCell=New oldCell
o\x=c\x
o\y=c\y
o\dis=c\dis
Delete c
c=First cell
Wend
For o.oldCell=Each oldCell
bordersWhite=0
For dy=-1To 1
For dx=-1To 1
If dx<>0Or dy<>0
nx=o\x+dx
ny=o\y+dy
If nx>=0And nx<w And ny>=0And ny<h
pixcol=ReadPixelFast(nx,ny,imgBuff)
If (pixcol=-1And array(nx,ny)=0)Or array(nx,ny)>o\dis+9
bordersWhite=1
Exit
EndIf
EndIf
EndIf
Next
If bordersWhite Exit
Next
If bordersWhite
ns.start=New start
ns\x=o\x
ns\y=o\y
ns\dis=o\dis
s2.start=First start
While s2\nex<>Null
If ns\dis<s2\nex\dis
Exit
EndIf
s2=s2\nex
Wend
ns\nex=s2\nex
s2\nex=ns
EndIf
Delete o
Next
EndIf
s2=s
s=s\nex
Delete s2
Wend
maxDis=0
For j=0To h
For i=0To w
If array(i,j)>maxDis maxDis=array(i,j)
Next
Next
For j=0To h
For i=0To w
dis2#=array(i,j)*360./maxDis
If array(i,j) <> 0
colr=col(dis2,0,0)
colg=col(dis2,0,1)
colb=col(dis2,0,2)
newcol=colr*256*256+colg*256+colb
WritePixelFast(i,j,newcol,imgBuff)
EndIf
Next
Next
UnlockBuffer(imgBuff)
DrawImage image,0,0
Function col(ang1#,ang2#,kind)
While ang1>360
ang1=ang1-360
Wend
While ang1<0
ang1=ang1+360
Wend
While ang2>180
ang2=ang2-360
Wend
While ang2<-180
ang2=ang2+360
Wend
a3#=ang2/180.
If ang1>300
diff#=(ang1-300)/60.
r=255
g=0
b=255*(1-diff)
ElseIf ang1>240
diff#=(ang1-240)/60.
r=255*diff
g=0
b=255
ElseIf ang1>180
diff#=(ang1-180)/60.
r=0
g=255*(1-diff)
b=255
ElseIf ang1>120
diff#=(ang1-120)/60.
r=0
g=255
b=255*diff
ElseIf ang1>60
diff#=(ang1-60)/60.
r=255*(1-diff)
g=255
b=0
Else
diff#=(ang1-00)/60.
r=255
g=255*diff
b=0
EndIf
If a3>0
r2=r+a3*(255-r)
g2=g+a3*(255-g)
b2=b+a3*(255-b)
Else
r2=r+a3*r
g2=g+a3*g
b2=b+a3*b
EndIf
If r2>255
r2=255
ElseIf r2<0
r2=0
EndIf
If g2>255
g2=255
ElseIf g2<0
g2=0
EndIf
If b2>255
b2=255
ElseIf b2<0
b2=0
EndIf
If kind=0
Return r2
ElseIf kind=1
Return g2
ElseIf kind=2
Return b2
Else
Return 0
EndIf
End Function

Actually, I kinda hate how unreadable this is compared to the original. (Which is, incidentally, 5305 bytes.) Actually, I could lop off quite a few more bytes by using one-character variable names for everything, but this is kinda ridiculous enough already. And it's not winning any time soon. :P

C++ / SFML : 1271 1235 1226 bytes
-36 bytes thanks to user202729
 -9 bytes thanks to Zacharý
#include<SFML\Graphics.hpp>
#include<iostream>
#define V std::vector
#define P e.push_back
#define G(d,a,b,c) case d:return C(a,b,c);
#define FI(r,s)(std::find_if(e.begin(),e.end(),[&a](const T&b){return b==T{a.x+(r),a.y+(s),0};})!=e.end())
using namespace sf;using C=Color;struct T{int x,y,c;bool operator==(const T&a)const{return x==a.x&&y==a.y;}};int max(V<V<int>>&v){int m=INT_MIN;for(auto&a:v)for(auto&b:a)m=b>m?b:m;return m;}C hsv2rgb(int t){int ti=t/60%6;float f=t/60.f-ti,m=(1.f-f)*255,n=f*255;switch(ti){G(0,255,n,0)G(1,m,255,0)G(2,0,255,n)G(3,0,m,255)G(4,n,0,255)G(5,255,0,m)default:throw std::exception();}}void r(Image&a,int x,int y){auto d=a.getSize();V<V<int>>m(d.x,V<int>(d.y));int i=0,j,c=0,t;for(;i<d.y;++i)for(j=0;j<d.x;++j)m[j][i]=a.getPixel(j,i)==C::Black?-1:0;V<T>e{{x,y,1}};while(e.size()){V<T>t=std::move(e);for(auto&a:t){m[a.x][a.y]=a.c;if(a.x>0&&m[a.x-1][a.y]==0&&!FI(-1,0))P({a.x-1,a.y,a.c+1});if(a.y>0&&m[a.x][a.y-1]==0&&!FI(0,-1))P({a.x,a.y-1,a.c+1});if(a.x<m.size()-1&&m[a.x+1][a.y]==0&&!FI(1,0))P({a.x+1,a.y,a.c+1});if(a.y<m[0].size()-1&&m[a.x][a.y+1]==0&&!FI(0,1))P({a.x,a.y+1,a.c+1});}}c=max(m)-1;for(i=0,j;i<d.y;++i)for(j=0;j<d.x;++j)if(m[j][i]>0)a.setPixel(j,i,hsv2rgb(360.f*(m[j][i]-1)/c));}

The sf::Image parameter is also the output ( will be modified ). You can use it like that :
sf::Image img;
if (!img.loadFromFile(image_filename))
    return -1;

r(img, 0, 0);

if (!img.saveToFile(a_new_image_filename))
    return -2;

The first parameter is the image input ( and output ), the second and third parameters are the x and y parameter where it needs to start

The switch case seems so wasteful that probably a macro definition would be useful... Also is the   at setPixel(j, i,hsv2 and FI(xm,ym) (std::find_if really necessary?

You can remove the space between G(d,a,b,c) and case d:. Also, the space between case d: and return C(a,b,c) is unneeded as well. (b>m?b:m) doesn't require the parentheses, and (t/60)%6 => t/60%6 by order of operations.

You should probably also rename xm and ym to shorter variable names

I think it's possible to remove the space between G(d,a,b,c)and case,  FI, ti, and hsv2rgb can each be replaced with a shorter name.

Matlab with DIPimage,  118 bytes - 30% = 82.6
function F(f,x,y),a=readim(f);m=a{1}>0;s=m|1;s(x,y)=0;h=gdt(s,[],m);n=~isinf(h);a(n)=lut(h(n),255*hsv(fix(max(h(n)))))

DIPimage has a function to compute Euclidean geodesic distance transform (gdt). It uses the Fast Marching algorithm, which produces a very reasonable approximation to Euclidean distances. See the docs.
DIPimage automatically displays the image
I'm using the idea from flawr's answer to create a colormap using hsv.

C++, 979 969 898 859 848 bytes
#include<cstdio>
#include<cstdlib>
#define K 400
#define L 400
#define M (i*)malloc(sizeof(i))
#define a(C,X,Y)if(C&&b[Y][X].c){t->n=M;t=t->n;b[Y][X].d=d+1;t->n=0;t->c=X;t->d=Y;}
#define A(n,d)case n:d;break;
#define F fgetc(f)
#define W(A,B) for(A=0;A<B;A++){
struct i{int c;int d;int v;i*n;}b[L][K]={0},*h,*t;float m=0;int main(){FILE*f=fopen("d","r+b");int x,y,d=0;W(y,L)W(x,K)b[y][x].c=F<<16|F<<8|F;}}rewind(f);x=165,y=155;h=M;h->c=x;h->d=y;b[y][x].d=d;t=h;while(h){i*p=b[h->d]+h->c;if(p->v)h=h->n;else{p->v=1;x=h->c;y=h->d;d=p->d;m=d>m?d:m;a(x>0,x-1,y)a(x<K-1,x+1,y)a(y>0,x,y-1)a(y<L-1,x,y+1)}}W(y,L)W(x,K)i p=b[y][x];unsigned char n=-1,h=p.d/(m/n),R=h%43*6,Q=n*(n-(n*R>>8))>>8,t=n*(n-(n*(n-R)>>8))>>8,r,g,b;switch(h/43){A(0,n,t,0)A(1,Q,n,0)A(2,0,n,t)A(3,0,Q,n)A(4,t,0,n)A(5,n,0,Q)}d=h?r|g<<8|b<<16:p.c?-1:0;fwrite(&d,1,3,f);}}}

Input: RGB data file (contained in file: d)
Output: RGBA RGB data file (outputted in file: d)
Example: convert -depth 8 -size "400x400" test.png d.rgb && mv -f d.rgb d && g++ -o test main.c && ./test
NOTE: the image size and start are controlled at a source level, if this is an issue add 50 bytes or something -- I just didn't care to change it to be honest.

Not exactly a direct "ungolf"  but this was a C prototype I mocked up first:
#include "stdio.h"
#include "stdlib.h"

struct i{
    unsigned int c;
    int d;
    int v;
}b[400][400]={0};

typedef struct q{
    int x;
    int y;
    struct q *n;
}q;
q *qu;
q *t;
float m=0;
int get_dist(int x, int y)
{
    int d = 0;

}

void flood(int x,int y,int d){
    qu=malloc(sizeof(q));
    qu->x=x;qu->y=y;b[y][x].d=d;
    t=qu;
    while(qu){
        struct i *p = &b[qu->y][qu->x];
        if(p->v){qu=qu->n; continue;}
        p->v=1;x=qu->x;y=qu->y;d=p->d;
        #define a(C,X,Y) if(C&&b[Y][X].c){t->n=malloc(sizeof(q));t=t->n;b[Y][X].d=d+1;t->n=0;t->x=X;t->y=Y;}
        a(x>0,x-1,y);
        a(x<399,x+1,y);
        a(y>0,x,y-1);
        a(y<399,x,y+1);
        m=p->d>m?p->d:m;
    }
}

unsigned int C(int h)
{
    int r=0,g=0,b=0;
    int s=255,v=255;
    unsigned char R, qq, t;

    R = h%43*6;

    qq = (v * (255 - ((s * R) >> 8))) >> 8;
    t = (v * (255 - ((s * (255 - R)) >> 8))) >> 8;

    switch (h / 43){
        case 0: r = v; g = t; break;
        case 1: r = qq; g = v; break;
        case 2: g = v; b = t; break;
        case 3: g = qq; b = v; break;
        case 4: r = t; b = v; break;
        case 5: r = v; b = qq; break;
    }

    return r|(g<<8)|(b<<16)|255<<24;
}

#define F fgetc(f)
int main()
{
    FILE *f=fopen("d", "r+b");
    for(int y=0; y<400; y++){
        for(int x=0; x<400; x++){
            b[y][x].c = (F<<24)|(F<<16)|(F<<8);
        }
    }
    rewind(f);
    flood(165,155,1);
    m/=255.f;
    for(int y=0; y<400; y++){
        for(int x=0; x<400; x++){
            struct i p = b[y][x];
            unsigned int h = C(p.d/m);
            int o = p.c?-1:255<<24;
            if(p.d)fwrite(&h,4,1,f);
            else fwrite(&o,4,1,f);
        }
    }
}

Many concepts remain similar, but there are certainly a myriad of tiny changes.  To compile that as C you do need to use C11 (C99 will probably work but I only strictly tested in C11).

I quite enjoyed this challenge, thanks for giving me the idea to try something new :).

Edit: Golf'd a bit better.
Edit2: Merged two structs so my pixel struct and queue are the same, bit more macro abuse, and reflowed uses of 255 such that it can be defined as -1 when defining a series of unsigned chars, and lastly removed a function call.
Edit3: Reused a few more variables, operator precedence tweaks, and output converted to RGB saving the alpha channel
Edit4: I think I am done with this now, some pointer arithmetic changes and slight control flow tweaks.

783 bytes

Python 3 and matplotlib, 251 227 bytes
from pylab import*
def f(i,p):
 h,w,_=i.shape;o=ones((h,w))/0;q=[p+[0]]
 while q:
  x,y,d=q.pop(0)
  if w>x>=0and h>y>=0and i[y,x,0]:o[y,x]=d;i[y,x]=0;d+=1;q+=[[x-1,y,d],[x+1,y,d],[x,y-1,d],[x,y+1,d]]
 imshow(i);imshow(o,'hsv')

The input is an MxNx3 numpy array as returned by matplotlib's imread() function. The input is modified by the function so it should be copied beforehand. It displays the image automatically if matplotlib is in "interactive" mode; otherwise a call to show() should be added for another 7 bytes.
The output is created by first displaying the original image and then displaying the rainbow image overtop of it. Matplotlib conveniently treats inf and nan as transparent so the black and white image shows through.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Get happy and mad
Requirements
You need to make a smiley face go from smiling to frowning and back. There needs to the below faces in the code: Smiling, no expression, frowning, no expression, and then back to smiling. The new face needs to replace the old face flipbook style so that there's only one face on the screen at a time. There is no input required it will just be a loop that displays one face, pauses for 200 milliseconds, and replaces the current face with the next and so on looping forever.
Faces to use:
                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOO     OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO     OOOOo
   oOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO OOOOOOo
    *OOOOO  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  OOOOO*
    *OOOOOO  *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*  OOOOOO*
     *OOOOOO  *OOOOOOOOOOOOOOOOOOOOOOOOOOO*  OOOOOO*
      *OOOOOOo  *OOOOOOOOOOOOOOOOOOOOOOO*  oOOOOOO*
        *OOOOOOOo  *OOOOOOOOOOOOOOOOO*  oOOOOOOO*
          *OOOOOOOOo  *OOOOOOOOOOO*  oOOOOOOOO*
             *OOOOOOOOo           oOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*
                      ""ooooooooo""

                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
     *OOOOOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOOOO*
      *OOOOOOo                             oOOOOOO*
        *OOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOO*
          *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
             *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*
                      ""ooooooooo""

                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
    *OOOOOOOOOOOOOO                  OOOOOOOOOOOOOOO*
     *OOOOOOOOOOO                      OOOoOOOOOOOO*
      *OOOOOO       OOOOOOOOOOOOOOOO        OOOOOO*
        *OOOOO   OOOOOOOOOOOOOOOOOOOOOO   OOOOOO*
          *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
             *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*
                      ""ooooooooo""

                      __ooooooooo__
                 oOOOOOOOOOOOOOOOOOOOOOo
             oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
          oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
        oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
      oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
     oOOOOOOOOOOO*  *OOOOOOOOOOOOOO*  *OOOOOOOOOOOOo
    oOOOOOOOOOOO      OOOOOOOOOOOO      OOOOOOOOOOOOo
    oOOOOOOOOOOOOo  oOOOOOOOOOOOOOOo  oOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
   oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
    *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
     *OOOOOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOOOO*
      *OOOOOOo                             oOOOOOO*
        *OOOOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOoOOOOOO*
          *OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
             *OOOOOOOOOOOOOOOOOOOOOOOOOOOOO*
                 *OOOOOOOOOOOOOOOOOOOOO*
                      ""ooooooooo""

Only one face shows up at a time and it should loop forever cycling between happy indifferent and sad.
Goal
Have the shortest code is always the goal but being able to tell that the output is actual a face is quite important.

Is the input one face, and the output the next in the sequence? Or is there no input, and it has to output a face, pause, clear and output the next face, etc? And if the latter, is it a single loop or does it loop forever? 2. If the goal is having the shortest code, why is the winner the post with the most upvotes rather than the post with the shortest code?

Welcome to PPCG. Popularity contests of this type are generally not well received, as they are more of an art contest than a prgramming contest. A better way to go with this challenge would be for you to design some faces  and make it a codegolf, so the winning depends on programming skill, like this: http://codegolf.stackexchange.com/q/49671/15599 . I think this is too simple Please stick around and answer a few challenges to get a feel for the site. Also, you can post challenges to our sandbox for feedback before they go live http://meta.codegolf.stackexchange.com/q/2140/15599

No input it just starts the sequence. It can be a single loop that lasts forever and I'll change it to the shortest code as per both pete and steveverrill suggested.

@PeterTaylor being able to tell that the output is actall a face is quite important. I think OP's intention is that we can redesign the face, but as that isn't a good idea (because everyone will just go :) to be as short as possible), I think you've jumped ahead. I think you are right, the challenge should have faces prescribed by the OP.

I've given you an upvote and a reopen vote, but there's a few things you could make clearer: I understand the sequence is 4 steps: smile, neutral, frown, neutral? Also, how long should each face be displayed? (if you don't specify a time, it seems like it's acceptable to display the next face immediately (in a millisecond), which would look rubbish, but in codegolf every byte counts, so you should specify a time to be fair.)

Added the neutral face back as the fourth face as it does need to cycle back in reverse order. Also defined that the pause is 200 milliseconds

Python 2 - 461/442 bytes
461 bytes:
f='eNrtlkEOwyAMBO+8wuLoz/gJPIH/3yKVhC62AVeVKrUNR7KDceJdhchbpdRrlZLM4yreqikg8sRr\npdZH1EhE9cAgwkQ8ivROg5BphWW5Yymp5rJm50G90pHGzD2c1TVYjQJlCFvj86w91SQMlJiXLuYb\nCFAxTEOXuM4x7v1zH0CWBfYEgAChgkA+6BVircLWlTzrgCi5Lqecu81zThPRnQW/mgUfwzZmdob2\nDQqMs7qXNhJbs9Fs2HUWBAq5YRBoJsbcaXCnwZ+lgR3NTRq4zMnN0sA/WcaKOg2mP1gO8R1hcACw\nDCfh\n'.decode('base64').decode('zlib').split("\n\n");import os,time;f+=[f[1]];i=0
while 1:os.system('cls');print f[i];i=(i+1)%4;time.sleep(.2)

442 bytes requiring ansi code support:
f='eNrtlkEOwyAMBO+8wuLoz/gJPIH/3yKVhC62AVeVKrUNR7KDceJdhchbpdRrlZLM4yreqikg8sRr\npdZH1EhE9cAgwkQ8ivROg5BphWW5Yymp5rJm50G90pHGzD2c1TVYjQJlCFvj86w91SQMlJiXLuYb\nCFAxTEOXuM4x7v1zH0CWBfYEgAChgkA+6BVircLWlTzrgCi5Lqecu81zThPRnQW/mgUfwzZmdob2\nDQqMs7qXNhJbs9Fs2HUWBAq5YRBoJsbcaXCnwZ+lgR3NTRq4zMnN0sA/WcaKOg2mP1gO8R1hcACw\nDCfh\n'.decode('base64').decode('zlib').split("\n\n");import time;f+=[f[1]];i=0
while 1:print'<ESC>[f'+f[i];i=(i+1)%4;time.sleep(.2)

<ESC> is a literal escape character (code 27). This program assumes that the terminal it is running on starts out blank

Mathematica, 478 470 bytes
i=0;Dynamic[Uncompress["1:eJzt1rsKwjAUBuAOPkjNmEl9BHUUAnYVAg6CU4b6/nhNPLekR6hCJWcQqf/XpFp/Oj+G/WnWNE1/f9md+0u3vr1rxfE+xPH+sFiuWCI4aQLLyrlMvhwWiAYQpCWYQWXb1uIcPZIcZM/lXfGICF1gu2ZHIiQ5xSDJNiRMypA1hxzIpMu0rzMOw2fEYujYL0HGxlMnqJOCi/mQlzZ9FxbepDEuyrfBCGSJA4ISovj/iueRwTsTs48xJtWDMd221oiWQfXHNfJjOVACfGiNfA7B/6y0Qe5AjRQmMBahYrlcj+guTMe+UiSbWiRaBlUtkrHkaEXC7+AcRFK++V2xSOTzuxYdF4pEMA5/MNkeqQ8kagZV7ZGxZH0gQctNtUiuFNCEqg=="][[i=i~Mod~4+1]],UpdateInterval->.2,TrackedSymbols->{}]

JavaScript (ES6), 613 bytes
setInterval(_=>(c=console).clear()||c.log((` 16__o6__
 11oO18o
 7oO26o
 4oO32o
 2oO36o
 0oO40o
  oO8*  *O11*  *O9o
 oO8 3O9 3O9o
 oO9o  oO11o  oO10o
oO46o
`+[`oO1 2O28 2O1o
oO3 O32 O3o
 *O2  O30  O2*
 *O3  *O26*  O3*
  *O3  *O24*  O3*
 0*O3o  *O20*  oO3*
 2*O4o  *O14*  oO4*
 4*O5o  *O8*  oO5*
 7*O5o 8oO5*`,n=`oO46o
oO46o
 *O44*
 *O44*
  *O5oO24oO5*
 0*O3o 26oO3*
 2*O2oO24oO2*
 4*O32*
 7*O26*`,`oO46o
oO46o
 *O44*
 *O11 15O12*
  *O8 19O9*
 0*O3 4O13 5O3*
 2*O2 0O19 0O3*
 4*O32*
 7*O26*`,n][i++%4]+`
 11*O18*
 16""o6""`).replace(/.\d+/g,r=>r[0].repeat(+r.slice(1)+3))),i=200)

Explanation
Uses a simple run-length encoding scheme to compress the string. Any character can optionally have a number directly after it which tells the decompressor to print that character n + 3 times (eg. ab4c will become abbbbbbbc).
Without this compression the code size is just over 2000 bytes.
setInterval(
  _=>(c=console).clear()||c.log(            // clear and display the face in the console
    (                                       // piece together the appropriate string
      `TOP`+                                // run-length encoded face top string
      [`HAPPY`,n=`NEUTRAL`,`SAD`,n][i++%4]+ // encoded mouth string
      `BOTTOM`                              // encoded face bottom string
    )
      .replace(/.\d+/g,                     // search for each character-number instance
        r=>r[0].repeat(+r.slice(1)+3)       // repeat the character n + 3 times
      )
  ),
  i=                                        // i = iterator
    200                                     // set interval to 200ms
)

This doesn't clear the screen before printing each face.

@ppperry Oh, I must have missed that in the question! I've fixed it now.


text:
Gravity simulator
Statement
You are given a still of a series of balls falling in a 2D grid. This grid is surrounded by immutable and unbreakable walls so all the action is contained within them. Your task is to determine what the state of the scenario will be after gravity does all it's work.
Elements inside grid

-  Floor, doesn't alter the direction of falling balls.
\  Right slide, alters the path of the ball one (1) position right.
/  Left slide, alters the path of the ball one (1) position left.
o  A ball.

Rules

Balls fall.
Floors and slides don't fall.
If the ball hits a slide that would make it go through a wall (\#or#/), or cross through a floor the slide will act as a floor.
When a ball hits another ball the will become one ball, but increase their power to the sum of both balls.
New balls (joined) will continue to behave as usual.
When a ball can't move anymore, it's replaced by its power.
The power of a ball will always be at most 9.

Input
The grid will be given in a string variable with whatever name is shortest in your language of choice. By default we will use a as the input.
A sample of an input, exactly as received:
##########\n# \      #\n#o       #\n#  - -\o #\n#/-    \ #\n#  \oo-/\#\n#-/ \   /#\n#   \ \  #\n#       /#\n##########

For random grids generated use https://repl.it/B1j3/2. Use my generated page instead (no ads, no crap, just the input and the output)
Note line breaks are \n. Printing the input to screen (not required for the challenge) would show things like this. Although I've put four puzzles alongside to safe space.
##########  ##########  ##########  ##########
# \      #  # o    -/#  #       o#  #-o /    #
#o       #  #    \   #  # o     -#  #-- \ /\ #
#  - -\o #  #-  \    #  #    - \o#  # - -- o-#
#/-    \ #  #        #  #o /\    #  #/ \     #
#  \oo-/\#  #o  -o-  #  # /    -o#  #/ /o oo/#
#-/ \   /#  #   -/-  #  # -  o  -#  #o/      #
#   \ \  #  #    \\  #  #   \o  /#  #o-o    o#
#       /#  # \o\  /\#  #     \o #  # -\o o /#
##########  ##########  ##########  ##########

Output
The same grid, printed to screen with the final result of ball power. A valid answer would be one (1) of the following puzzles, each one corresponds to the input at the same position, of course if the input is different you should adjust the output. Not limit it to those four!
##########  ##########  ##########  ##########
# \      #  #      -/#  #       1#  #-1 /    #
#        #  #    \   #  #       -#  #-- \ /\ #
#1 - -\  #  #-  \    #  #    - \ #  # - --  -#
#/-    \1#  #        #  #  /\    #  #/ \     #
#  \  -/\#  #   -1-  #  # /    -2#  #/ /    /#
#-/ \   /#  #   -/-  #  # -     -#  # /      #
#   \ \  #  #    \\  #  #   \   /#  # -      #
#    2  /#  #1\2\  /\#  #2   2\1 #  #2-\3 23/#
##########  ##########  ##########  ##########

Score
Languages will compete against themselves so feel free to use nongolf languages. To validate a solution I must be able to test it somewhere to see it works!.
Score is number of bytes. In the event of a tie, the first answer to reach the tied score wins.
Warnings

If unsure of how a ball should react, ask me and I'll clarify, I've been as clear as I could but I'm sure there are cases that are confusing.
Slides are only ridden if you can exit them, think about it like a real slide. There's a guy at the top that doesn't let you through the ball unless it will exit through the other side.

Clarifying examples of ball movement
######                       ######
#-o- #    BALL WOULD GO RD   #- - #
# \  #                       # \o #
######                       ######

######                       ######
#-o- #     BALL WOULD STAY   #-o- #
# \\ #                       # \\ #
######                       ######

######                       ######
#  -o#     BALL WOULD STAY   #  -o#
#   \#                       #   \#
######                       ######

######                       ######
#  o #     BALL WOULD STAY   #  o #
#  \/#                       #  \/#
######                       ######

######                       ######
#-o- #    BALL WOULD GO LD   #- - #
# /\ #                       #o/\ #
######                       ######

How can I test if my answer is valid?
I've set up a simple page in one of my sites that will give you a random puzzle, and its answer. Take the input and check it against the output. My solution, without worrying too much about golfing is 389b 355b in python (generator, and page also python)
Leaderboard

var QUESTION_ID=64359,OVERRIDE_USER=8478;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

I'm reminded of Marbelous.

Bonus points if anybody answers in Marbelous.

Borderline dupe of A Mere Bagatelle and Not Your Routine Bean Machine

sounds like potentially an ascii-art pinball game

@JuanCortés why don't you use the fancy leader board code so you don't have to update the rankings yourself?

Didn't know it existed, but got it :)

Should we really care about a ball having power > 9 ? For instance @usandfriends solution does not handle that case

For this first challenge no, it's a very edge case that might be plausible but no. Max 9

@JuanCortés I'm thinking of starting a 1000 point bounty for a Marbelous solution. Can you discuss in chat to iron out the details first?

I feel like this question is a dupe

I'm sorry you feel that way

What about " o\n_/"?

Marbelous, 19561 bytes
(Not that I tried to optimize the size.)
This claims the final bounty here.
This expects a trailing newline in the input. It works for boards up to 15x15 (including the edges) but I feel like this is reasonable as that is a direct result of the num size limit being 255. Please use my interpreter as I can make no guarantees about other interpreters. It is based on the one here but with a few bug fixes and an added debugger.
To solve the boards in the example takes about 330000 ticks. That is mostly due to the difficulty of arbitrary data storage. Marbelous is not turning complete so I have to use a big rotating tape to store the board. The code is divided into roughly three sections. (Separated by those four big lines of %%).

This gets the full input and converts it to the encoding expected by the rest of the code. It also populates the initial fields of the main processing loop.
This function takes a t of values (ie one square and the three below it) and figures out the state after one tick. It then outputs all the values that need to be sent to the memory tape or terminates the program if we are complete.
This is the memory tape. It is possible to read or write to it by sending values to the appropriate portals.

Overall this is an interesting language that could be fun if it is made turning complete. I do feel that the coding can get a bit repetitive (it is mostly just lots of &0s) but it is still fun.
# ENCODING:
# 0 = empty square
# 1-9 = that many marbles
# A = wall
# B = right ramp
# C = left ramp
# D = reset count
# E = nothing

.. @B .. .. .. .. .. .. .. @C .. .. .. .. .. .. .. .. .. .. ..
.. 00 00 // // // // // // // .. .. .. .. .. .. .. .. .. .. ..
.. ge t_ in pu t_ +_ in it .. .. .. .. .. .. .. .. .. .. .. ..
.. @B @C .. .. &A .. .. @K .. .. .. .. .. .. .. .. .. .. .. ..
%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%
.. .. .. .. .. .. .. \\ \\ \\ \\ .. .. .. .. .. .. .. .. .. ..
.. .. .. // .. .. \\ \\ \\ .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. \\ \\ %% @4 %% @9 %% .. .. .. .. .. .. .. .. ..
.. .. .. .. \\ %% @3 \\ .. .. &4 .. .. .. .. .. .. .. .. .. ..
.. .. .. .. @2 \\ \\ .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. %% @1 \\ \\ .. .. .. .. // .. @A .. .. .. .. .. .. .. ..
0A @0 \\ \\ \\ .. 01 .. .. .. .. // // .. .. .. .. .. .. .. ..
\\ \\ \\ \\ ti ck _r et ur n_ pr in t_ an d_ te rm in at e_ pg # ys: v0 v3
.. .. .. .. @0 @1 @2 @3 @4 .. &0 &1 &2 .. &0 &1 &2 &3 &4 &3 &4 # xs: v1 v2 l0 w sl
.. .. .. .. .. .. .. .. .. \\ \\ \\ @5 \\ \\ \\ @6 \\ @7 \\ @8 # @5 = write loc
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. # @6 = write val
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. # @7 = read loc
.. .. .. .. .. .. .. .. .. .. .. .. \/ .. .. .. \/ .. \/ .. \/ # @8 = read ret loc
%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% @D @E 01 .. %% # Acts as a switchboard
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% &5 &5 // .. %% # to activate the right
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% pl us .. .. %% # gate when a write is
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% =1 =2 =3 =4 %% # complete
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% &0 &1 &2 &3 %%
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% ++ ++ ++ eo %%
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% \\ \\ \\ @E %%
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. %% %% %% %% %% %%
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. @G @K .. ..
.. .. @P 0E .. .. @O 0E .. .. @N 0E .. .. @M 0E .. \\ .. .. ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 .. ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E .. \\ &9 0E ..
.. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // .. 0E &9 // ..
.. \\ &9 0E .. \\ &9 .. .. \\ &9 .. .. \\ &9 .. .. \\ &9 .. ..
.. 0E &9 // .. .. @P .. .. .. @O .. .. .. @N .. .. .. @M .. ..
.. \\ &9 0E .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. 0E .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. &A .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. \\ \\ .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. // // .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. \\ \\ .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. // // .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. \\ \\ .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. // // .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. 01 .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. .. ng .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. &A .. @5 .. @7 .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. .. .. .. du pe du pe .. .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. .. .. ez @L ez .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. .. .. .. +2 .. +3 .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. .. .. @H .. .. .. .. .. .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. .. // // // // .. .. .. .. .. .. .. .. ..
.. \\ &9 0E .. .. .. .. .. @I .. .. .. @L .. .. .. .. .. .. ..
.. 0E &9 // .. .. .. .. .. // // // // // .. .. .. .. .. .. ..
.. \\ &9 0E .. .. @F .. .. .. @J @8 @6 .. .. .. .. .. .. .. ..
.. .. &9 // .. .. 00 01 00 00 // // // .. .. .. .. .. .. .. ..
.. .. \\ \\ \\ lo op er lo op er lo op .. .. .. .. .. .. .. ..
.. .. .. .. .. @G @F @H @I @J @D @9 @A .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..

# value, position, mode, w/r-location, input, wrote, read1, read2
#
# mode 0 = waiting
# mode 1 = inputing
# mode 2 = writing
# mode 3 = reading
:looper
# &6 = reset
# &5 = not reset
#
# &7 = writing and match
# &8 = writing and no match
#
# &9 = reading and match
# &A = reading and no match
#
# mode 1: output nothing
# mode 2:
}2 .. %% }0 .. %% 00 01 00 00 00 .. .. .. .. .. ..
>0 &0 %% =D &5 %% &1 &1 &1 &1 &1 .. .. .. .. .. ..
.. \/ %% &6 \/ %% {1 {2 {3 {4 \\ !! .. .. .. .. ..
>1 &1 %% \/ .. %% %% %% %% %% %% %% %% %% %% %% %%
.. \/ %% .. .. %% }1 }3 .. }4 }1 00 00 00 00 .. ..
>2 &2 %% %% %% %% &2 &2 .. .. ++ .. .. .. .. .. ..
.. \/ %% .. .. %% mi nu .. &7 &7 &7 &7 &7 &7 .. ..
>3 &3 %% .. .. %% =0 &8 .. {0 {1 {5 {3 {4 \\ !! ..
&4 \/ %% .. .. %% &7 .. .. .. .. .. .. .. .. .. ..
\/ .. %% .. .. %% .. .. }0 }0 }1 .. .. .. .. .. ..
.. .. %% .. .. %% .. .. .. ne wl 02 }3 }4 00 .. ..
.. .. %% .. .. %% .. .. &8 &8 .. &8 &8 &8 &8 .. ..
.. .. %% .. .. %% .. .. {0 {1 .. {2 {3 {4 \\ !! ..
.. .. %% .. .. %% %% %% %% %% %% %% %% %% %% %% %%
.. .. %% .. .. %% }1 }3 .. }0 }1 00 00 }4 }0 00 ..
.. .. %% .. .. %% &3 &3 .. .. ++ .. .. &9 &9 .. ..
.. .. %% .. .. %% mi nu .. &9 &9 &9 &9 se nd &9 ..
.. .. %% .. .. %% =0 &A .. {0 {1 {3 {4 {6 {7 \\ !!
.. .. %% .. .. %% &9 .. .. .. .. .. .. .. .. .. ..
.. .. %% .. .. %% .. .. }0 }0 }1 .. .. .. .. .. ..
.. .. %% .. .. %% .. .. .. ne wl 03 }3 }4 00 .. ..
.. .. %% .. .. %% .. .. &A &A .. &A &A &A &A .. ..
.. .. %% .. .. %% .. .. {0 {1 .. {2 {3 {4 \\ !! ..
.. .. %% .. .. %% .. .. .. .. .. .. .. .. .. .. ..
.. .. %% .. .. %% .. .. .. .. .. .. .. .. .. .. ..

:newl
# }0 = 0 -> same
# }0 = D -> 0
# else -> }1 + 1
}0 .. ..
=E =D ..
&0 &1 &2
\/ \/ \/
}1 00 }1
.. .. ++
&0 &1 &2
{0 {0 {0

# Tik, Return, Print, and Terminate Program
#
# 0,1,9-C,
#
:tick_return_print_and_terminate_pg
%% %% %% %% %% %% %% %% %% %% %% %% %%
%% }2 }3 }4 00 01 }2 }2 }2 }2 }2 }2 %% # Echo values that should be echoed
%% ++ .. .. .. .. ++ +2 .. -- .. ++ %%
%% .. .. .. .. .. .. }3 .. }3 }3 }3 %%
%% &0 &0 &0 &0 &0 &0 &0 &0 &0 &0 &0 %%
%% {2 {3 {4 {F {G {D {E {5 {6 {7 {8 %%
%% %% %% %% %% %% %% %% %% %% %% %% %%
%% .. .. .. .. %% .. }5 }0 }1 }6 .. %% # (left)  prints the cell
%% .. .. .. .. %% .. so lv ev ls .. %% # (right) solve the position
%% .. .. .. .. %% // // .. .. .. .. %%
%% .. }3 }2 .. /\ \\ .. .. .. .. .. %%
%% .. pr in tc %% .. &0 &0 &0 &0 .. %%
%% .. .. .. .. %% .. {9 {A .. du pe %%
%% .. .. .. .. %% .. .. .. // {C {1 %%
%% .. .. .. .. %% .. .. du pe .. .. %%
%% .. .. .. .. %% .. .. {B {0 .. .. %%
%% %% %% %% %% %% %% %% %% %% %% %% %%
%% .. }4 }2 .. .. .. .. .. .. .. 00 %% # Check if the program should terminate
%% .. mi nu .. .. .. .. }3 .. .. &1 %%
%% .. \\ \\ \\ =0 &0 .. &1 .. .. .. %%
%% .. .. .. .. &1 \/ .. pb .. .. .. %%
%% .. .. .. .. \/ .. .. .. .. .. !! %%
%% %% %% %% %% %% %% %% %% %% %% %% %%

# Get Input and Initlize
#
# gets the full board input
:get_input_+_init
# 1) }1 = 0 then print char }0++
# 2) }1 = 0 & char = \n then }1 = }0, }0 := 0
# 3) }1 != 0 & char != \n then }1++
# 4) eof then output stop
# 5) }0 = 1 or w-1 or w or w+1 & }1 != 0 output v
# 6) }1 != 0 output encoding
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. 00 .. .. .. .. .. .. .. .. .. .. .. .. .. }0 }1 ..
.. ]] &1 .. .. .. .. .. .. .. .. .. .. .. .. mi nu ..
.. .. \/ .. .. }0 }1 .. .. .. .. .. .. .. .. -2 .. 0D
.. \\ \\ \\ c+ ge t_ in pu t_ +_ in .. .. .. &1 .. &1
.. .. .. .. // .. .. .. .. .. .. .. .. .. .. /\ {4 {7
.. .. .. /\ {0 {1 {2 {3 {4 {5 {6 {7 .. .. !! .. .. ..
.. .. !! .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..

# Char + Get Input and Initlize
#
# gets the full board input
:c+get_input_+_init
# &0 = no width
# &1 = width
# &2+&9 = newline
# &3+&8 = not newline
# &4 = no width & newline
# &5 = no width & !newline
# &6 = width & newline
# &7 = width & !newline
# &A/B/B = release v0/2/3
.. .. .. .. %% 00 00 %% .. .. .. .. .. .. .. .. .. .. .. .. ..
}2 .. .. .. %% &0 &0 %% }0 .. }1 00 .. 00 }1 }1 .. }0 }1 }2 ..
=0 &1 .. .. %% &2 &3 %% &0 .. &5 &5 .. &4 &4 &4 .. ec ++ .. ..
&0 \/ .. .. %% &4 &5 %% [[ .. ++ .. .. {0 {1 {3 .. &7 &7 &7 ..
\/ .. .. .. %% \/ \/ %% .. .. {0 {1 .. .. .. .. .. {7 {0 {1 ..
%% %% %% %% %% %% %% %% .. .. .. .. .. .. .. .. .. .. .. .. ..
}0 .. .. .. %% 00 00 %% }1 }2 .. }0 }0 }0 .. 23 .. .. .. .. ..
=A \\ du pe %% &1 &1 %% &6 &6 .. ec ec ec .. &4 .. .. .. .. ..
du pe &3 &8 %% &9 &8 %% {0 {1 .. &A &B &C .. [[ .. .. .. .. ..
&2 &9 \/ \/ %% &6 &7 %% .. .. .. {5 {2 {6 .. .. .. .. .. .. ..
\/ \/ .. .. %% \/ \/ %% .. .. .. .. .. .. .. .. .. .. .. .. ..
%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%
}1 .. .. }1 .. .. }1 .. .. .. .. .. .. .. .. .. .. .. .. .. ..
&7 .. .. &7 }2 .. &7 }2 .. .. .. .. .. .. .. .. .. .. .. .. ..
=1 \/ .. mi nu .. mi nu .. .. .. .. .. .. .. .. .. .. .. .. ..
&A .. .. =1 \/ .. =2 \/ .. .. .. .. .. .. .. .. .. .. .. .. ..
\/ .. .. &B .. .. &C .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. \/ .. .. \/ .. .. .. .. .. .. .. .. .. .. .. .. .. ..
00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ !!

# Encoding
#
# convert the char code to the encoding
:ec
}0 .. .. .. .. ..
++ .. .. .. .. ..
>> .. .. .. .. ..
>> .. .. .. .. ..
=S =B =C =N =9 ..
&0 &1 &2 &3 &4 &5
\/ \/ \/ \/ \/ \/
01 0A 0C 0B 0A 00
&0 &1 &2 &3 &4 &5
\\ \\ \\ {0 // //

# Print Bottom
#
# prints #\n then # repeated }0 times
:pb
0A .. @0 .. @1 ..
23 .. &0 .. &0 ..
[[ 23 /\ [[ -- ..
.. @0 .. }0 >0 \/
.. .. .. \\ @1 ..

# Print Cell
#
# }0 = the width of the board
# }1 = the position of the cell to print
# }2 = the cell to print
#
# prints the cell and a newline if needed
:printc
%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%
%% }0 }1 %% .. %% }2 .. .. .. .. %% .. .. .. .. }2 %% }1 }0 %% .. %%
%% is bd %% 23 %% &0 .. .. .. .. %% 20 2D 5C 2F tn %% ++ .. %% 0A %%
%% =1 &0 %% &1 %% =0 =A =B =C <A %% &2 &3 &4 &5 &6 %% di vb %% &7 %%
%% &1 \/ %% [[ %% &2 &3 &4 &5 &6 %% [[ [[ [[ [[ [[ %% =1 \/ %% [[ %%
%% \/ .. %% .. %% \/ \/ \/ \/ \/ %% .. .. .. .. .. %% &7 .. %% .. %%
%% .. .. %% .. %% .. .. .. .. .. %% .. .. .. .. .. %% \/ .. %% .. %%
%% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %% %%

# Is Border
#
# }0 = board width
# }1 = position
#
# {0 = 1 if on border else 0
:isbd
}1 }0 }1 }0
.. .. ++ ..
di vb di vb
\\ {0 // ..

# Solve Values
#
# takes input in a t:
# takes 4 cells in a t shape:
#       x    or    1
#      xxx        234
# and returns their values
# after 1 tick
:solvevls
# &0) center is space
# &1) center is wall
# &2) left slide & left is space
# &3) left slide & left isn't space
# &4) right slide & right is space
# &5) right slide & right isn't space
# &7) no ball
%% %% %% %% %% %% %% %% %% %% %%
%% }0 .. .. .. .. .. .. .. .. %% # Top Center
%% du pe 6x 6x 6x 6x .. .. .. %%
%% <A <A <A <A <A <A &7 .. .. %%
%% &0 &1 &2 &3 &4 &5 \/ .. .. %%
%% \/ \/ \/ \/ \/ \/ .. .. .. %%
%% %% %% %% %% %% %% %% %% %% %%
%% }1 .. .. .. .. .. .. .. .. %% # Bottom Left
%% du pe 6x 6x 6x 6x .. .. .. %%
%% .. .. 9 .. .. \/ .. .. %%
%% .. .. &2 &3 .. .. .. .. .. %%
%% \/ \/ \/ \/ \/ \/ .. .. .. %%
%% %% %% %% %% %% %% %% %% %% %%
%% }2 .. .. .. .. .. .. .. .. %% # Bottom Center
%% du pe 6x 6x 6x 6x .. .. .. %%
%% <A =A =C =C =B =B \/ .. .. %%
%% &0 &1 &2 &3 &4 &5 .. .. .. %%
%% \/ \/ \/ \/ \/ \/ .. .. .. %%
%% %% %% %% %% %% %% %% %% %% %%
%% }3 .. .. .. .. .. .. .. .. %% # Bottom Right
%% du pe 6x 6x 6x 6x .. .. .. %%
%% .. .. .. .. 9 \/ .. .. %%
%% .. .. .. .. &4 &5 .. .. .. %%
%% \/ \/ \/ \/ \/ \/ .. .. .. %%
%% %% %% %% %% %% %% %% %% %% %%
%% .. .. }0 .. %% .. .. .. .. %%
%% 00 }1 }2 }3 %% }0 }1 }2 }3 %%
%% &0 &0 &0 &0 %% &1 &1 &1 &1 %%
%% {0 {1 {2 {3 %% {0 {1 {2 {3 %%
%% %% %% %% %% %% %% %% %% %% %%
%% .. }0 .. .. %% .. .. .. .. %%
%% 00 }1 }2 }3 %% }0 }1 }2 }3 %%
%% &2 &2 &2 &2 %% &3 &3 &3 &3 %%
%% {0 {1 {2 {3 %% {0 {1 {2 {3 %%
%% %% %% %% %% %% %% %% %% %% %%
%% .. .. .. }0 %% .. .. .. .. %%
%% 00 }1 }2 }3 %% }0 }1 }2 }3 %%
%% &4 &4 &4 &4 %% &5 &5 &5 &5 %%
%% {0 {1 {2 {3 %% {0 {1 {2 {3 %%
%% %% %% %% %% %% %% %% %% %% %%
%% .. .. .. .. %% .. .. .. .. %%
%% }0 }1 }2 }3 %% .. .. .. .. %%
%% &7 &7 &7 &7 %% .. .. .. .. %%
%% {0 {1 {2 {3 %% .. .. .. .. %%
%% %% %% %% %% %% %% %% %% %% %%

# @0 set tape to position
#    @7 gets zero once complete
# @1 send current marble to location + advance one
# @2 write to current marble + advance one

# &0 = marble tape
# &1 = counter

# @3 counter loop
# @4, @5, @6

# .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
# .. .. .. 08 @5 .. .. .. .. .. .. .. .. .. ..
# .. 07 &0 // // .. .. .. .. .. .. .. .. .. ..
# .. \\ &0 06 .. .. .. .. .. .. .. .. .. .. ..
# .. 05 &0 // .. .. .. .. .. .. .. .. .. .. ..
# .. \\ &0 04 .. .. .. .. .. .. .. .. .. .. ..
# .. 03 &0 // .. .. .. .. .. .. .. .. .. .. ..
# .. \\ &0 02 .. .. .. .. .. .. .. .. .. .. ..
# .. 01 &0 // .. .. .. .. .. .. .. .. .. .. ..
# .. \\ &0 00 .. .. .. .. .. .. .. .. .. .. ..
# .. 00 &0 // .. .. .. .. .. .. .. .. .. .. ..
# .. \\ &0 00 .. .. .. .. .. .. .. .. .. .. ..
# .. 00 &0 // .. .. .. .. .. .. .. .. .. .. ..
# .. \\ &0 .. .. .. .. .. .. .. .. .. .. .. ..
# .. .. /\ @5 .. .. .. .. 00 .. .. .. .. .. ..
# .. >0 @8 .. .. .. .. .. .. .. .. .. .. .. ..
# .. &1 .. .. .. .. .. .. .. .. .. .. .. .. ..
# .. .. .. .. .. .. .. @8 .. @9 .. .. .. .. ..
# .. .. .. .. .. .. .. \\ &0 // .. .. .. .. ..
# .. .. .. .. .. .. .. .. \/ .. .. .. .. .. ..
# .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
# .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
# .. .. .. .. .. .. .. .. @3 00 .. .. .. .. ..
# .. .. .. .. .. .. .. .. &1 // .. .. .. .. ..
# .. .. .. .. .. .. .. .. ++ .. .. .. .. .. ..
# .. .. .. .. .. .. .. @3 /\ .. .. .. .. .. ..
# .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
# .. .. .. .. .. .. 05 @0 @4 .. .. .. .. .. ..
# .. .. .. .. .. .. \\ \\ te st .. .. .. .. ..
# .. .. .. .. .. .. .. .. @4 .. =0 \\ .. .. ..
# .. .. .. .. .. .. .. .. .. .. @9 .. .. .. ..
# .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
# .. .. .. .. .. .. .. .. .. .. .. .. \/ .. ..

# Test Equality
#
# if }0 == }1 sends 00 to {0 and 01 to {>
# else sends }0 to {0 and 00 to {>
:test
}0 }1 .. .. .. .. ..
mi nu .. .. }0 .. ..
=0 \\ \\ &0 &0 .. ..
du pe 3x \/ du pe 3x
ez eo .. .. .. .. ez
{0 {> !! .. !! {0 {>

### SIMPLE HELPERS ###

# Send
#
# sends }1 to {0 if }0 = 0 else {1
:send
}0 .. 00
=0 &1 ..
&0 \/ ..
\/ .. ..
}1 }1 ..
&0 &1 ..
{0 {1 !!

# Marker
#
# does nothing
:%%
}0
{0

## EQUALS ##

# Equals Max
#
# sends FF to {0
:em
}0 FF
.. {0

# Equal One
#
# sends 01 to {0
:eo
}0 01
.. {0

# Equal Zero
#
# sends 00 to {0
:ez
}0 00
.. {0

## DUPLICATE ##

# Duplicate 2 times
#
# sends }0 to {0 and {1
:dupe
.. }0 ..
{0 /\ {1

# Duplicate 3 times
#
# sends }0 to {0, {1, and {2
:dupe3x
.. }0 .. ..
.. /\ .. ..
.. .. /\ ..
.. .. .. //
{0 {1 {2 ..

# Duplicate 4 times
#
# sends }0 to {0, {1, {2, and {3
:dupe4x4x
.. }0 .. .. ..
.. /\ .. .. ..
.. .. /\ .. ..
.. .. .. /\ ..
.. .. .. .. //
{0 {1 {2 {3 ..

# Duplicate 6 times
#
# sends }0 to {0, {1, {2, {3, {4 and {5
:dupe6x6x6x6x
.. }0 .. .. .. .. ..
.. /\ .. .. .. .. ..
.. .. /\ .. .. .. ..
.. .. .. /\ .. .. ..
.. .. .. .. /\ .. ..
.. .. .. .. .. /\ ..
.. .. .. .. .. .. //
{0 {1 {2 {3 {4 {5 ..

### MATH ###

# Divisible By
#
# returns }0 % }1 == 0
:divb
}0 }1
mo du
=0 &1
&0 ..
01 00
&0 &1
{0 {0

# Modulo
#
# sends }0 % }1 to {0
#
# if }0 > }1 return modu }0 - }1 else }0
:modu
}0 }1
Gt eq # interpreter includes this
=1 &0
&1 \/
\/ ..
}0 ..
&0 ..
{0 ..
.. ..
}0 }1
mi nu
&1 }1
mo du
{0 ..

# To Number Char
#
# converts number 0-9 to a number character
:tn
}0
+F
+F
+F
+3
{0

# Plus
#
# sends }0 + }1 to {0
:plus
}0 .. }1
\\ {0 //

# Minus
#
# sends }0 - }1 to {0
:minu
.. }1
}0 ng
\\ {0

# Negative
#
# sends -}0 to {0
:ng
}0
~~
++
{0

Amazing. I'd like to add to the bounty as well.

How fast is this? the interpreter linked is lagging my browser heavily.

Nevermind, it just took about a minute.

JavaScript (ES6), 157 196
Edit char by char instead of row by row, much better result
g=>(s=~g.search`
`,g=[...g]).map((c,i)=>c<' '?0:g[[0,1,-1].map(d=>!d|'\\ /'[d+1]==g[d+=i]&&+g[d+=s]?g[v+=+g[d],d+v-v]=' ':0,v=c>'a'?1:+c),i]=v?v:c)&&g.join``

Note: does not handle ball values > 9. But it could, with a 18 bytes cost. See basic code below.
TEST snippet (better full page)

F=g=>(s=~g.search`
`,g=[...g]).map((c,i)=>c<' '?0:g[[0,1,-1].map(d=>!d|'\\ /'[d+1]==g[d+=i]&&+g[d+=s]?g[v+=+g[d],d+v-v]=' ':0,v=c=='o'?1:+c),i]=v?v:c)&&g.join``

// Basic code, starting point before golfing
B=g=>{
  s = ~g.search('\n');
  (g=[...g]).map((c,i)=>{
    v = c == 'o' ? 1 : +c
    if (c>=' ' // skip newlines
        && !isNaN(v)) // digit or space
    {
      if (w=+g[i+s]) v += w, g[i+s]=' '
      if (g[i-1]=='\\' && (w=+g[i+s-1])) v += w, g[i+s-1]=' '
      if (g[i+1]=='/' && (w=+g[i+s+1])) v += w, g[i+s+1]=' '
      if (v) g[i] = v
    }
  })
  // return g.join``
  // To handle values > 9 ...
  return g.map(v=>+v?v%10:v).join``
}

function test() {
  O.textContent = F(I.value)
}

test()
textarea,pre { width: 15em; height: 15em; display: block; margin: 0; }
iframe { height: 25em; width: 15em}
td { vertical-align: top }

    Test cases
    Input

    Output

    Copy/paste test cases from here
(courtesy of OP)
    <button onclick="T.src='http://bohem.io/wadus/index.php'">reload</button>

    <textarea id=I>##########
#  o  o o#
# o\o o  #
#oo o/   #
#       o#
#     /o #
#\o   o  #
# o /-   #
#   o  - #
##########</textarea>
    <button onclick='test()'>Test</button>

Nice! I have a lot to learn in the ways of golf

shouldn´t you map values >9 with v>9?9:v?

@Titus I could, but in fact I could do whatever I want, as a value > 9 is not expected, see the comment by OP answering my question.

Javascript (ES6), 453 426 409 306 290 286 bytes
The first and most obvious solution that came to my mind is one that looks around the slides and then merges or replaces.
a=>{a=a.split`
`.map(b=>[...b.replace(/o/g,'1')]);for(r=1;r<a.length-1;r++){d=a[r];for(c=1;c<d.length-1;c++){e=a[r+1];f=e[c]=='\\'?c+1:e[c]=='/'?c-1:!isNaN(+e[c])?c:null;(''+d[c]).match(/[0-9]/g)&&f!=null&&!isNaN(+e[f])?(e[f]=+e[f]+ +d[c],d[c]=' '):0}}return a.map(b=>b.join``).join`
`}

Ungolfed:
func = state => {
    state = state.split `
`.map(line => [...line.replace(/o/g, '1')]);

    for (r = 1; r < state.length - 1; r++) {
        thisState = state[r];
        for (c = 1; c < thisState.length - 1; c++) {
            nextState = state[r + 1];
            nc = nextState[c] == '\\' ? c + 1 : nextState[c] == '/' ? c - 1 : !isNaN(+nextState[c]) ? c : null;

            ('' + thisState[c]).match(/[0-9]/g) && nc != null && !isNaN(+nextState[nc]) ? (
                nextState[nc] = +nextState[nc] + +thisState[c],
                thisState[c] = ' '
            ) : 0;
        }
    }

    return state.map(line => line.join ``).join `
`;
}

Test like:
func(`##########
# -- o - #
# \\\\\\ -  #
#-       #
# o  o   #
#o \\\\ /-\\#
#      \\ #
#/-  //  #
#   /- o #
##########`)

Thanks to: @edc65

I'll post my python when I'm sure I can't golf it anymore, but so far it's the python code that's generating the answer. Any way I can test your golfed code somewhere so I can pop you on the leaderboard? (jsfiddle,jsbin,ideone,whatever)

got it down to 355, your move!

@JuanCortés Done!

b.replace(/o/g,'1').split``  can be shortened to [...b.replace(/o/g,1)]

@edc65 I think I fixed it. Basically it always keeps the power under 10 by mod'ing 10.

@edc65 Okay I can remove the mod then and save a few bytes.

Java, Too Many 1102 987 bytes
Because, Java.
\o/ It's under 1000!
class G{class T{char s;int p=0;T(char c){s=c;}}T A=new T(' ');T[][]o;boolean i(){for(int i=1;i<o.length;i++)for(int j=1;j<o[i].length;j++)if(o[i][j].p>0){if(m(i,j,i+1,j)||o[i+1][j].s=='/'&&m(i,j,i+1,j-1)||o[i+1][j].s=='\\'&&m(i,j,i+1,j+1))return 1>0;int w=o[i][j].p;o[i][j]=new T(Integer.toString(w).charAt(0)){{p=w;}};}return 1<0;}boolean m(int a,int b,int c,int d){if(o[c][d]==A||o[c][d].p>0){o[a][b].p+=o[c][d].p;o[c][d]=o[a][b];o[a][b]=A;return 1>0;}return 1<0;}String s(){String s="";for(T[]r:o){for(T t:r)s+=t.s;s+="\n";}return s;}void f(String s){String[]r=s.split("\\\\n");o=new T[r.length][r[0].length()];for(int i=0;i<o.length;i++)for(int j=0;j<o[i].length;j++)switch(r[i].charAt(j)){case'-':o[i][j]=new T('-');break;case'\\':o[i][j]=new T('\\');break;case'/':o[i][j]=new T('/');break;case'o':o[i][j]=new T('o'){{p=1;}};break;case'#':o[i][j]=new T('#');break;default:o[i][j]=A;}}public static void main(String[]a){G g=new G();g.f(a[0]);while(g.i());System.out.println(g.s());}}

A side goal was being able to print every iteration of the board: just remove the middle ; in while(g.i()) ; System.out.print(g.s()); (Though this does disable the last print which has the 0->power conversion). Unfortunately, in this version, gravity works in strangely. Each pass I take the first non-stuck ball and move it. Short circuiting iterate() there is less bytes than going over the whole board then returning if anything changed.
This is a complete main class, compile and run on the command line with argument:
java -jar G.jar "##########\n# o-/    #\n#-  / -/ #\n# oo   o #\n# /   \o #\n# o   o \#\n#    o   #\n#   -\o  #\n#\  \\ o/#\n##########"

"Readable" version:
class GravitySimulator {
    class Token {
        char symbol;
        int power = 0;

        Token(char c) {
            symbol = c;
        }
    }

    Token A = new Token(' ');

    Token[][] board;

    boolean iterate() {
        for (int i=1; i<board.length; i++)
            for (int j=1; j<board[i].length; j++)
                if (board[i][j].power>0) {
                    if (move(i,j,i+1,j) || board[i+1][j].symbol=='/' && move(i,j,i+1,j-1) || board[i+1][j].symbol=='\\' && move(i,j,i+1,j+1)) return true;
                    int pow = board[i][j].power;
                    board[i][j] = new Token(Integer.toString(pow).charAt(0)){{power=pow;}};
                }
        return false;
    }

    boolean move(int x1, int y1, int x2, int y2) {
        if (board[x2][y2] == A || board[x2][y2].power>0) {
            board[x1][y1].power += board[x2][y2].power;
            board[x2][y2] = board[x1][y1];
            board[x1][y1] = A;
            return true;
        } return false;
    }

    String string() {
        String s = "";
        for (Token[] row : board) {
            for (Token token : row) s+=token.symbol;
            s+="\n";
        }
        return s;
    }

    void fromString(String s) {
        String[] rows = s.split("\\\\n");
        board = new Token[rows.length][rows[0].length()];
        for (int i=0; i<board.length; i++)
            for (int j=0; j<board[i].length; j++)
                switch(rows[i].charAt(j)) {
                    case '-': board[i][j]=new Token('-');break;
                    case '\\':board[i][j]=new Token('\\');break;
                    case '/': board[i][j]=new Token('/');break;
                    case 'o': board[i][j]=new Token('o'){{power=1;}};break;
                    case '#': board[i][j]=new Token('#');break;
                    default:  board[i][j]=A;
                }
    }

    public static void main(String[] args) {
        GravitySimulator g = new GravitySimulator();
        g.fromString(args[0]);
        while(g.iterate());
        System.out.println(g.string());
    }
}

Such java much verbose. +1

Python3, 355b
g=g.replace("o","1").split("\n")
r=1
while r:
 r=0
 for y in range(len(g)):
  for x in range(len(g[y])):
   if g[y][x].isdigit():
    h=g[y+1]
    m={"/":-1,"\\":1}
    j=x+m[h[x]]if h[x]in m else x
    if("0"+h[j].strip()).isdigit():
     r=1
     g[y+1]=h[:j]+str(int(g[y][x])+int("0"+h[j]))+h[j+1:]
     g[y]=g[y][:x]+' '+g[y][x+1:]
print("\n".join(g))

Test here

PHP, 228 204 197 194 bytes
for($a=strtr($a,o,1);$c=$a[$i];$i++)$c>0&&(($d=$a[$t=$i+strpos($a,"
")+1])>" "?$d!="/"?$d!="\\"?$d>0:$a[++$t]<"!"||$a[$t]>0:$a[--$t]<"!"||$a[$t]>0:1)&&$a[$t]=min($a[$t]+$c,9).!$a[$i]=" ";echo$a;

yields warnings in PHP 7.1. Insert (int) before $a[$t]+$c to fix.
Run with php -nr '$a="<string>";' or try it online.
breakdown
for($a=strtr($a,o,1);   # replace "o" with "1"
    $c=$a[$i];$i++)     # loop through string
    $c>0                    # if character is numeric
    &&(($d=$a[                  # and ...
        $t=$i+                  # 3: target position = current position + 1 line
            strpos($a,"\n")+1   # 2: width = (0-indexed) position of first newline +1
    ])>" "                  # if target char is not space
        ?$d!="/"                # and not left slide
        ?$d!="\\"               # and not right slide
        ?$d>0                   # but numeric: go
        :$a[++$t]<"!"||$a[$t]>0     # right slide: if target+1 is space or ball, then go
        :$a[--$t]<"!"||$a[$t]>0     # left slide: if target-1 is space or ball, then go
    :1                              # space: go
    )&&                     # if go:
        $a[$t]=min($a[$t]+$c,9) # move ball/merge balls
        .!$a[$i]=" "            # clear source position
    ;
echo$a;                 # print string

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Who is the sleepiest of them all?
Write a program or function that takes in a string of the characters -=o. where the -=o's and .'s always alternate, character to character. The string will have an odd length greater than one and always start and end in one of -=o.
Basically, the input will look like a line of emoticon faces that share eyes in various states of sleepiness, e.g.
o.=.=.-.-.o.o

Your goal is to print or return the face that is either the sleepiest or the most awake (it's up to you which you choose). If there are multiple choices for who is sleepiest/most awake then any one of them may be output.
There are nine distinct faces and five levels of sleepiness:
-.- is 100% sleepy
-.= is 75% sleepy
-.o is 50% sleepy
=.- is 75% sleepy
=.= is 50% sleepy
=.o is 25% sleepy
o.- is 50% sleepy
o.= is 25% sleepy
o.o is 0% sleepy

In case it's not clear, the sleepiness percentage is computed by assigning 1 to - for fully asleep, 0.5 to = for half asleep, and 0 to o for awake. Then the sum of the two eye values divided by two is the percentage.
The shortest code in bytes wins.
Test Cases
Sleepiest
-.- GIVES -.-
=.- GIVES =.-
o.o GIVES o.o
o.-.= GIVES -.=
=.-.= GIVES =.- OR -.=
o.-.= GIVES -.=
-.-.= GIVES -.-
o.o.- GIVES o.-
=.=.=.o GIVES =.=
-.=.=.= GIVES -.=
=.o.-.= GIVES -.=
o.-.o.=.= GIVES o.- OR -.o OR =.=
-.o.-.=.= GIVES -.=
o.o.o.o.o GIVES o.o
-.-.-.-.- GIVES -.-
o.=.=.-.-.o.o GIVES -.-
-.=.-.o.o.=.o.-.o.=.-.o.=.o.- GIVES -.= OR =.-
Most Awake
-.- GIVES -.-
=.- GIVES =.-
o.o GIVES o.o
o.-.= GIVES o.-
=.-.= GIVES =.- OR -.=
o.-.= GIVES o.-
-.-.= GIVES -.=
o.o.- GIVES o.o
=.=.=.o GIVES =.o
-.=.=.= GIVES =.=
=.o.-.= GIVES =.o
o.-.o.=.= GIVES o.=
-.o.-.=.= GIVES -.o OR o.- OR =.=
o.o.o.o.o GIVES o.o
-.-.-.-.- GIVES -.-
o.=.=.-.-.o.o GIVES o.o
-.=.-.o.o.=.o.-.o.=.-.o.=.o.- GIVES o.o

I'm feeling -.-

Pyth, 12 10 bytes
hoSN%2.:z3

This prints the sleepiest emoticon. Verify all test cases at once  in the Pyth Compiler.
Credit goes to @Sp3000 for the idea to use sorting.
How it works
hoSN%2.:z3
              (implicit) Save the in z.
      .:z3    Compute all substrings of length 3.
    %2        Keep every seconds substring. This discards non-emoticons.
 o            Sort the emoticons by the following key:
  SN            Sort the characters of the emoticon.
                This works since '-' < '=' < 'o'.
h             Retrieve the first, minimal element.

What is this sorcery?!

@Dennis I'm new to Pyth so this might be way wrong: Why not hS%2.:z3?

@helix Because we want =.- to be sleepier than -.o, but they're sorted the other way. I had made the same mistake.

Python 2, 54 53 bytes
f=lambda s:s and max((s+' ')[:3],f(s[2:]),key=sorted)

This is a function that returns the face that is most awake.
Many thanks to xnor for providing many tactical tricks to shorten my original algorithm.

Well, I feel silly not realizing the symbols are sorted by awakeness. I think you can recurse the max rather than iterating it through: f=lambda s:s[3:]and max(s[:3],f(s[2:]))or s

Actually, I think this doesn't work on =.-.o, since =.- vs -.o is the exception to the sort rule.

Actually, I just realised that I misread the op. I thought that the faces are sorted as they appear in the table. Because of this assumption my submission fails for "=.o.-". I think I have a fix though.

@xsot I believe ,key=sorted would be a solution, but this is 11 chars so yours is probably shorter.

Yeah that's the fix I had in mind

I think this saves a char: f=lambda s:s and max((s+' ')[:3],f(s[2:]),key=sorted). The idea is you actually want the nice empty base case f=lambda s:s and max(s[:3],f(s[2:]),key=sorted), but a one-char string o beats =.o in the sort ordering (if the sort was greatest to least, it would work). So, sabotage s when it's short by putting in spaces, which are the lowest.

CJam, 12 bytes
q3ew2%{$}$0=

This prints the sleepiest emoticon. Try this fiddle or this test suite in the CJam interpreter.
Credit goes to @Sp3000 for the idea to use sorting.
How it works
q            e# Read all input from STDIN.
 3ew         e# Push all overlapping slices of length 3.
    2%       e# Keep every seconds slice. This discards non-emoticons.
      {$}$   e# Sort the slices by their sorted characters.
             e# This works since '-' < '=' < 'o'.
          0= e# Retrieve the first, minimal slice.

Dyalog APL, 35 28 bytes
{⊃{⍵[⍒{+/'.??o='⍳⍵}¨⍵]}3,/⍵}

This is a monadic function that takes the string on the right and outputs the sleepiest face.
    {⊃{⍵[⍒{+/'.??o='⍳⍵}¨⍵]}3,/⍵}'o.=.=.-.-.o.o'
-.-

{(⊃⍒3+/'.??o='⍳⍵)⊃3,/⍵}

And given the input constraints, that ?? is also unnecessary.

Prolog, 205 189 bytes
Code
r([X|T],[N|B],M):-N=M,write(X);r(T,B,M).
p(X):-findall(S,sub_atom(X,_,3,_,S),L),findall(E,(nth1(I,L,E),I mod 2=\=0),R),maplist(atom_codes,R,Q),maplist(sum_list,Q,S),min_list(S,M),r(R,S,M).

Explanation
r([X|T],[N|B],M):-N=M,write(X);r(T,B,M).
p(X):-findall(S,sub_atom(X,_,3,_,S),L),              % L = all sublists of length 3
      findall(E,(nth1(I,L,E),I mod 2=\=0),R),        % R = every other element of L
      maplist(atom_codes,R,Q),                       % Q = list of decimal ascii codes
                                                           created from R

      maplist(sum_list,Q,S),                         % S = list of sums of R's lists
      min_list(S,M),                                 % M = minimum sum
      r(R,S,M).                                      % Prints first element in R with sum M

Example
>p('-.=.-.o.o.=.o.-.o.=.-.o.=.o.-').
-.=

Edit: Saved 16 bytes by unifying r-clauses with OR.

Python 2/3, 54 56 bytes
lambda x:".".join(max(zip(x[::2],x[2::2]),key=sorted))

Just wanted to take an alternative tack to xsot's recursive answer.
This takes the best (or worst?) tuple of adjacent pairs of eyes and joins them together.
Replace max with min to return the most sleepy (as is this returns the most awake)
Seems to work, using the following test:
for line in """-.- GIVES -.-
    =.- GIVES =.-
    o.o GIVES o.o
    o.-.= GIVES o.-
    =.-.= GIVES =.- OR -.=
    o.-.= GIVES o.-
    -.-.= GIVES -.=
    o.o.- GIVES o.o
    =.=.=.o GIVES =.o
    -.=.=.= GIVES =.=
    =.o.-.= GIVES =.o
    o.-.o.=.= GIVES o.=
    -.o.-.=.= GIVES -.o OR o.- OR =.=
    o.o.o.o.o GIVES o.o
    -.-.-.-.- GIVES -.-
    o.=.=.-.-.o.o GIVES o.o
    -.=.-.o.o.=.o.-.o.=.-.o.=.o.- GIVES o.o""".splitlines():
    inp, _, opts = line.partition(" GIVES ")
    optst = opts.split(" OR ")
    act = f(inp)
    print(inp, "expected", opts, "got", act, "equal?", act in optst)

Which gives the following result:
-.- expected -.- got -.- equal? True
=.- expected =.- got =.- equal? True
o.o expected o.o got o.o equal? True
o.-.= expected o.- got o.- equal? True
=.-.= expected =.- OR -.= got =.- equal? True
o.-.= expected o.- got o.- equal? True
-.-.= expected -.= got -.= equal? True
o.o.- expected o.o got o.o equal? True
=.=.=.o expected =.o got =.o equal? True
-.=.=.= expected =.= got =.= equal? True
=.o.-.= expected =.o got =.o equal? True
o.-.o.=.= expected o.= got o.= equal? True
-.o.-.=.= expected -.o OR o.- OR =.= got =.= equal? True
o.o.o.o.o expected o.o got o.o equal? True
-.-.-.-.- expected -.- got -.- equal? True
o.=.=.-.-.o.o expected o.o got o.o equal? True
-.=.-.o.o.=.o.-.o.=.-.o.=.o.- expected o.o got o.o equal? True

Two quick questions: 1) is labeling as Python 2 / 3 when something works with both recommended? 2) Is the f= part required as part of the code size for this challenge? If I don't do that it'll create the lambda and then just immediately throw it away again...

"Python 2/3" or just "Python" is fine I think 2) If you don't need the f= then the current consensus seems to be that anonymous functions are okay by default, so you can drop the f= in this case (xsot's needs it since it's recursive)

C, 70 bytes
char*f(char*s){char*p=s[3]?f(s+2):s;return*s+s[2]>*p+p[2]?s[3]=0,s:p;}

The function returns the most awake face.  It modifies the input string in place, so as to return a null-terminated string.

Clojure, 82 bytes
(fn[x](println(apply str(apply min-key #(reduce +(map int %))(partition 3 2 x)))))

Bonus: the following smaller function prints the same face, but with more style!
(fn[x](println(apply min-key #(reduce +(map int %))(partition 3 2 x))))

Test here.

Minkolang 0.12, 119 bytes
At first, I tried doing this short and really golfy. I gave up and went for something a bit more "fun", but still relatively golfy.
>2@fv$oI2:[9[i$z3[iciz1+q=]++3=tt"^"3zpt]$x$x]IX3140w
o.o1F
o.=1$
=.o1+
=.=12
o.-1:
-.o11
=.-1+
-.=13
-.-1[
/c0i<
\qO].

Try it here!
Explanation
But really, click on the link above and click Slow! Anyway...
>2@fv

This skips over the fv, which will be important later.
$o                                                  Read in whole input as characters
  I2:                                               Half the stack length
     [                                              Open for loop (for each face)
      9[                                            Open another for loop - 9 repeats
        i$z                                         Stores loop counter in register
           3[                                       Open another for loop - 3 repeats
             ic                                     Copy char 1/2/3
               iz1+q                                Retrieve char from lookup table
                    =                               1 if equal, 0 otherwise
                     ]                              Close for loop
                      ++                            Add twice
                        3=                          1 if equal to 3, 0 otherwise
                          tt      t                 Ternary - executes first part when 0,
                                                    second part otherwise
                            "^"3zp                  Put a ^ next to the face that matched
                                   ]                Close lookup for loop
                                    $x$x            Dump first two characters
                                        ]           Close for loop
                                         IX         Dump the whole stack
                                           31       Push a 3, then a 1
                                             40w    Wormhole to (4,0) in the code

What all that did was put a ^ next to the faces that matched. So now the codebox might look like this:
>2@fv$oI2:[9[i$z3[iciz1+q=]++3=tt"^"3zpt]$x$x]IX3140w
o.o1F
o.=1$
=.o1+
=.=^2   <-- caret
o.-^:   <-- caret
-.o11
=.-1+
-.=^3   <-- caret
-.-1[
/c0i<
\qO].

Without the comments, of course. Now, the 40w wormhole sent the instruction pointer to v, which immediately redirects it onto F. Now, F is a "gosub" command. It's like a goto, but you can return to where you called it. At the time F is encountered, the stack is [3,1], so it jumps to the 1 (maybe) on the second row. As the program counter was heading downwards, it continues, pushing 1s onto the stack along the way. That is...until it hits a ^, at which point it's redirected back up, where it pushes each 1 again. The instruction pointer then hits f, which restores its position and direction (when F was encountered earlier). For convenience, I will take the following code and change its layout. (The </\ serve to redirect the instruction pointer as needed.)
$+                 Sum up the whole stack
  2:               Divide by 2 (because each 1 was pushed twice)
    1+             Add 1 (shift down one row)
      3[           Open for loop - 3 repeats
        i          Push loop counter
         0c        Copy top of stack
           q       Retrieve face character
            O      Output as character
             ].    Close for loop and stop when it's done.

I'm actually kinda proud of how I used multiple features unique to Minkolang that I haven't often used before. Mainly the ternary and the gosub. Anyway, there you have it!

Ruby, 59 bytes
Function returns sleepiest face, using the sorting trick.
f=->(s){s.split(?.).each_cons(2).min_by{|e|e.sort}.join(?.)}

Called like this:
f.call("o.=.=.-.-.o.o")
# => "-.-"

Works on awkward eye order due to internal sort of eyes:
f.call("=.-.o")
# => "=.-"

Brachylog, 10 bytes
s₃ᶠġ₂hᵐoᵒh

Try it online!
Translated from Dennis' Pyth answer.

ES6, 81 72 bytes
a=>"-.-,-.=,=.-,-.o,=.=,o.-,=.o,o.=,o.o".split`,`.find(b=>a.includes(b))

Probably requires Chrome 45 or Firefox 41.
Thanks to @ETHproductions for saving 9 bytes.

Nice, but "=.-" should be switched with "-.o"; same with "=.o" and "o.-". Also, you may be able to save some bytes by putting everything in one string, separated by commas, and using .split`,` .

Using split could save 9 chars

@ETHproductions Sorry I didn't notice that the original list of faces wasn't itself in order of sleepiness.

Perl 5, 127 bytes
%h=qw[- 2 = 1];sub r{$b=0;$b+=$h{$_}for split'',pop;$b}($_)=<>;@a='o.o';while(/.../g){push@a,$& if(r$&)>r$a[-1];--pos}say$a[-1]

(I'm sure it's doable more briefly.) How it works:

Grab each three-character string from the string, with overlap by one (that's what the --pos does).
Append that three-character string to an array if its value exceeds that of the last element of the array; here, "value" is just the sum of its characters' values in sleepiness.
Print the last element of the array.

Mathematica, 61 bytes
"."
Sort[Partition[#~StringSplit~%,2,1]][[1]]~StringRiffle~%&

Goes for the sleepiest one.

This function only works once, unless you repeat the entire code each time you want to call it. The point of function submissions is for them to be reusable. Calling your function breaks the value of the global % which it relies on.

F# 60
fun s->Seq.max[for n in 0..2..String.length s-2->s.[n..n+2]]

Returns the most awake face (change max by min for the sleepest)

><>, 55 bytes
try it here!
<v~i:i&0"."0
 >i:@+:&:@)?v&~i0(?v
 ^?)0i:r~r&~<;ooo$r<

Outputs most awake face.
Since the ASCII values for -, =, and o increase respectively, I could use that to my advantage. Basically it adds the values of the current and previous eye part, check if it's a higher value than before, if it is it saves the new value and updates what face that represents, then loops until the end of the input. Then outputs the face that remains. (I'm very pleased at how nicely all the code fits in place)

Perl 5 -MList::Util=max -p, 68 bytes
s|..(?=(.))|$t=max$t,ord($&)%15%4+ord($1)%15%4 .$&.$1|eg;$_=$t;s/.//

Try it online!
Grabs each set of three characters, ignores the . in the middle, maps the addition of the other two to an integer in the range 0-4, concatenates that to the front of the emoticon face, then sorts by that.  Grabs the last entry (most awake), removes the number from the front, and outputs it.