text:
Diamondize a Matrix
Given a matrix, output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom.
For example, consider the following matrix:
1 2 3
4 5 6
7 8 9

The diamond version of this matrix is:
  1
 4 2
7 5 3
 8 6
  9

Inputs and outputs
An input matrix will be given as a list of lists (or anything similar in your language of choice). The output shall be a list of lists as well.
The matrices will only contain positive integers.
The input matrix will not necessarily be square.
The input matrix will be at least 1×1.
Test Cases
Input:  [[1]]
Output: [[1]]

Input:  [[1,2],[3,4]]
Output: [[1],[3,2],[4]]

Input:  [[1,2,3],[4,5,6]]
Output: [[1],[4,2],[5,3],[6]]

Input:  [[11,2,5],[3,99,3],[4,8,15],[16,23,42]]
Output: [[11],[3,2],[4,99,5],[16,8,3],[23,15],[42]]

Scoring
This is code-golf, so the shortest answer in bytes wins.

Related

Related/Generalisation. (Wouldn't consider it a dupe though, since that one allowed ragged arrays and required rotation by any multiple of 45 degrees.)

Related.

J, 6 bytes
<@|./.

This is an unnamed a monadic verb which takes a matrix and returns a list of antidiagonals:
   input =. i.3 4
   input
0 1  2  3
4 5  6  7
8 9 10 11

   <@|./. input
┌─┬───┬─────┬─────┬────┬──┐
│0│4 1│8 5 2│9 6 3│10 7│11│
└─┴───┴─────┴─────┴────┴──┘

Test it here.
Explanation

/. is J's built-in to apply a function to each anti-diagonal. Unfortunately, these anti-diagonals are given in the opposite order of what we want here.
In <@|., we first apply |. which reverses the anti-diagonal and then < to box it (which is the only way to return a ragged array in J, since normal arrays are always rectangular, so the antidiagonals would be padded with zeroes).

That is crazy and beautiful. I will take the time to learn this language some day.

@machineyearning did you ever learn J? you had 8 years :)

Python, 91 bytes
e=enumerate
lambda M:[[r[n-i]for i,r in e(M)if-1<n-i<len(r)][::-1]for n,_ in e(M[1:]+M[0])]

Test it on Ideone.

Python + NumPy, 69 bytes
import numpy
lambda M:map(M[::-1].diagonal,range(1-len(M),len(M[0])))

Expects a 2D NumPy array as input and returns a list of NumPy arrays. Test it on Ideone.

Jelly, 7 bytes
ṚŒDṙZL$

Try it online!
Explanation
Ṛ         Reverse the matrix vertically.
 ŒD       Get its diagonals. However these start from
          the main diagonal, not the corners.
    ZL$   Get the width of the input matrix.
   ṙ      Rotate the list of diagonals left by that many
          places to obtain the correct order.

Don't know Jelly, but that isn't 7 bytes if it requires unicode operands.

@Guidobot Jelly uses a custom code page that encodes each of the 256 characters it understands as a single byte.

Mathematica, 58 56 bytes
a=Length;Reverse@#~Diagonal~b~Table~{b,1-a@#,a@#&@@#-1}&

Anonymous function, takes nested arrays.

You can save one with Length[#] where  is \[Transpose].  And probably another from aliasing Length.

Or Length@#&@@# for ASCII only at the same byte count.

CJam, 17 bytes
{eeSf.*::+W%zSf-}

An unnamed block (function) which expects the matrix on the stack and replaces it with its antidiagonals.
Test it here.
This (found by Sp3000) works for the same byte count:
{_,,Sf*\.+W%zSf-}

Explanation
This is best explained with an example. Consider the input:
[[0  1  2  3]
 [4  5  6  7]
 [8  9 10 11]]

ee    e# Enumerate matrix, turning each row [x ... z] into [i [x ... z]] where
      e# i is the vertical index from the top.

[[0 [0  1  2  3]]
 [1 [4  5  6  7]]
 [2 [8  9 10 11]]]

Sf.*  e# Replace each i with a string of i spaces.

[[""   [0  1  2  3]]
 [" "  [4  5  6  7]]
 ["  " [8  9 10 11]]]

::+   e# Prepend these strings to the rows.

[[0  1  2  3]
 ['  4  5  6  7]
 ['  '  8  9 10 11]]   e# Note that each '  corresponds to a space character.

W%    e# Reverse the rows.

[['  '  8  9 10 11]
 ['  4  5  6  7]
 [0  1  2  3]]

z     e# Zip/transpose.

[[ '  '  0]
 [ '  4  1]
 [ 8  5  2]
 [ 9  6  3]
 [10  7]
 [11]]

Sf-   e# Remove spaces from each row.

[[ 0]
 [ 4  1]
 [ 8  5  2]
 [ 9  6  3]
 [10  7]
 [11]]

Python 2, 88 87 bytes
lambda L:[filter(None,x)[::-1]for x in map(None,[],*[i*[0]+r for i,r in enumerate(L)])]

Prepend 0s, zip, then remove falsy elements. Returns a list of tuples. This uses map(None,...) to perform zip_longest  (padding missing spots with None) and filter(None,...) to remove falsy elements.
Annoyingly, we need to add an extra [] row to the map to guarantee that a list of tuples is returned, since map(None,*[[1]]) returns [1] rather than [(1,)] for a 1x1 matrix. The extra row gets stripped out by the filter though.
(Thanks to @Dennis for -1 byte)

Ruby, 68 66 bytes
Anonymous function.
->l{i=-1;k=[];l.map{|r|i-=j=-1;r.map{|e|k[i+j+=1]=[e,*k[i+j]]}};k}

Because of how the splat operator works, I was able to save 2 bytes by forgoing the array addition.

JavaScript (Firefox), 86 75 bytes
a=>a.concat(a[0]).slice(1).map((_,i)=>[for(v of a)if(n=v[i--])n].reverse())

Saved 11 bytes thanks to @Neil!
Works in Firefox 30+. Takes an array of arrays.

Nice algorithm, but you can use a.concat(a[0]).slice(1) to get an array of the right length. Also, [for(of)] is not ES6; I normally write it as (Firefox 30+) or some such.

@Neil Wow, I feel a bit silly not figuring out to use concat and slice. Thanks!

Husk, 3 2 bytes
∂T

-1 byte thanks to @mypronounismonicareinstate.
Try it online.
Explanation:
 T  # Transpose the (implicit) matrix-argument; swapping rows/columns
∂   # Take the anti-diagonals of this transposed matrix
    # (after which the result is output implicitly)

(possibly; I can be wrong) 2 bytes by ∂T (T = transpose) (the only thing I know about Husk is that I once noticed it had a nice built-in, tried to use it and failed completely)

@mypronounismonicareinstate Ah smart, thanks! :) And yeah, I know the trouble. This is only my second Husk answer, but the first time I used it (also because I remembered the 1-byte diagonals builtin), it took quite a while.. Here is that answer. That mainly had to do with me not reading the tutorial more thoroughly though.. In combination with the right-to-left and strong-typed execution style, and the arguments are right-to-left using the even superscript numbers.. (i.e. if you have two argument, ² is the 1st arg and ⁰ is the 2nd..)

Prolog (SWI), 111 bytes
A*B*C:-append(A,B,C).
s(A,B,C):-A*[B]*C.
N+B:-N=[A|X],X+R,Z*Q*R,maplist(s,[[]|Z],A,Y),Y*Q*B,!;maplist(=([]),B).

Try it online!
Explanation
Let's first look a version of the code that not nearly so condensed.
snoc(Init,Last,List) :-
  append(Init,[Last],List).

diamondize([],Soln) :-
  maplist(=([]),Soln).
diamondize([FirstRow|Rest],Soln):-
  diamondize(Rest,RestSoln),
  append(BeginRestSoln,EndSoln,RestSoln),
  maplist(snoc,[[]|BeginRestSoln],FirstRow,BeginSoln),
  append(BeginSoln,EndSoln,Soln),
  !.

The diamondize/2 predicate (+/2 in the golfed version) is responsible for calculating what the diamond version of the input matrix is.
The predicate works recursively as follows: first it calculates the diamond version of the input matrix with its first row removed (diamondize(Rest,RestSoln)); then to calculate the diamond version of the entire input matrix it uses the fact that adding an initial row changes the diamond version by prepending a singleton list of the first element of the initial row and then pairing up each remaining element in the initial row with the first however many lists in the diamond and adding each initial row element to the end of its paired list, leaving the remaining lists in the diagonal unchanged. To do this in Prolog I use append to split RestSoln into a beginning, BeginRestSoln, and an end, EndSoln. Then I use the the builtin maplist/4 to assert a relation between BeginRestSoln, the new initial row, FirstRow, and a new list BeginSoln. The maplist/4 predicate asserts that all triples of elements of equal indices from the lists in its second, third, and fourth arguments will satisfy the predicate given as its first argument when it is called on them (note that this requires all the lists given as arguments to be of equal length). The predicate I use is snoc/3 which asserts that when its second argument is added to the end of the list in its first argument, you get its third argument. Furthermore I add an empty list to the start of BeginRestSoln which means that when I snoc that with the first element of FirstRow the resulting first element ofBeginSoln will be a singleton list of that aforementioned first element. The rest of BeginSoln will be the lists that began the diagonal version of the remainder of the matrix with the remaining elements of the first row added to the end, just as desired in the process described above. Finally to get the solution for the entire matrix we append BeginSoln with the unchanged EndSoln.
We have now covered the behavior of diamondize/2 when the matrix is not empty, but the base case is the empty matrix. In that case the "solution" is considered to be a list of some undetermined length with [] for all its elements. This list is constructed using the maplist/2 predicate which asserts that each element of the list given in its second argument satisfies the predicate given in its first argument. The predicate we use is =([])/1 which is the partially applied =/2 predicate which asserts that its two arguments unify, so our partially applied version asserts that its singular argument unifies with (ie is equal to) the empty list. However, since we do not specify a length, Prolog will attempt to satisfy the future goals with the shortest list containing only empty lists, backtracking and trying a longer such list if the future goals can't be satisfied. This behavior is very useful since in our first inductive case the predicates won't be satisfied unless the previous solution is at least one less than the length of the rows of the matrix, but we run into an issue in that longer lists of empty lists would also result in solutions that the program would consider valid, but would be invalid for this challenge. To avoid producing these solutions, we add a cut (!) to the end of the recursive case of diamondize/2, which will tell Prolog not to backtrack once we have a working solution.
Finally to golf the whole thing I used a number of tactics. First off, of course we can eliminate excess whitespace, and give variables and predicates shorter names. Then since append/3 is being used a lot I can save a couple bytes by creating a copy of it with a shorter name, using an operator to name both it and what was the diamondize/2 predicate (unfortunately since operator predicates technically can have at most two arguments, I cannot give s/3 an operator name since I need to pass it to maplist/4). Finally I can consolidate the two cases of +/2 into a single case with a disjunction.

Mathematica, 60 bytes
#&@@@#&/@GatherBy[Join@@MapIndexed[List,#,{2}],Tr@*Last]&

where  is a Unicode character which Mathematica reads as the postfix \[Transpose] operator.
This is a bit longer than the other Mathematica solution but I figured I'd post it because it doesn't use the Diagonals built-in and uses a completely different approach.
Explanation
MapIndexed[List,#,{2}]

This first transposes the matrix (such that the antidiagonals appear in the correct order if the matrix was flattened). Then we map List over the cells of the matrix together with the index, which turns each matrix element i into {i, {x, y}} where x and y are the coordinates of the element in the matrix.
Join@@...

This flattens the outermost dimension, so that we now have a flat list of the matrix elements (with their coordinates) in column-major order.
GatherBy[..., Tr@*Last]

This groups those elements by the sum of their coordinates. Note that antidiagonals are lines of constant x+y, so this does exactly the grouping we want. The order within each group is preserved. Now we just need to get rid of the coordinates again. This is done via the rather cryptic:
#&@@@#&/@...

This maps the function #&@@@#& over each group, which itself applies #& to each element in the group, and # is simply the first argument, i.e. the original matrix element.

Any explanation as to why  is read as \[transpose] ?

@Fatalize It's a private-use Unicode codepoint, and the glyph Mathematica associates with this codepoint is a superscript T: http://reference.wolfram.com/language/ref/character/Transpose.html ... \[Transpose] is simply the ASCII transliteration of that Unicode character. Copying either the Unicode character or the transliteration into Mathematica will work.

Octave, 77 bytes
With a little abuse of the accumarray function:
@(M)char(accumarray(((1:size(M,1))+(0:size(M,2)-1)')(:),M(:),[],@(x){num2str(x')}))

This defines an anonymous function. To use it, assign to a varible or use ans.
Input is the matrix with : as row separator. Output is a cell array containing an array for each row (Octave's equivalent to jagged arrays). This is displayed by Octave showing the indices of the cell array and the contents of each cell. Try it here.
To display the result separated by spaces and newlines only: 83 bytes
@(M)char(accumarray(((1:size(M,1))+(0:size(M,2)-1)')(:),M(:),[],@(x){num2str(x')}))

You can also try it here.

Octave, 63 62 bytes
Removed one byte thanks to @DonMue... @LuisMendo!
@(a)cellfun(@(x)x(x>0)',num2cell(spdiags(flipud(a)),1),'un',0)

I went the boring route and munged the antidiagonals.
Sample run on ideone.

I think you can shorten 'uni' to 'un'

@LuisMendo Why, yes I can! Thanks! :)

Haskell, 83 82 bytes
r=zip[0..]
\o->fst$span(any(>0))[reverse[e|(x,t)<-r o,(v,e)<-r t,x+v==a]|a<-[0..]]

nimi saved a byte. Thanks!

It's been a while but I've got a shorter answer.  Maybe you will see some way to knock a couple off that.

[C#], 100 bytes
for(r=0;r<l;r++)for(c=0;c<i[r].Length;c++)o[c+r]=o[c+r]?.Prepend(i[r][c]).ToArray()??new[]{i[r][c]};

Try It online!
Maybe there's a shorter way of inserting elements. Prepend and ToArray seems verbose, but that's the best I found.

Haskell, 56 bytes
a!b=zipWith(++)([]:b)$a++repeat[]
foldr1(!).map(pure<$>)

Try it online!

BQN, 11 bytes
⌽¨+´¨∘↕∘≢⊸⊔

Anonymous tacit function. Takes a 2D array and returns a list of lists. Try it at BQN online!
Explanation
⌽¨+´¨∘↕∘≢⊸⊔
        ≢     Get the shape of the array (a list of two integers)
      ↕∘      Range (a 2D array of coordinate pairs)
  +´¨∘        Sum each of those pairs
              We now have an array in which the top left element is 0, the two elements
              in the next antidiagonal are 1, and so forth
         ⊸    With that as left argument and the original array as right argument,
          ⊔   Group the values of the right argument into buckets based on the
              corresponding number in the left argument
⌽¨            Reverse each antidiagonal

Pip, 19 bytes
_RMxMZD:xRL_AL BMEa

Try It Online!
I'm a bit rusty. There might be a shorter way to do this with loops but oh well.
                ME  # Map [index item] for each item of...
                  a # Input
        --------ME  # Block
         RL         # Repeat...
        x           # The empty string
           _        # By the index
            AL      # Concatenate to...
               B    # The item
     ZD:            # Transpose, filling with ""
----M               # Map over each...
_RM                 # Remove
   x                # The empty string

Interesting approach! Looks like you're eligible for this bounty if you wish to claim it.

Python, 128 bytes (numpy)
(lambda A: (lambda A,S:[[A[U][I-U] for U in range(min(S[1]-1,I),max(I-S[0]+1,0)-1,-1)] for I in range(S[1]+S[0]-1)])(A,A.shape))

Welcome to Programming Puzzles & Code Golf! By default, submissions to code golf challenge must be programs or functions and use one of the approved methods for I/O. A snippet that expects the input in a hardcoded variable is not allowed.

Looks like you can rework the first solution that uses lambda into just a lambda that you can use as your submission.

I will lambda it

lambda A:[[A[U][I-U]for U in range(max(I-len(A)+1,0),min(len(A[0])-1,I)+1)]for I in range(len(A+A[0])-1)] (as in your original revision) would be a bit shorter. Also, you should change A[U][I-U] to A[I-U][U] to get orientation from the question.

I will check it when back at home. Makes sense

Pyth, 41 17 bytes
tm_<dx+dYk.T+LaYk

Try it online!
Inspired by @Doorknob's solution to another problem.
How it works:
tm_<dx+dYk.T+LaYk
            +L      prepend to each subarray...
              aYk   (Y += ''). Y is initialized to [],
                    so this prepends [''] to the first
                    subarray, ['', ''] to the second, etc.
                    ['' 1  2  3
                     '' '' 4  5  6
                     '' '' '' 7  8  9
                     '' '' '' '' 10 11 12
                     '' '' '' '' '' 13 14 15]
          .T        transpose, giving us
                    ['' '' '' '' ''
                     1  '' '' '' ''
                     2  4  '' '' ''
                     3  5  7  '' ''
                     6  8  10 ''
                     9  11 13
                     12 14
                     15]
 m_<dx+dYk          removes all empty strings in the
                    subarrays while reversing each one
t                   remove the first subarray

Previous attempt:
JlQKlhQm_m@@Qk-dk}h.MZ,0-dtKh.mb,tJdUt+JK

Try it online!
How it works:
JlQKlhQm_m@@Qk-dk}h.MZ,0-dtKh.mb,tJdUt+JK    input array stored as Q
JlQ                                          J = len(Q)
   KlhQ                                      K = len(Q[0])
       m                            Ut+JK    list for d from 0 to J+K-1:
        _m       }AAAAAAAAAABBBBBBBB             reversed list for k from A to B, where:
                  h.MZ,0-dtK                       A = max(0, d-(K-1))
                       0-dtK                               0  d-(K-1)
                            h.mb,tJd               B = min(J-1, d)
                                 tJd                       J-1  d
          @@Qk-dk                                    Q[k][d-k]

Groovy, 77 73 75
{i->o=[].withDefault{[]};a=0;i.each{b=0;it.each{o[a+b++].add(0,it)};a++};o}

Takes array of arrays as input and returns array of arrays.
Try it
EDIT: I forgot to output the anwser, after adding it score goes up to 75.

APL (Dyalog Unicode), 78 bytes
{{⍵/⍨×≢¨⍵}{⍵/⍨×⍵}¨↓⍉(-⍳≢⍵)⌽⍵↑⍨1 2×≢⍵}

Try it online!

Perl 5, 67 bytes
sub{map{[grep$_,map{shift@{$_[-$_]}}-$_..0]}0..$#_,($#_)x$#{$_[0]}}

Try it online!

05AB1E (legacy), 17 16 bytes
εD0*«NFÁ]øí0δKʒOĀ

Unfortunately 05AB1E only has a builtin for the main (anti)diagonal, and not one for all (anti)diagonals, so we'll have to do things manually..
-1 byte by switching to the legacy version of 05AB1E, so the 0δK can be 0K.
Try it online or verify all test cases.
Explanation:
ε        # Map each row in the (implicit) input-matrix to:
 D       #  Duplicate the current row
  0*     #  Multiply each by 0, so we have a list of 0s the same length of the row
    «    #  Append the lists together
         #   i.e. [[1,2,3],[4,5,6],[7,8,9]] → [[1,2,3,0,0,0],[4,5,6,0,0,0],[7,8,9,0,0,0]]
     NF  #  Loop the (0-based) map-index amount of times:
       Á #   And rotate the row with appended 0s once towards the right each iteration
         #    → [[1,2,3,0,0,0],[0,4,5,6,0,0],[0,0,7,8,9,0]]
]ø       # After the map and inner loop: zip/transpose; swapping rows/columns
         #  → [[1,0,0],[2,4,0],[3,5,7],[0,6,8],[0,0,9],[0,0,0]]
  í      # And reverse each inner row
         #  → [[0,0,1],[0,4,2],[7,5,3],[8,6,0],[9,0,0],[0,0,0]]
0K       # Remove all 0s from each inner row
         #  → [[1],[4,2],[7,5,3],[8,6],[9],[]]
  ʒOĀ    # And filter out any empty rows
         #  → [[1],[4,2],[7,5,3],[8,6],[9]]
         # (after which the result is output implicitly)

Japt, 11 bytes
Takes input as an array of space delimited strings, outputs a 2D array of integer strings.
ËiEç)¸ÃÕËÔf

Try it (header converts 2D arrays to the required input format) or run all test cases
ËiEç)¸ÃÕËÔf     :Implicit input of array
Ë               :Map each element at 0-based index E
 i              :  Prepend
  Eç            :    E spaces
    )           :  End prepend
     ¸          :  Split on spaces
      Ã         :End map
       Õ        :Transpose
        Ë       :Map
         Ô      :  Reverse
          f     :  Filter

Vyxal, 22 bitsv2, 2.75 bytes
Þ`R

Try it Online!
Bitstring:
0010101000111101000010


text:
Create your own Gym Exercise and follow along irl
Let's do an exercise together, shall we? Simply follow the movements of the stickman. What stickman you ask? The one we are about to create!
Make a program that allows for a string-input only containing integers, and outputs the following nine stick-figures with an interval in between:
 @  \@/ |@_ _@| @/   \@ |@| \@\ /@/
/|\  |   |   |   |   |   |   |   |
/ \ / \ / \ / \ /|\ /|\ / \ / \ / \
 1   2   3   4   5   6   7   8   9

This will result in an animation, which we can then follow along irl.
Here is an example of the output created when the input is "123245762":

Some rules:

This is tagged code-golf, so shortest code in bytes wins
The input is a string only containing [1-9] with a length potentially varying from 2 to 100 characters **
The animation must be an endless loop
The interval time must be 750 ms
No duplicated adjacent integers are allowed in the input - this also includes the first and last integers of the input (see the seventh and eight test cases) **

** How it fails in case of invalid input is completely up to you, but it should be clear that it fails. It could throw an exception; simply return at the start; reboot your PC; delete it's own source-/compile-code; hack into the military and shoots a rocket to the compiling GPS-location. Your call. EDIT: It's not allowed to simply display a (correct / half) animation as failing input. It must be clear that something is wrong with the input for the failing testcases below. Thanks to @user81655 for bringing this to my attention, hence the edit.
Subrules:

Please post the gif for one of the (non-failing) test cases below in your answer, which you can make very easy with the following program: screentogif.codeplex.com (Any other gif-creating program is also allowed of course.)
Bonus points if you actually do the exercise alongside the animation irl when it's finished. ;)

Correct testcases:

123245762
65
121234346565879879132418791576

Failing testcases:

2 // Too few characters
7282918274959292747383785189478174826894958127476192947512897571298593912374857471978269591928974518735891891723878 // Too much characters
1232405762 // Containing invalid input (the 0)
112212 // Fails because of the 11 and 22 present
1232457621 // Fails because of the starting and leading 1

IMO this is a borderline dupe of this

BTW, making edits after a challenge is posted is discouraged.

imo the input validation ruins the challenge.

@FlipTack You're indeed right. I should have just kept with the challenge and assume all input is valid. This was my very first question here on PPCG. Bit too late to change it now, though.

Pyth, 114 bytes
.V0j@cv.Z"xÚí» À0DW¹NM@+Üñ\">íÂA¸êÄÓw»`3±2þ&'NövfAé8é~0,p'ÆìÞúr_'¥,d!YÈBíéqs"3tv@zb.d.75

Try it here
(No pausing, non-infinite)

Hmm, it isn't possible to return/throw or loop infinitely in Pyth? Or it will take too much bytes/is too time-consuming to make? (Currently it works the same for all correct testcases, as well as all failing testcases. And it also adds in the output for 0.) Regardless, thanks for the entry. Definitely one of the most unreadable code-snippets for this entry is my guess. :)

The online interpreter doesn't flush IO during a sleep so it isn't noticed. You did say you wanted an infinite loop so I'm not sure what you're asking there. "How it fails is up to you" - I'm doing undefined behavior for this; the code might do anything (even though it SHOULD behave the same) Also I'm expecting this to be relatively readable compared to some possible entries

SpecBAS - 387 bytes
1 DIM m$=" @"#13"/|\"#13"/ \","\@/"#13" |"#13"/ \","|@_"#13" |"#13"/ \","_@|"#13" |"#13"/ \","@/"#13" |"#13"/|\"," \@"#13" |"#13"/|\","|@|"#13" |"#13"/ \","\@\"#13" |"#13"/ \","/@/"#13" |"#13"/ \"
2 INPUT a$: o=0
3 IF LEN a$<2 OR LEN a$>100 THEN 10
4 FOR i=1 TO LEN a$
5 n=VAL(a$(i))
6 IF n=0 OR n=o THEN 10
7 CLS : ?m$(n): o=n: WAIT 750
8 NEXT i
9 GO TO 4
10 CLS : ?" @"#13"-O-"#13"/ \"#13"FAT"

Keeps looping until you press ESC. Failure to exercise properly (incorrect input - in this example a 0 as one of the steps) leads to fatness. The GIF loops, in the program it just stops at that point.
#13 is the SpecBAS equivalent to \n and lets you include line feed in strings.

"FAT" :D ......

JavaScript (ES6), 165 bytes

f=s=>{n=s[0];e.textContent=' @ \\@/|@__@|@/  \\@|@|\\@\\/@/'.substr(n*3-3,3)+(n>1?`
 |
`:`
/|\\
`)+(n<5|n>6?'/ \\':'/|\\');s=s.slice(1)+n;s[0]-n&&setTimeout(f,750,s)}
f("123245762")
<pre id=e>

JavaScript (ES6), 210 bytes
s=>setInterval(_=>(c=console).clear(i=0)&c.log(`, @
/|\\
/ \\,\\@/
 |
/ \\,|@_
 |
/ \\,_@|
 |
/ \\,@/
 |
/|\\, \\@
 |
/|\\,|@|
 |
/ \\,\\@\\
 |
/ \\,/@/
 |
/ \\`.split`,`[s[i++%s.length]]),750)

How does this handle the rules about excluding 0 and duplicates?

@Morgan'Venti'Thrappuccino I was under the impression that invalid inputs don't need defined behaviour, since it says How it fails in case of invalid input is completely up to you. I just handle invalid input by displaying an animation. :P None of the other existing answers checked this either, however the answer the OP just posted does, so maybe he did want us to handle invalid input.

"I just handle invalid input by displaying an animation. :P" Lol.. That's one way of looking at it. xD I'll edit the question.

Java 8, 663 636 634 631 596 355 354 343 bytes
Just for the lols I tried to make the program in Java. Admittedly I'm pretty bad at golfing and regexes, so it can most likely be golfed (a lot?) more. Nevertheless, here it is in Java 7.
Now almost two years later and I almost halved the code in Java 8. Why did I ever made those rules about validating the input and requiring a full program, though... >.> I hate my past self now..
interface M{static void main(String[]a)throws Exception{for(;a[0].matches("[1-9]{2,100}")&!a[0].matches(".*(.)\\2.*|(.).*\\1");)for(int c:a[0].getBytes()){c-=48;System.out.printf("%s%n%s%n%s%n",c<2?" @ ":c<3?"\\@/":c<4?"|@_":c<5?"_@|":c<6?"@/ ":c<7?" \\@":c<8?"|@|":c<9?"\\@\\":"/@/",c<2?"/|\\":" | ",c%7>4?"/|\\":"/ \\");Thread.sleep(750);}}}

-11 bytes thanks to @ceilingcat.
Explanation:
Try it online. (After it has timed out after 60 sec.)
interface M{                     // Class
  static void main(String[]a)    //  Mandatory main-method
      throws Exception{          //    Required throws for the `Thread.sleep`
    for(;a[0].matches("[1-9]{2,100}")
                                 //   Validate 2-100 integers only containing 1-9
         &!a[0].matches(".*(.)\\2.*|(.).*\\1")
                                 //   Validate no adjacent duplicated char (with wrap-around)
        ;)                       //   And start an infinite loop if it's valid:
      for(int c:a[0].getBytes()){//    Inner loop over the characters of the input:
        c-=48;                   //     Convert the character-code to an integer
        System.out.printf("%s%n%s%n%s%n",
                                 //     Print:
          c<2?" @ ":c<3?"\\@/":c<4?"|@_":c<5?"_@|":c<6?"@/ ":c<7?" \\@":c<8?"|@|":c<9?"\\@\\":"/@/",
                                 //      The top part of the stick figure
          c<2?"/|\\":" | ",      //      The middle part of the stick figure
          c%7>4?"/|\\":"/ \\");  //      The bottom part of the stick figure
        Thread.sleep(750);}}}    //     Sleep 750 ms

Gif:
(Note: Old gif, since it's clearly jdk1.8+ now.)

Usually we say Java 7 to refer to this version of Java as 1.7 can confuse some to think that it is Java 1 revision 7

The long if statement could be turned into something like p(new String[]{" @ ",y,"|@_", ... }[c-49]);if(c==49){p(x);l();}else if(c==53){w();p(x);}else d();. Also I think that defining l and w wastes characters, now that they're only used twice. Consider letting s instead be char[] s=a[0].toCharArray(); all the other operations with it are much shorter, then.

Mathematica, 252 bytes
i=0;Dynamic[Uncompress["1:eJxTTMoPSuNkYGAoZgESPpnFJcFCQIaCQ4yBoZF+TUwMmFaIiQELx8Q46IMEFGrgwoJA4RqHeCyi8Q41aKICQFEUA2qg5gIlHdCEIeaimyAMcQTEWWj26aO7DQDaqDEh"][[FromDigits[#~StringTake~{i=i~Mod~StringLength@#+1}]]],UpdateInterval->3/4,TrackedSymbols->{}]&

Would be nice if someone could create a GIF. Run in a notebook.

Python3, 338 bytes
import os,time
p=" @ \n/|\\\n/ \\","\\@/\n | \n/ \\","|@_\n | \n/ \\","_@|\n | \n/ \\","@/ \n | \n/|\\"," \\@\n | \n/|\\","|@|\n | \n/ \\","\\@\\\n | \n/ \\","/@/\n | \n/ \\"
i=input()
for j in range(len(i)):(i[j]in"123456789"and i[j]!=i[(j+1)%len(i)])or exit()
while 1:[[time.sleep(0.75),os.system("clear"),print(p[int(j)-1])]for j in i]

source: Stack Exchange

license: 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/

sort: votes


text:
KOTH: Everybody loves tokens
In this game two players compete to eat the most points worth of tokens, but there's a twist! Eating multiple tokens in a row of the same color gives an ever-growing bonus, but watch out, or your opponent will thwart your plans by eating the tokens you want before you can!
Rules:

1 versus 1
n by n board (random size between 5x5 and 15x15)
You and your opponent will spawn in the same random cell
Throughout the board will be randomly generated numbers in some cells ranging in value from 1-3
2 * (the width of the board) tokens will be generated, but there can be overrides, so there may be fewer by chance.
Each number will be one of 3 colors: Red, Green, or Blue, in hex RGB format
Each round, player 1 moves and the board is updated, then player 2 moves, and the board is updated. So each player can effectively tell what move the previous player made based on the change in the board state. This continues until the game ends, as described later.
You have 6 possible actions for a turn: UP, RIGHT, DOWN, LEFT, EAT, and PASS
The 4 move commands are self-explanatory, and you CAN pass your turn. If you return a nonsensical move, we will assume you meant pass. If you try to move off the edge of the board, you will not move. The edges don't wrap.
EAT consumes the number you are currently in the same space as
You gain as many points as the number you consume
If you eat 2 numbers in a row of the same color, you get +1
If you eat 3 numbers in a row of the same color, you get +2
If you eat m numbers in a row of the same color, you get +(m-1)
These bonuses are added cumulatively, so getting m numbers in a row leads to m*(m-1)/2 in total bonus by the time you eat a different color.
Game end conditions:

All numbers are consumed
4 * (the width of the board) turns have gone by with no effective eating (just saying “EAT” with no token where you are doesn't count) occurring by either player (any token is reachable in 2 * (the width) moves, so this bound will only be surpassed if both players have no single target token in mind)

Your AI should take less than a second to make a move, else PASS will be assumed as your choice.

The tournament will be round robin with a large number of rounds, say 100 or 1000. A random board is generated, and each ordered pair of different players is run on that board. After the tournament completes we will rank people by their total score. So even if you are player 2 for a game, your goal is still to get as many points as possible.
AI Submission: The language my controller supports is Javascript. Multiple submissions are allowed. Everyone submits a constructor for an object like this:
function (player1) {
    this.yourMove = function (b) {
        return "MOVE";
    }
}

The input player1 is a boolean saying whether you are player 1 or not.
Your constructor must have the yourMove function, but it can have
any number of additional functions or values as well. Don't define any
global variables, just put them as variables on your object. A new version
of your object will be created at the beginning of each match, and
yourMove will be called on it, with the current board as input, on each of your turns, and should return a valid move.
b, the input to yourMove, is a copy of the current board, here are the
constructors, with input examples, though you can't call them yourself:
function token(color, points) {
    this.color = color; //"#FF0000"
    this.points = points; //5
}

function player(pos, score, colorBonus, lastColor) {
    this.pos = pos; //[5, 5]
    this.score = score; //9
    this.colorBonus = colorBonus; //i.e. 2 if you just ate 3 blue tokens in a row
                                  //0 if you just ate two different colors.
    this.lastColor = lastColor; //"#00FF00", is "#000000" at start
}

function board(player1, player2, tokens) {
    this.player1 = player1; //new player([5, 5], 9, 2, "#00FF00")
    this.player2 = player2; //new player([5, 5], 9, 2, "#00FF00")
    this.tokens = tokens; //[[new token("#0000FF", 5), false],
                      // [new token("#0000FF", 5), false]]
}

The token array has "false" for any empty squares, and tokens[a][b] is
the token at x = a, y = b, numbered starting from the upper-left corner.
Controller:
Here's a link to the controller in GitHub. It's an html file that you can run to see how the game and the round-robin works, and it comes with two AIs, a random one that moves in a random direction each turn but eats tokens at its position, and a naive algorithm that goes for the nearest token that gives the most points. I will add in each AI as it is submitted.
Below is a snippet that allows you to run the controller on the default AI.
Current AIs:

KindaRandomAI
NaiveAI
MirrorBot
HungryBot

<!DOCTYPE html>
<html>

<body>

  <canvas id="myCanvas" width="700" height="600" style="border:1px solid #c3c3c3;">
    Your browser does not support the HTML5 canvas tag.
  </canvas>

  <script>
    // AI Array, put in at least two constructor functions as described in the
     // data file, and it will do round robin on them.
     // Also, you can adjust some variables for testing purposes only.
    var interval = 1; // in milliseconds per turn
    var matches = 10; // number of matches for each pairing
    var aiArray = [];
    myAI = function(player1) {
      this.player1 = player1;
      this.yourMove = function(b) {
        var me;
        if (this.player1) {
          me = b.player1;
        } else {
          me = b.player2;
        }
        var d = 0;
        var tokenP;
        while (tokenP == undefined) {
          var arr = this.findTokensAtDistance(me.pos, d)
          tokenP = this.findBestToken(arr, b.tokens, me);
          d += 1;
        }
        return this.startAndGoalToCommand(me.pos, tokenP);
      }
      this.findTokensAtDistance = function(p, d) {
        if (d == 0) {
          return [
            [p[0], p[1]]
          ];
        }
        var myArr = [];
        for (i = 0; i <= d; i++) {
          myArr[i] = [i, d - i];
        }
        var mySecArr = [];
        for (i = 0; i <= d; i++) {
          mySecArr[i] = [myArr[i][0] + p[0], myArr[i][1] + p[1]];
        }
        mySecArr[mySecArr.length] = [myArr[0][0] + p[0], -myArr[0][1] + p[1]];
        for (i = 1; i < myArr.length - 1; i++) {
          mySecArr[mySecArr.length] = [-myArr[i][0] + p[0], myArr[i][1] + p[1]]
          mySecArr[mySecArr.length] = [myArr[i][0] + p[0], -myArr[i][1] + p[1]]
          mySecArr[mySecArr.length] = [-myArr[i][0] + p[0], -myArr[i][1] + p[1]]
        }
        mySecArr[mySecArr.length] = [-myArr[myArr.length - 1][0] + p[0], myArr[myArr.length - 1][1] + p[1]];
        return mySecArr;
      }
      this.findBestToken = function(arr, t, player) {
        var tokenPos;
        for (i = 0; i < arr.length; i++) {
          if (arr[i][0] >= 0 && arr[i][0] < t.length && arr[i][1] >= 0 && arr[i][1] < t.length) {
            if (t[arr[i][0]][arr[i][1]] != false && ((tokenPos == undefined) || (this.tokenScore(player, t[arr[i][0]][arr[i][1]]) > this.tokenScore(player, t[tokenPos[0]][tokenPos[1]])))) {
              tokenPos = [arr[i][0],
                [arr[i][1]]
              ];
            }
          }
        }
        return tokenPos;
      }
      this.tokenScore = function(player, token) {
        if (player.lastColor == token.color) {
          return player.colorBonus + 1 + token.points;
        } else {
          return token.points;
        }
      }
      this.startAndGoalToCommand = function(start, goal) {
        var diff = [goal[0] - start[0], goal[1] - start[1]];
        if (diff[0] > 0) {
          return "RIGHT";
        } else if (diff[1] > 0) {
          return "DOWN";
        } else if (diff[1] < 0) {
          return "UP";
        } else if (diff[0] < 0) {
          return "LEFT";
        } else {
          return "EAT";
        }
      }
    }
    aiArray[0] = myAI;
     // This is a really stupid AI, used to test that the round-robin selected
     // it is the worst by far
    myStupidAI = function(player1) {
      this.player1 = player1;
      this.yourMove = function(b) {
        var me;
        if (this.player1) {
          me = b.player1;
        } else {
          me = b.player2;
        }
        if (b.tokens[me.pos[0]][me.pos[1]] != false) {
          return "EAT";
        } else {
          var dirs = this.getViableDirections(b, me.pos);
          var rand = Math.floor(Math.random() * dirs.length);
          return dirs[rand];
        }
      }
      this.getViableDirections = function(b, p) {
        var dirs = [];
        if (p[0] > 0) {
          dirs.push("LEFT");
        }
        if (p[1] > 0) {
          dirs.push("UP");
        }
        if (p[1] < b.tokens.length - 1) {
          dirs.push("DOWN");
        }
        if (p[0] < b.tokens.length - 1) {
          dirs.push("RIGHT");
        }
        return dirs;
      }
    }
    aiArray[1] = myStupidAI;
    mirrorBot = function(player1){
        this.hasStarted=0;
        this.player1 = player1;
        this.yourMove = function(b){
            this.op = this.player1 ? b.player2 : b.player1;
            var out = "EAT";
            if(this.hasStarted){
                if(this.opl.pos[0] < this.op.pos[0]) out = "LEFT";
                if(this.opl.pos[0] > this.op.pos[0]) out = "RIGHT";
                if(this.opl.pos[1] < this.op.pos[1]) out = "UP";
                if(this.opl.pos[1] > this.op.pos[1]) out = "DOWN";
            }
            this.opl = this.op;
            this.hasStarted = 1;
            return out;
        }
    }
    aiArray[2] = mirrorBot;
    hungryBot = function(first) {
  // Set up "self"
  var self = this;

  // Determine player order
  this.player = -(first - 2);
  this.enemy = first + 1;

  // Action associative array
  this.actions = ['EAT', 'LEFT', 'RIGHT', 'UP', 'DOWN'];

  //Logic handler
  this.yourMove = function(board) {
// Determine player object
var player = board['player' + self.player];
var enemy = board['player' + self.enemy];

// Point value action grid
var actions = [0, 0, 0, 0, 0]; // Associative with "this.actions"

// Board dimensions
var size = board.tokens.length;
var maxDist = size * 2;

// Colors remaining
var colors = {
  '#FF0000': 0,
  '#00FF00': 0,
  '#0000FF': 0
};

// Averaged value weight
var average = [0, 0];

// Total points
var points = 0;

// Token holder
var tokens = [];

// Token parser
for (var i = 0, x = 0, y = 0; i < size * size; i += 1, x = i % size, y = i / size | 0) {
  if (!board.tokens[x][y]) {
    continue;
  } else {
    var token = {};
    token.points = board.tokens[x][y].points;
    token.color = board.tokens[x][y].color;
    token.x = x - player.pos[0];
    token.y = y - player.pos[1];
    token.distX = Math.abs(token.x);
    token.distY = Math.abs(token.y);
    token.dist = token.distX + token.distY;
    token.distE = Math.abs(x - enemy.pos[0]) + Math.abs(y - enemy.pos[1]);
    token.value = -token.points - (player.colorBonus + 1) * (token.color == player.lastColor) * ((token.dist == 0) + 1) * 1.618 - (enemy.colorBonus + 1) * (token.color == enemy.lastColor);
    tokens.push(token);
    colors[token.color] += 1;
    points += token.points;
    average[0] += x * token.points;
    average[1] += y * token.points;
  }
}

// Determine actual average
average[0] = average[0] / points | 0;
average[1] = average[1] / points | 0;

// Pick best token
var best = 0;

// Calculate point values of tokens
for (i = 0; i < tokens.length; i++) {
  var token = tokens[i];
  // Add remaining numbers of tokens of color as factor
  token.value -= (colors[token.color] / tokens.length) * 1.618;
  // Subtract distance as a factor
  token.value += token.dist;
  // Add distance to average to value
  token.value += (Math.abs(average[0] - (token.x + player.pos[0])) + Math.abs(average[1] - (token.y + player.pos[1]))) / Math.sqrt(2);
  // Consider them higher value if we are closer, and lower if they are
  token.value += ((token.dist - token.distE) / (token.dist + token.distE + 0.001)) * token.dist;
  // Don't go for it if enemy is already there
  token.value += (token.distE == 0 && token.dist > 0) * 100;

  if (tokens[best].value > tokens[i].value || (tokens[best].value === tokens[i].value && Math.round(Math.random()))) {
    best = i;
  }
}

// Set token to best token
var token = tokens[best];

// What to respond with
var response = 'PASS';

// Find best action to get token
if (token.dist == 0) {
  response = 'EAT'; // We're on the token
} else if (token.distX >= token.distY) { // Token is more horizontal
  if (token.x < 0) { // Token is left
    response = 'LEFT';
  } else if (token.x > 0) { // Token is right
    response = 'RIGHT';
  }
} else if (token.distX < token.distY) { // Token is more vertical
  if (token.y < 0) { // Token is above
    response = 'UP';
  } else if (token.y > 0) { // Token is below
    response = 'DOWN';
  }
}

// Return response
return response;
  }
};
    aiArray[3]=hungryBot;
    for (i = 0; i < aiArray.length; i += 1) {
      Object.freeze(aiArray[i]);
    }
     // This is the actual code to run the program. You shouldn't mess with it,
     // or your AI might not work during the actual competition.
     // Also note that you can't access this code at all in your AI.
     // Feel free to make suggestions and we'll try to incorporate them,
     // and let us know if something isn't working correctly.
    Object.freeze(aiArray);
    setInterval((function() {
      function token(color, points) {
        this.color = color;
        this.points = points;
      }

      function player(pos, score, colorBonus, lastColor) {
        this.pos = pos;
        this.score = score;
        this.colorBonus = colorBonus;
        this.lastColor = lastColor;
      }

      function board(player1, player2, tokens) {
        this.player1 = player1;
        this.player2 = player2;
        this.tokens = tokens;
      }

      function copyBoard(b) {
        return new board(copyPlayer(b.player1), copyPlayer(b.player2), copyTokens(b.tokens));
      }

      function copyTokens(t) {
        var tokens = [];
        for (i = 0; i < t.length; i++) {
          tokens[i] = [];
          for (j = 0; j < t[i].length; j++) {
            tokens[i][j] = t[i][j];
          }
        }
        return tokens;
      }

      function copyPlayer(p) {
        return new player([p.pos[0], p.pos[1]], p.score, p.colorBonus, p.lastColor);
      }

      function endGame(b) {
        if (b.player1.score > b.player2.score) {
          var c = document.getElementById("myCanvas");
          var ctx = c.getContext("2d");
          ctx.font = 20 + "px Arial";
          ctx.textAlign = "left";
          ctx.fillStyle = "#000000";
          ctx.fillText("Player 1", 601, 160);
          ctx.fillText("wins!", 601, 180);
        } else if (b.player1.score < b.player2.score) {
          var c = document.getElementById("myCanvas");
          var ctx = c.getContext("2d");
          ctx.font = 20 + "px Arial";
          ctx.textAlign = "left";
          ctx.fillStyle = "#000000";
          ctx.fillText("Player 2", 601, 160);
          ctx.fillText("wins!", 601, 180);
        } else {
          var c = document.getElementById("myCanvas");
          var ctx = c.getContext("2d");
          ctx.font = 20 + "px Arial";
          ctx.textAlign = "left";
          ctx.fillStyle = "#000000";
          ctx.fillText("It's a", 601, 160);
          ctx.fillText("draw!", 601, 180);
        }
      }

      function genTokenArray(size) {
        var temp = [];
        for (i = 0; i < size; i++) {
          temp[i] = [];
          for (j = 0; j < size; j++) {
            temp[i][j] = false;
          }
        }
        return temp;
      }

      function genRandomTokenArray(size) {
        var temp = genTokenArray(size);
        for (i = 0; i < size * 2; i++) {
          var rand = Math.floor(Math.random() * temp.length);
          var points = Math.floor(Math.random() * 3 + 1);
          var rand2 = Math.floor(Math.random() * 3);
          var color;
          var rand3 = Math.floor(Math.random() * temp[rand].length);
          if (rand2 == 0) {
            color = "#FF0000"
          } else if (rand2 == 1) {
            color = "#00FF00"
          } else {
            color = "#0000FF"
          }
          temp[rand][rand3] = new token(color, points);
        }
        return temp;
      }

      function countTokens(tokenArr) {
        var x = 0;
        for (i = 0; i < tokenArr.length; i++) {
          for (j = 0; j < tokenArr[i].length; j++) {
            if (tokenArr[i][j] != false) {
              x += 1
            }
          }
        }
        return x;
      }

      function actPlayer(b, p, s) {
        if (s == "UP" && p.pos[1] > 0) {
          p.pos[1] -= 1;
        } else if (s == "RIGHT" && p.pos[0] < b.tokens.length - 1) {
          p.pos[0] += 1;
        } else if (s == "DOWN" && p.pos[1] < b.tokens.length - 1) {
          p.pos[1] += 1;
        } else if (s == "LEFT" && p.pos[0] > 0) {
          p.pos[0] -= 1;
        } else if (s == "EAT" && b.tokens[p.pos[0]][p.pos[1]] != false) {
          if (p.lastColor == b.tokens[p.pos[0]][p.pos[1]].color) {
            p.colorBonus += 1;
            p.score += p.colorBonus;
          } else {
            p.lastColor = b.tokens[p.pos[0]][p.pos[1]].color;
            p.colorBonus = 0;
          }
          p.score += b.tokens[p.pos[0]][p.pos[1]].points;
          b.tokens[p.pos[0]][p.pos[1]] = false;
        }
      }

      function drawEmptyRect() {
        var c = document.getElementById("myCanvas");
        var ctx = c.getContext("2d");
        ctx.clearRect(0, 0, 700, 600);
      }

      function drawToken(t, x, y, g) {
        drawEntity(x, y, t.points, t.color, "#000000", 300 / g, g);
      }

      function drawLittleEntity(x, y, label, fillColor, labelColor, size, cX, cY, g) {
        var delta = 600 / g;
        var x1 = x * delta + cX * delta / 4;
        var y1 = y * delta + cY * delta / 4;
        var c = document.getElementById("myCanvas");
        var ctx = c.getContext("2d");
        ctx.beginPath();
        ctx.arc(x1, y1, size / 2, 0, 2 * Math.PI);
        ctx.stroke();
        ctx.fillStyle = fillColor;
        ctx.fill();
        ctx.font = delta / 2 + "px Arial";
        ctx.textAlign = "center";
        ctx.fillStyle = labelColor;
        ctx.fillText(label, x1, y1 + delta * 3 / 16);
      }

      function drawEntity(x, y, label, fillColor, labelColor, size, g) {
        var delta = 600 / g;
        var x1 = x * delta + delta / 2;
        var y1 = y * delta + delta / 2;
        var c = document.getElementById("myCanvas");
        var ctx = c.getContext("2d");
        ctx.beginPath();
        ctx.arc(x1, y1, size, 0, 2 * Math.PI);
        ctx.stroke();
        ctx.fillStyle = fillColor;
        ctx.fill();
        ctx.font = delta + "px Arial";
        ctx.textAlign = "center";
        ctx.fillStyle = labelColor;
        ctx.fillText(label, x1, y1 + delta * 3 / 8);
      }

      function drawAllTokens(arrToken) {
        for (i = 0; i < arrToken.length; i++) {
          for (j = 0; j < arrToken[i].length; j++) {
            if (arrToken[i][j] != false) {
              drawToken(arrToken[i][j], i, j, arrToken.length);
            }
          }
        }
      }

      function drawGrid(g) {
        var delta = 600 / g;
        for (i = 0; i <= g; i++) {
          var canvas = document.getElementById("myCanvas");
          var ctx = canvas.getContext("2d");
          ctx.beginPath();
          ctx.moveTo(i * delta, 0);
          ctx.lineTo(i * delta, 600);
          ctx.stroke();
        }
        for (j = 0; j <= g; j++) {
          var canvas = document.getElementById("myCanvas");
          var ctx = canvas.getContext("2d");
          ctx.beginPath();
          ctx.moveTo(0, j * delta);
          ctx.lineTo(600, j * delta);
          ctx.stroke();
        }
      }

      function drawPlayer1(b, g) {
        drawLittleEntity(b.player1.pos[0], b.player1.pos[1], "F", "#000000", "#FFFFFF", 300 / g, 1, 1, g);
      }

      function drawPlayer2(b, g) {
        drawLittleEntity(b.player2.pos[0], b.player2.pos[1], "S", "#000000", "#FFFFFF", 300 / g, 3, 3, g);
      }

      function drawScore(b) {
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        ctx.font = "20px Arial";
        ctx.fillStyle = "#000000";
        ctx.textAlign = "left";
        ctx.fillText("P" + indices[0] + " Score:", 601, 50);
        ctx.fillText(b.player1.score, 601, 70);
        ctx.fillText("P" + indices[1] + " Score:", 601, 100);
        ctx.fillText(b.player2.score, 601, 120);
      }

      function drawScoreNum(s, i) {
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        ctx.font = "20px Arial";
        ctx.fillStyle = "#000000";
        ctx.textAlign = "left";
        ctx.fillText("P" + i + " Score:", 601, i * 50 + 50);
        ctx.fillText(s, 601, i * 50 + 70);
      }

      function redraw(b, g) {
        drawEmptyRect();
        drawGrid(g);
        drawScore(b);
        drawAllTokens(b.tokens);
        drawPlayer1(b, g);
        drawPlayer2(b, g);
        drawScoreNum()
      }

      function nextPair(pair, total) {
        var pairRes = [pair[0], (pair[1] + 1) % total];
        if (pairRes[1] == 0) {
          pairRes[0] = pairRes[0] + 1;
        }
        return pairRes;
      }

      function nextGameUnfair() {
        scores[indices[0]] = scores[indices[0]] + currBoard.player1.score;
        scores[indices[1]] = scores[indices[1]] + currBoard.player2.score;
        if (matchCount >= matches) {
          matchCount = 0;
          indices = nextPair(indices, aiArray.length);
          if (indices[0] == indices[1]) {
            indices = nextPair(indices, aiArray.length);
          }
          if (indices[0] >= aiArray.length) {
            return false;
          }
          player1Turn = true;
          timeWithoutEating = 0;
          firstAI = new aiArray[indices[0]](true);
          secondAI = new aiArray[indices[1]](false);
          currBoard = genBoard();
        } else {
          matchCount++;
          player1Turn = true;
          timeWithoutEating = 0;
          firstAI = new aiArray[indices[0]](true);
          secondAI = new aiArray[indices[1]](false);
          currBoard = genBoard();
        }
        return true;
      }

      function nextGameFair() {
        scores[indices[0]] = scores[indices[0]] + currBoard.player1.score;
        scores[indices[1]] = scores[indices[1]] + currBoard.player2.score;
        indices = nextPair(indices, aiArray.length);
        if (indices[0] == indices[1]) {
          indices = nextPair(indices, aiArray.length);
        }
        if (indices[0] >= aiArray.length) {
          indices = [0, 1];
          matchCount++;
          if (matchCount >= matches) {
            return false;
          }
          player1Turn = true;
          timeWithoutEating = 0;
          currBoard = genBoard();
        } else {
          player1Turn = true;
          timeWithoutEating = 0;
          currBoard = savedBoard;
        }
        firstAI = new aiArray[indices[0]](true);
        secondAI = new aiArray[indices[1]](false);
        savedBoard = copyBoard(currBoard);
        return true;
      }

      function genBoard() {
        var rand = Math.floor(Math.random() * 11 + 5);
        var randX = Math.floor(Math.random() * rand);
        var randY = Math.floor(Math.random() * rand);
        return new board(new player([randX, randY], 0, 0, "#000000"),
          new player([randX, randY], 0, 0, "#000000"),
          genRandomTokenArray(rand));
      }
      var running = true;
      var indices = [0, 1];
      var scores = []
      for (i = 0; i < aiArray.length; i++) {
        scores.push(0);
      }
      var matchCount = 0;
      var firstAI = new aiArray[0](true);
      var secondAI = new aiArray[1](false);
      var player1Turn = true;
      var currBoard = genBoard();
      var savedBoard = copyBoard(currBoard);
      var timeWithoutEating = 0;
      return function() {
        if (running) {
          var numTokens = countTokens(currBoard.tokens);
          if (numTokens <= 0) {} else if (player1Turn) {
            actPlayer(currBoard, currBoard.player1, firstAI.yourMove(copyBoard(currBoard)));
          } else {
            actPlayer(currBoard, currBoard.player2, secondAI.yourMove(copyBoard(currBoard)));
          }
          player1Turn = !player1Turn;
          redraw(currBoard, currBoard.tokens.length);
          if (numTokens > countTokens(currBoard.tokens)) {
            timeWithoutEating = 0;
          } else {
            timeWithoutEating += 1;
          }
          if (numTokens <= 0 || timeWithoutEating > 4 * currBoard.tokens.length) {
            running = nextGameFair();
          }
        } else {
          drawEmptyRect();
          for (i = 0; i < scores.length; i++) {
            drawScoreNum(scores[i], i);
          }
        }
      }
    })(), interval);
  </script>

</body>

</html>

Yay, a KOTH! It has been forever since the last one.

Agreed, I love me a good KOTH and this seems to be a great premise. I'm a bit green to js, how does one persist game state between moves if we can't save results within out player object?

Is the board width passed anywhere into the function?

@BentNeeHumor Yes, the function that takes in the player1 boolean is the constructor for your AI, which will have a yourMove function that takes the current board as input, as b.

@DoctorHeckle Refer to previous comment, the constructor for example could say this.yourMove = function (b) {//do stuff with b;this.lastBoard=b} and this.lastBoard will give you the last board.

It could be nice to make your naive AI compete, to serve as reference. And for the lulz! ;) (I guess random would skew the results, but the lol factor would be even better)

I haven't participated in a KOTH here before; are multiple submissions ok, or is it one per user?

@DylanSp Sometimes they aren't allowed due to collusion possibilities, but in this case, collusion would have minimal benefits, so I'll allow multiple submissions.

Is player.colorBonus equal to the next color bonus you will earn, or the previous one earned?

@Blue http://codegolf.stackexchange.com/questions/77235/koth-everybody-loves-tokens#comment188351_77235

@BentNeeHumor The previous one, so if you eat two Blue in a row, player.colorBonus==1, and when you eat another Blue, you get +2 and the bonus increases by 1

Would it be 0 if the previous color was different?

@BentNeeHumor Yes. It starts out 0 (and lastColor starts as "#000000", different from any color on the board) and is reset to 0 whenever a different color than the previous one is eaten.

Is the board wrap-around or bounded at the edges? If the latter, does a move of LEFT when you are at the LHS of the board, for example, count as equivalent to PASS?

@Penguino Bounded, working like you say it does, updated post to indicate that.

As someone mentioned before, you should submit your own bots as answers. It allows for individual questions/commentary, and for reference as people build their own bots.

Do the claims of teleportation indicate a problem with the controller?

@trichoplax No, it turned out to be a problem with my AI, the controller is fine.

@Blue Ah OK. I was thinking that the controller had permitted your AI to make the mentioned teleport moves.

The video does make it look like the controller is permitting the bot to teleport, suggesting a problem with the controller itself.

@trichoplax The board is deep-copied before being given to the bots, so as long as the copying is correct, it can't be the bots somehow affecting the board by mistake.

Yes the bot alone shouldn't be able to make this happen. The linked video does seem to indicate a problem with the controller itself, but I can't guess how it is happening.

Also, the snippet is too long if I add the next AI. What's the best way to move the code elsewhere and still put it in the snippet?

Host individual files on GitHub pages maybe. That way it will also be a little easier to read.

So... who wins? :3

Is there a page that explains how KOTH works?

Is the contest still on? Which languages can be used?

HungryBot
Uses a point system to add weight to the value of pursuing each token. Uses a variety of different factors in its consideration, and reevaluates them each turn to ensure its following the best strategy.
function hungryBot(first) {
  // Set up "self"
  var self = this;

  // Determine player order
  this.player = -(first - 2);
  this.enemy = first + 1;

  // Action associative array
  this.actions = ['EAT', 'LEFT', 'RIGHT', 'UP', 'DOWN'];

  //Logic handler
  this.yourMove = function(board) {
    // Determine player object
    var player = board['player' + self.player];
    var enemy = board['player' + self.enemy];

    // Point value action grid
    var actions = [0, 0, 0, 0, 0]; // Associative with "this.actions"

    // Board dimensions
    var size = board.tokens.length;
    var maxDist = size * 2;

    // Colors remaining
    var colors = {
      '#FF0000': 0,
      '#00FF00': 0,
      '#0000FF': 0
    };

    // Averaged value weight
    var average = [0, 0];

    // Total points
    var points = 0;

    // Token holder
    var tokens = [];

    // Token parser
    for (var i = 0, x = 0, y = 0; i < size * size; i += 1, x = i % size, y = i / size | 0) {
      if (!board.tokens[x][y]) {
        continue;
      } else {
        var token = {};
        token.points = board.tokens[x][y].points;
        token.color = board.tokens[x][y].color;
        token.x = x - player.pos[0];
        token.y = y - player.pos[1];
        token.distX = Math.abs(token.x);
        token.distY = Math.abs(token.y);
        token.dist = token.distX + token.distY;
        token.distE = Math.abs(x - enemy.pos[0]) + Math.abs(y - enemy.pos[1]);
        token.value = -token.points - (player.colorBonus + 1) * (token.color == player.lastColor) * ((token.dist == 0) + 1) * 1.618 - (enemy.colorBonus + 1) * (token.color == enemy.lastColor);
        tokens.push(token);
        colors[token.color] += 1;
        points += token.points;
        average[0] += x * token.points;
        average[1] += y * token.points;
      }
    }

    // Determine actual average
    average[0] = average[0] / points | 0;
    average[1] = average[1] / points | 0;

    // Pick best token
    var best = 0;

    // Calculate point values of tokens
    for (i = 0; i < tokens.length; i++) {
      var token = tokens[i];
      // Add remaining numbers of tokens of color as factor
      token.value -= (colors[token.color] / tokens.length) * 1.618;
      // Subtract distance as a factor
      token.value += token.dist;
      // Add distance to average to value
      token.value += (Math.abs(average[0] - (token.x + player.pos[0])) + Math.abs(average[1] - (token.y + player.pos[1]))) / Math.sqrt(2);
      // Consider them higher value if we are closer, and lower if they are
      token.value += ((token.dist - token.distE) / (token.dist + token.distE + 0.001)) * token.dist;
      // Don't go for it if enemy is already there
      token.value += (token.distE == 0 && token.dist > 0) * 100;

      if (tokens[best].value > tokens[i].value || (tokens[best].value === tokens[i].value && Math.round(Math.random()))) {
        best = i;
      }
    }

    // Set token to best token
    var token = tokens[best];

    // What to respond with
    var response = 'PASS';

    // Find best action to get token
    if (token.dist == 0) {
      response = 'EAT'; // We're on the token
    } else if (token.distX >= token.distY) { // Token is more horizontal
      if (token.x < 0) { // Token is left
        response = 'LEFT';
      } else if (token.x > 0) { // Token is right
        response = 'RIGHT';
      }
    } else if (token.distX < token.distY) { // Token is more vertical
      if (token.y < 0) { // Token is above
        response = 'UP';
      } else if (token.y > 0) { // Token is below
        response = 'DOWN';
      }
    }

    // Return response
    return response;
  }
};

Are you a Python programmer?

@CatsAreFluffy Not really...?

Just thought you were because self :)

Why use self? Isn't this sufficient?

PATH bot
Acronym stands for Pathfinding And Tree Heuristics Bot
EDIT: As of now, here are the rankings for the AIs, with the points

HungryBot (6422)
PATH bot (4591)
NaiveAI (3811)
KindaRandomAI (618)
MirrorBot (193)
LazyBot (25)

Link to complete controller on github
Description: Like NaiveAI, this bot finds the nearest token that will give it the most points. However, it also simulates the outcomes of each of its moves, up to 6 times.
Rationale: Because NaiveAI is already pretty good, I though I would make it better. Without looking at the code first (big mistake).
Beats: All except HungryBot
Looses to: None except HungryBot
Problems:

Cannot simulate increased streak
Hangs while calculating best token
Can teleport

I still don't know why it was teleporting, but I fixed it. Old video here: https://youtu.be/BIhSKycF9iA
Full code:
pathBot = function (player1)
{
    this.pathNode = function(pos,ppt,parents,par)
    {
        this.pos = pos;this.ppt = ppt;this.parents = parents;this.par=par;
        this.childs=[];
    }
    this.addChildren = function (pn,children)
    {
        pn.childs=[];
        for(var i=0; i<children.length; i=i+1)
        {
            if(pn.parents.indexOf(children[i].pos)==-1&&pn.pos!=children[i].pos)
                pn.childs.push(
                    new this.pathNode(
                        children[i].pos,
                        children[i].ppt*pn.ppt,
                        pn.parents.concat([pn.pos]),
                        pn
                    )
                );
        }
    }
    this.orderTokensByPPT = function(b,pos){
        var tokens = [];
        for(var y=0; y<b.tokens.length; y=y+1)
        {
            for(var x=0; x<b.tokens[y].length; x=x+1)
            {
                var tok = b.tokens[y][x];
                if(tok)
                {
                    tokens.push(
                        new this.pathNode(
                            [y,x],
                            (tok.points+(tok.color==this.color ? this.streak : 0)) / this.lenOfMovesTo(pos,[y,x]),
                            [],
                            undefined
                        )
                    );
                }
            }
        }
        tokens.sort(function(a,b){
            return b.ppt - a.ppt;
        });
        return tokens;
    }
    this.lenOfMovesTo = function(cur,pos)
    {
        return Math.abs(cur[0]-pos[0])+Math.abs(cur[1]-pos[1])+1;
    }
    this.startAndGoalToCommand = function (start, goal) {
        var diff = [goal[0] - start[0], goal[1] - start[1]];
        if (diff[0] > 0) { return "RIGHT"; }
        else if (diff[1] > 0) { return "DOWN"; }
        else if (diff[1] < 0) { return "UP"; }
        else if (diff[0] < 0) { return "LEFT"; }
        else { return "EAT"; }
    }
    this.color = 0;
    this.streak = 0;
    this.eatTok = function(b)
    {
        if(b.tokens[this.me.pos[0]][this.me.pos[1]].color==this.color)
        {
            this.streak++;
        }
        else{
            this.streak = 0;
            this.color = b.tokens[this.me.pos[0]][this.me.pos[1]].color;
        }
        this.bestToken = false;
        return "EAT";
    }

    this.recurLen = 6;
    this.include = 4;
    this.recurDown = function(b,pn,level)
    {
        if(level==0) return pn;
        this.addChildren(pn,this.orderTokensByPPT(b,pn.pos));
        var newChilds = [];
        for(var i=0; i<pn.childs.length&&i<this.include; i=i+1)
        {
            newChilds.push(this.recurDown(b,pn.childs[i],level-1));
        }
        pn.childs = newChilds;
        return pn;
    }
    this.findMax = function(pn)
    {
        if(pn.childs)
        {
            var maxList = [];
            for(var i=0; i<pn.childs.length; i=i+1)
                maxList.push(this.findMax(pn.childs[i]));
            maxList.sort(
                function(a,b)
                {
                    return b.ppt-a.ppt;
                }
            );
            return maxList[0];
        }
        return pn;
    }
    this.findMaxList = function(pnList)
    {
        for(var i=0; i<pnList.lenght; i=i+1)
        {
            pnList[i] = this.findMax(pnList[i]);
        }
        pnList.sort(function(a,b){return b.ppt-a.ppt;});
        return pnList[0];
    }
    this.bestToken=false;
    this.yourMove = function(b){
        this.op = player1 ? b.player2 : b.player1;
        this.me = player1 ? b.player1 : b.player2;
        if(this.bestToken)
        {
            if(b.tokens[this.bestToken.pos[0]][this.bestToken.pos[1]]==undefined)
                this.bestToken = false;
        }
        if(!this.bestToken)
        {
            var paths = this.orderTokensByPPT(b,this.me.pos);
            for(var i=0; i<paths.length; i++)
            {
                paths[i] = this.recurDown(b,paths[i],this.recurLen);
            }
            var max = this.findMaxList(paths);
            while(max.par)
            {
                max = max.par;
            }
            this.bestToken = max;
        }
        var move = this.startAndGoalToCommand(this.me.pos,this.bestToken.pos);
        if(move=="EAT") return this.eatTok(b);
        else return move;
    }
}

SLaNTbot is slowing the turn speed down, and eating up 15% of my CPU... D: EDIT: And also not eating anything?

@Mwr247 the speed, yeah, it models ~2500 possibilities every tick. But for the eating thing, I don't exactly know why. Like I said in the question, it just teleports (aka moves multiple spaces in 1 turn), and sits there doing nothing. I put an alert just before the return and it seems to be giving the right instructions every time.

Maybe this: "Your AI should take less than a second to make a move, else PASS will be assumed as your choice.". I haven't read the controller, but if it's taking over a second, is it assuming PASS?

@Mwr247 I'll look into that, but it seems unlikely given that it was taking <1 second (or so I though) on my machine. Still, never hurts to look. Thank you!

@Mwr247 After some more testing, that is not it. It is making decisions almost as fast (at least for me) as NaiveAi. Also, you are more likely to experience teleportation on big maps

MirrorBot
Should be called "cannon fodder"
Description: Moves the exact opposite of what the other player did
Rationale: I wanted to get comfortable programming in JS again. This should not win
Will beat: No one
Will lose to: Everyone
function mirror(player1) {
    this.hasStarted=false;
    this.player1 = player1;
    this.opl=[0,0];
    this.yourMove = function(b){
        this.op = this.player1 ? b.player2.pos : b.player1.pos;
        out = "EAT";
        console.log(this.op);
        console.log(this.opl);
        if(this.hasStarted){
            if(this.opl[0] < this.op[0]) out = "RIGHT";
            if(this.opl[0] > this.op[0]) out = "LEFT";
            if(this.opl[1] < this.op[1]) out = "UP";
            if(this.opl[1] > this.op[1]) out = "DOWN";
        }
        this.opl = [this.op[0],this.op[1]];
        this.hasStarted = true;
        return out;
    }
}

There are a few problems with your code. Right and Left aren't opposite, and your function definition for yourMove isn't valid syntax. My code was broken before as well, so in the process of finding and fixing the problem in my code I fixed your code as well. You can look at the fixed code in my script.

@FricativeMelon I fixed the broken function definition. I have to counter the claim that right aren't opposite.

0,0 is the top-left corner, so positive x is right and negative x is left. if the new x-pos is greater in value than the old x-pos, the other player moved right, so you should move left, and vice-versa. Also, you should use var out = "EAT"; instead of out = "EAT";, since the later defines a global variable. Nitpicking a bit, the third and fourth lines don't do anything and can be removed as well, and op can be a local variable like out instead of a property.

@FricativeMelon ah, I get what you are saying. I have updated the code. Thank you!

I put your new code in the script, and it's working now. Doesn't beat RandomAI though :(

KindaRandomAI
Every turn, do the following:
If there is a token at your position, "EAT".
Otherwise, move in a random viable direction, i.e. if you're at the left edge don't say "LEFT".
kindaRandomAI = function(player1) {
    this.player1 = player1;
    this.yourMove = function(b) {
        var me;
        if (this.player1) {
            me = b.player1;
        } else {
            me = b.player2;
        }
        if (b.tokens[me.pos[0]][me.pos[1]] != false) {
            return "EAT";
        } else {
            var dirs = this.getViableDirections(b, me.pos);
            var rand = Math.floor(Math.random() * dirs.length);
            return dirs[rand];
        }
    }
    this.getViableDirections = function(b, p) {
        var dirs = [];
        if (p[0] > 0) {
            dirs.push("LEFT");
        }
        if (p[1] > 0) {
            dirs.push("UP");
        }
        if (p[1] < b.tokens.length - 1) {
            dirs.push("DOWN");
        }
        if (p[0] < b.tokens.length - 1) {
            dirs.push("RIGHT");
        }
        return dirs;
    }
}

-1 not completely random

That's better!.

NaiveAI
Starting with r=0, look at all tokens with taxicab distance r away from your position. If there are any, pick one that would give you the highest score if you got it right now. Otherwise, increase r by 1 and try again.
naiveAI = function(player1) {
  this.player1 = player1;
  this.yourMove = function(b) {
    var me;
    if (this.player1) {
      me = b.player1;
    } else {
      me = b.player2;
    }
    var d = 0;
    var tokenP;
    while (tokenP == undefined) {
      var arr = this.findTokensAtDistance(me.pos, d)
      tokenP = this.findBestToken(arr, b.tokens, me);
      d += 1;
    }
    return this.startAndGoalToCommand(me.pos, tokenP);
  }
  this.findTokensAtDistance = function(p, d) {
    if (d == 0) {
      return [
        [p[0], p[1]]
      ];
    }
    var myArr = [];
    for (i = 0; i <= d; i++) {
      myArr[i] = [i, d - i];
    }
    var mySecArr = [];
    for (i = 0; i <= d; i++) {
      mySecArr[i] = [myArr[i][0] + p[0], myArr[i][1] + p[1]];
    }
    mySecArr[mySecArr.length] = [myArr[0][0] + p[0], -myArr[0][1] + p[1]];
    for (i = 1; i < myArr.length - 1; i++) {
      mySecArr[mySecArr.length] = [-myArr[i][0] + p[0], myArr[i][1] + p[1]]
      mySecArr[mySecArr.length] = [myArr[i][0] + p[0], -myArr[i][1] + p[1]]
      mySecArr[mySecArr.length] = [-myArr[i][0] + p[0], -myArr[i][1] + p[1]]
    }
    mySecArr[mySecArr.length] = [-myArr[myArr.length - 1][0] + p[0], myArr[myArr.length - 1][1] + p[1]];
    return mySecArr;
  }
  this.findBestToken = function(arr, t, player) {
    var tokenPos;
    for (i = 0; i < arr.length; i++) {
      if (arr[i][0] >= 0 && arr[i][0] < t.length && arr[i][1] >= 0 && arr[i][1] < t.length) {
        if (t[arr[i][0]][arr[i][1]] != false && ((tokenPos == undefined) || (this.tokenScore(player, t[arr[i][0]][arr[i][1]]) > this.tokenScore(player, t[tokenPos[0]][tokenPos[1]])))) {
          tokenPos = [arr[i][0],
            [arr[i][1]]
          ];
        }
      }
    }
    return tokenPos;
  }
  this.tokenScore = function(player, token) {
    if (player.lastColor == token.color) {
      return player.colorBonus + 1 + token.points;
    } else {
      return token.points;
    }
  }
  this.startAndGoalToCommand = function(start, goal) {
    var diff = [goal[0] - start[0], goal[1] - start[1]];
    if (diff[0] > 0) {
      return "RIGHT";
    } else if (diff[1] > 0) {
      return "DOWN";
    } else if (diff[1] < 0) {
      return "UP";
    } else if (diff[0] < 0) {
      return "LEFT";
    } else {
      return "EAT";
    }
  }
}

LazyBot
Only eats something if he spawns on it.
This has no chance to win, but the challenge didn't have one of these, so why not.
lazyBot = function (player1) {
    this.yourMove = function(b) {
        return "EAT";
    }
}

Every koth has an EmoWolf...

@Blue It's not 100% emo, it tries to eat.

http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default/1916#1916

OneTarget
Finds the token that will give the most points in the least time and will go for that one. Ranks same color tokens a little higher because of the cumulative effect.
function (player1) {
    this.yourMove = function (b) {
        var me = player1? b.player1: b.player2;
        var him= player1? b.player2: b.player1;
        var x = me.pos[0];
        var y = me.pos[1];
        var maxVal = -1;
        var maxX = 0;
        var maxY = 0;
        for(var i = 0;i < b.tokens.length;i++){
            for(var j = 0;j < b.tokens.length;j++){
                if(b.tokens[i][j]){
                    var dist = Math.abs(x-i) + Math.abs(y-j);
                    var val = this.valueOf(b.tokens[i][j]);
                    val /= (dist + 1);
                    if(val > maxVal){
                        maxVal = val;
                        maxX = i;
                        maxY = j;
                    }
                }
            }
        }
        if(maxY < y)
            return "UP";
        if(maxX < x)
            return "LEFT";
        if(maxY > y)
            return "DOWN";
        if(maxX > x)
            return "RIGHT";
        return "EAT";
    }
    this.valueOf = function(t){
        //how many points would it give you?
        return t.points + (this.lastColor == t.color? 2 * this.colorBonus + 1 : 0);
    }
}

QuantityPlayer
All QuantityPlayer cares about is the amout of dots he eats, not the value or color of the dots. He know that even though all dots are different, they should be treated the same.
QuantityBot = function(playernum) {

this.dist = function(token) {
    return (Math.abs(token[0])+Math.abs(token[1]))
}

this.yourMove = function(game_board) {

    board_size = game_board.tokens.length
    board_area = board_size * board_size
    fete = board_size = size * 2

    token_list = []
    count = curr_x = curr_y = 0
    while(count < board_area) {
        if(game_board.tokens[x][y]) {
        token_list.push([x-player.pos[0],y-player.pos[1]])
        }
        count++; x = count % board_size; y = Math.floor(count / size)
    }

    closest_token = token_list[0]
    count = 1
    while(count < token_list.length) {
        curr_token = token_list[count]
        if(dist(curr_token) < dist(closest_token)){closest_token = curr_token}

        count++
    }

    if(dist(closest_token)==0){return 'EAT'}
    else{
    if(closest_token[0] >= closest_token[1]) {if(closest_token[0]<0) {return 'LEFT'} {return 'RIGHT'}}
    else{if(closest_token[1]<0) {return 'UP'} {return 'DOWN'}}
    }

}

}

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


text:
Generate a looping array
Introduction
A pointer array is an array L of nonzero integers where 0 ≤ L[i]+i < len(L) holds for all indices i (assuming 0-based indexing).
We say that the index i points to the index L[i]+i.
A pointer array is a loop if the indices form a single cycle of length len(L).
Here are some examples:

[1,2,-1,3] is not a pointer array, because the 3 does not point to an index.
[1,2,-1,-3] is a pointer array, but not a loop, because no index points to the -1.
[2,2,-2,-2] is a pointer array, but not a loop, because the indices form two cycles.
[2,2,-1,-3] is a loop.

Input
Your input is a non-empty list of nonzero integers, in any reasonable format.
It may be unsorted and/or contain duplicates.
Output
Your output shall be a loop that contains all the integers in the input list (and possibly other integers too), counting multiplicities.
They need not occur in the same order as in the input, and the output need not be minimal in any sense.
Example
For the input [2,-4,2], an acceptable output would be [2,2,-1,1,-4].
Rules and scoring
You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
Including a couple of example inputs and outputs in your answer is appreciated.
Test cases
These are given in the format input -> some possible output(s).
[1] -> [1,-1] or [1,1,1,-3]
[2] -> [2,-1,-1] or [1,2,-2,-1]
[-2] -> [1,1,-2] or [3,1,2,-2,-4]
[2,-2] -> [2,-1,1,-2] or [2,-1,2,-2,-1]
[2,2,2] -> [2,-1,2,-2,2,-2,-1] or [2,2,2,2,-3,-5]
[2,-4,2] -> [2,2,-1,1,-4] or [2,5,1,1,1,-4,2,-7,-1]
[3,-1,2,-2,-1,-5] -> [2,3,-1,2,-1,-5] or [3,3,-1,-1,2,2,-1,6,1,1,1,1,-12,-5]
[-2,-2,10,-2,-2,-2] -> [10,-1,1,-2,-2,1,-2,-2,1,-2,-2]
[-15,15,-15] -> [15,-1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,-15,-15]
[1,2,3,4,5] -> [1,2,3,-1,4,-1,5,-1,-1,-9,-1,-1]

Jelly, 12 bytes
ż~Ṣ€FxA$;L$U

Try it online!
Background
Consider the pair of integers n, ~n, where n ≥ 0 and ~ denotes bitwise NOT, i.e., ~n = -(n + 1).
By placing n copies of n to the left of n + 1 copies of ~n, if we start traversing the pointer array from the rightmost ~n, we'll traverse all 2n + 1 elements and find ourselves at the left of the leftmost n.
For example, if n = 4:
X  4  4  4  4  -5 -5 -5 -5 -5
                            ^
            ^
                         ^
         ^
                      ^
      ^
                   ^
   ^
                ^
^

For the special case n = 0, the element n itself is repeated 0 times, leaving this:
X -1
   ^
^

For each integer k in the input, we can form a pair n, ~n that contains k by setting n = k if k > 0 and n = ~k if k < 0. This works because ~ is an involution, i.e., ~~k = k.
All that's left to do is chain the generated tuples and prepend their combined lengths, so the leftmost element takes us back to the rightmost one.
Examples
[1] -> [3, 1, -2, -2]
[2] -> [5, 2, 2, -3, -3, -3]
[-2] -> [3, 1, -2, -2]
[2, -2] -> [8, 1, -2, -2, 2, 2, -3, -3, -3]
[2, 2, 2] -> [15, 2, 2, -3, -3, -3, 2, 2, -3, -3, -3, 2, 2, -3, -3, -3]
[2, -4, 2] -> [17, 2, 2, -3, -3, -3, 3, 3, 3, -4, -4, -4, -4, 2, 2, -3, -3, -3]
[3, -1, 2, -2, -1, -5] -> [26, 4, 4, 4, 4, -5, -5, -5, -5, -5, -1, 1, -2, -2, 2, 2, -3, -3, -3, -1, 3, 3, 3, -4, -4, -4, -4]
[-2, -2, 10, -2, -2, -2] -> [36, 1, -2, -2, 1, -2, -2, 1, -2, -2, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, 1, -2, -2, 1, -2, -2]
[-15, 15, -15] -> [89, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15, -15]
[1, 2, 3, 4, 5] -> [35, 5, 5, 5, 5, 5, -6, -6, -6, -6, -6, -6, 4, 4, 4, 4, -5, -5, -5, -5, -5, 3, 3, 3, -4, -4, -4, -4, 2, 2, -3, -3, -3, 1, -2, -2]

How it works
ż~Ṣ€FxA$;L$U  Main link. Argument: A (list of integers)

 ~            Yield the bitwise not of each k in A.
ż             Zipwith; pair each k in A with ~k.
  Ṣ€          Sort each pair, yielding [~n, n] with n ≥ 0.
    F         Flatten the list of pairs.
       $      Combine the previous two links into a monadic chain:
      A         Yield the absolute values of all integers in the list.
                |n| = n and |~n| = |-(n + 1)| = n + 1
     x          Repeat each integer m a total of |m| times.
          $   Combine the previous two links into a monadic chain:
         L      Yield the length of the generated list.
        ;       Append the length to the list.
           U  Upend; reverse the generated list.

You don't need to handle the special case n = 0, because the spec says "nonzero integers".

While 0 will never occur in the input, I still need the pair 0, -1 if -1 does.


text:
Fill the grid from 1 to 100
In this challenge you are supposed to fill a grid 10x10 with numbers from 1 to 100 (each number once) following this rules:

Number 1 must be on the bottom row
Number 100 must be on the upper row
Two consecutive numbers must be one next to the other (diagonals doesn't count)
The grid must be random

It's not necessary at all that all possible outcomes are equiprobable. Still, though, there must be a non-zero chance for every possible grid (that satisfies the first 3 conditions) to occur.
I don't want time to be a problem, but to avoid pure brute force, answers should take less than a minute to run.
Since output shouldn't be the main focus of the challenge I give complete freedom on how to write it, as long as each row in the output corresponds to a row in the grid and numbers are separated by a character (of any kind).

By "random", do you mean that every grid that satisfies the first 3 conditions has a non-zero chance of being produced? Also, can solutions keep producing random grids until they find one that fits the criteria, or is there a time bound?

How should output be presented? Does if have to be a string that gives the grid appearance, or can it be a 2x2 array as a functon return value, for example? If the former, 0 (or 00) to 99 would look neater. That one 3-digit number is a pain aesthetically

Less than a minute to run on what?

As it, this allows the cheap solution of generating a random grid, outputting it if it satisfies the properties, and otherwise outputting a fixed grid that works.

What if it takes less than a minute for most cases, but longer for some?

Albert, do you have a working solution?

What would you consider as brute-force here? Why do you think this can be solved (under all the given conditions) in less than one minute?

@flawr I think one minute is rather short, but í have an algorithm that might work in that time based on building a maze starting at the corners (requires some development though. ) Xnor's point is valid but I think what he mentions would be "I know it when I see it" kind of cheating. I'm not sure these are reasons enough to close the question.

I'd suggest taking this challenge to the Sandbox so it can get more feedback before you post it.

@LevelRiverSt It's not cheating at all when it satisfies the rules of the question. I shouldn't have to judge the asker's intent to decide whether a solution method is fair.


text:
Create a Boolean parser
What you need to do is create a Boolean parser.

Boolean expressions, in case you haven't heard of them yet, have two inputs and one output. There are four 'gates' in boolean arithmetic, namely OR (represented by |), AND (represented by &), NOT (which are used a bit like brackets : / and \ note, I could have used !, but you can't use them as brackets, since !!!! is ambiguous (//\\ or /\/\)) and XOR (represented by ^). These gates operate on their inputs which are either true or false. We can list the possible inputs (A and B in this case) and the outputs (O) using a truth table as follows:
XOR
A|B|O
-----
0|0|0
0|1|1
1|0|1
1|1|0

OR
A|B|O
-----
0|0|0
0|1|1
1|0|1
1|1|1

AND
A|B|O
-----
0|0|0
0|1|0
1|0|0
1|1|1

NOT is only 1 input, and it goes from true to false and vice versa.
In Boolean expressions, they are used like this:
1^((0&1&1)&/(1&0&1)\)

Evaluating as follows:
1^(( 1 |1)&/(1&0&1)\)  |  0 OR 1 = 1, order of operations left to right - no brackets
1^(( 1   )&/(1&0&1)\)  |  1 OR 1 = 1
1^(  1    &/(1&0&1)\)  |  Remove brackets
1^(  1    &/( 0 &1)\)  |  1 AND 0 = 0
1^(  1    &/( 0   )\)  |  0 AND 1 = 0
1^(  1    &/  0    \)  |  Remove brackets
1^(  1    &   1     )  |  NOT 0 = 1
1^(  1              )  |  1 AND 1 = 1
1^   1                 |  Remove brackets
0                      |  1 XOR 1 = 0

so 0 is the result.
Task: create a program to do this!*
I/O examples
Input -> Output
1v(0.1) -> 1
1v(0.1./1\) -> 1
/0\v(0+1) -> 0
0v1v1 -> 0

Notes

There is no order of precedence. We will treat 0.1v0+1 as (((0.1)v0)+1)

Leaderboard

var QUESTION_ID=77254,OVERRIDE_USER=42854;function answersUrl(e){return"http://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"http://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

Why use non-ascii? This makes it so its hard for non-esolangs to compete.

Sorry, **esolangs

Try the sandbox !

Is this looking better now?

You should format the test cases better, at the moments it is impossible to copy & paste them all at once. Read here for some more details on this.

@DigitalTrauma Nope, there's no whitespace.

You also use v, but that shoudn't be XOR, since that symbol is OR in logic.

@mbomb007 What would you recommend?

Use common Boolean representations for operators like the words for And Or Xor Not or use & | ^ !.

It's not clear to me what the cutoff is for "builtins that trivialise the problem". General-purpose eval could be made to work by first applying some simple substitutions: should that count? The examples also include elements which aren't mentioned in the spec.

I am deleting the question and moving it to the sandbox. Is this okay?

GNU Sed 4.2.2, 102
Score includes +1 for -r option to sed:
y/+./oa/
:
s%/0\\%1%
s%/1\\|\b(0o0|(\w)v\2)%0%
s%\b(\wo\w|\wv\w|1a1)%1%
s/\b\wa\w/0/
s/\((\w)\)/\1/
t

Ideone.

Incomplete Retina port.