text:
Golf a Purple Interpreter
Golf a Purple Interpreter
Purple is an esolang which is designed with two main purposes:

To be a minimization of Aubergine, since there just aren't enough self-modifying one-instruction languages around.
To admit the possibility of terrifyingly small golfed interpreters. My first pass at a reasonably full-featured Python 2 interpreter is only 702 bytes, and I'm sure a more experienced golfer could shave quite a bit from that.

Your goal is to write an interpreter for this language.
Information on Purple:
A Purple program is a sequence of characters placed into an infinite, addressable memory array such that the first character of the program is placed at address zero. The rest of the array (both before and after where the Purple program is stored) is initialized to zero.
There are three registers in Purple, called a and b and i, each of which can hold a signed integer and is initialized to zero. i is also the instruction pointer, and always points to the currently executing Purple instruction.
Each cycle, the interpreter will read a sequence of three contiguous characters beginning from the memory location indicated by the instruction pointer and attempt to execute this sequence as the Purple instruction. Afterwards, the instruction pointer is always incremented by 3.
Syntactically, the Purple instruction consists of three characters (or encodings thereof) in a row, like "xyz".
The first character x can be any of the following:
abABio

These symbols have the following meaning:
a - Place the result in register a.
b - Place the result in register b.
A - Place the result in the location in memory referred to by register a.
B - Place the result in the location in memory referred to by register b.
i - Set the instruction pointer to the result.
o - Output the result to stdout.

The other two bytes y and z can be any of the following:
abABio1

Each of these symbols has the following meaning:
a - Return the contents of register a.
b - Return the contents of register b.
A - Return the contents of the memory array at the address stored in register a.
B - Return the contents of the memory array at the address stored in register b.
i - Return the contents of register i (the instruction pointer).
o - Return the value of a single character read from stdin.
1 - Return the literal numeric value 1.

After fetching the instruction, the Purple interpreter will evaluate y and then z, subtract the result of z from the result of y, and then perform the action indicated by x on the difference.
If the sequence of three characters (or encodings thereof) is not a valid Purple instruction, the interpreter halts immediately without giving any errors.
Your interpreter must:

Be a complete program, not a function.
Never output to stderr, unless EOF is read.
Behave identically to the reference implementation on all well-formed inputs that do not involve very large numbers, including the test programs given below. (Well, identically up to timing--it can run slower, but not by too much!)

You may provide the program to the interpreter in any form you wish: read it from a file, embed it in the program as a string, or read it from stdin.
Test cases:
The program
ooo

when run with input
z!

should yield
Y

The program
bbboobiii

when run with input
It's a cat program.

(or any other input) should yield
It's a cat program.

(or whatever input it received) and then start over and do the same thing again.

The program
Aoab11bi1bABoAaiba

when run with input
0

should yield
0

and then halt, but when run with input
1

should continue outputting
1

forever.

The program
b1bbb1oAbabaa1ab1Ab1Bi1b

should yield
b1bbb1oAbabaa1ab1Ab1Bi1b

The program
aA1aa1bb1oAbbi1bb1bbAb1Bi1b Purple is the awesomest! Why haven't you tried it yet?
!dlroW ,olleG

should yield
Hello, World!

Scoring:
This is code-golf, so shortest source in bytes, as potentially modified by the following bonus, wins.
Bonus:

-10% if your interpreter reads a filename from either stdin or from a command line argument and loads the program from the file.

What is the size of the memory cells? bytes, characters (unicode ones?), (arbitrary) large integers? It looks like you are using "character" and "byte" with the same meaning.

@PaŭloEbermann my guess is that's implementation-specific; for example I need to use uint32 for characters and MAXINT for ints

What should be the value of o when the input is closed (i.e. EOF)? And what would be read after that?

@PaŭloEbermann do whatever the reference implementation does in this situation. (I'm fairly certain it gives 0 on EOF.)

@quintopia actually, your cat program demonstrates that the reference implementation throws an exception in this case (TypeError: ord() expected a character, but string of length 0 found), at least here (Python 2.7.6 on Ubuntu 14.04) – read(1) from a file at EOF gives an empty string, and ord on that is not defined. I guess finishing the program without an exception would work too, as we are not allowed to print to stderr?

@PaŭloEbermann Handle it any way you wish then. I'll allow writing to STDERR when reading EOF.

I put quite a few hours and quite a bit of hope into doing this in Go, only to realise the tape needs to be actually negatively addressable. Welp, there goes that project.

@sysreq Is that really a blocker? Your implementation could simply have two tapes, one for negative and one for positive indices. (Yes, this will take a bit more code, but not that much, I think.)

Having to figure out which of two tapes to assign to and such seems rather long, but I'll try it.
Suppose I write an interpreter/runtime that can read from a file: if I make the runtime basically allow Purple to bootstrap and interpret itself (unless someone would like to provide a kernel that ships with Purple instructions builtin), does that actually count as Purple interpreting Purple?

because there needs to be some sort of chicken-and-egg-bootstrap-resolver, but if that's not written in Purple then does it qualify?

@sysreq basically, a Purple self-interpreter would be a program that reads a Purple program from stdin and then does whatever that program would do. The first Purple program (the interpreter) can run in whatever interpreter you like. A program that completely overwrites the lowest memory addresses with the input, then deletes itself before somehow jumping to the read code would qualify (though I don't think this is actually possible).

I came so close to having a runtime capable of self-interpretation, but I was too late.

Post it anyway if you get it. I'll throw a love your way.

Pyth, 148 128 121 bytes (or 124 * .9 = 111.6, see bottom)
J,00=kjb.z .eXHkCbz#=b-Fm?=zx"oabABi1"C@H+Zd@s[0Jm.x@Hk0JZ1H)zCh~tkS2 ?hKx"abAB"=YC@HZ?PKXH@JKbXJKb?qY\i=Zb?qY\opCbvN=+Z3

Test suite
Code given on first line of STDIN, input to the Purple program on the rest of STDIN. To use code with newlines, use alternate version at the bottom.
Reasonably golfed. Here's it with linebreaks and indentation for clarity:
J,00
=kjb.z
 .eXHkCbz
#
  =b-Fm
    ?=zx"oabABi1"C@H+Zd
      @
        s[0Jm.x@Hk0JZ1H)
        z
      Ch~tk
    S2
   ?hKx"abAB"=YC@HZ
    ?PK
      XH@JKb
      XJKb
  ?qY\i=Zb
  ?qY\opCb
  vN
  =+Z3

Basically, a # loop does the execution and halting via error-break.
a and b are combined into a single variable, J. Z is the instruction pointer. k is input to the Purple program. H is the tape, represented as a dictionary. b is the current result. Y is the current
first byte of the instruction.
Reading from file:
J,00=kjb.z .eXHkCbjb'z#=b-Fm?q\o=zC@H+ZdCh~tk@s[Jm.x@Hk0JZ1H)x"abABi1"zS2 ?hKx"abAB"=YC@HZ?PKXH@JKbXJKb?qY\i=Zb?qY\opCbvN=+Z3

Give file name as first line of STDIN. Test run:
$ cat purple-final.pyth
J,00=kjb.z .eXHkCbjb'z#=b-Fm?=zx"oabABi1"C@H+Zd@s[0Jm.x@Hk0JZ1H)zCh~tkS2 ?hKx"abAB"=YC@HZ?PKXH@JKbXJKb?qY\i=Zb?qY\opCbvN=+Z3
$ cat purple-code.txt
aA1aa1bb1oAbbi1bb1bbAb1Bi1b Purple is the awesomest! Why haven't you tried it yet?
!dlroW ,olleG
$ pyth purple-final.pyth <<< 'purple-code.txt'
Hello, World!

JavaScript (ES6), 292 bytes
eval(`a=b=i=d=0;v=n=>(x=m[i+n])==97?a_98?b_65?m[a]_66?m[b]_105?i_111?p()[c]()_49?1:d=1;for(m=[...(p=prompt)()].map(b=>b[c="charCodeAt"]());!d;i+=3)(y=v(1),d)||(z=v(2),d)?1:(x=m[r=y-z,i])==97?a=r_98?b=r_65?m[a]=r_66?m[b]=r_105?i=r-3_111?alert(String.fromCharCode(r)):d=1`.replace(/_/g,":x=="))

Explanation
JavaScript answers are always weird when STDIN and STDOUT are required...
The first prompt is the input for the program string. Each prompt that results from an o instruction will read only the first character.
eval is used to replace a common phrase which saves a few bytes. Ungolfed and without the eval the program looks like this:
// Initialisation
a=b=i=                            // initialise registers to 0
  d=0;                            // d is set to true when the program should die

// Gets the result of Y or Z
v=n=>                             // n = offset from i
  (x=m[i+n])==97?a:               // x = value of instruction
  x==98?b:
  x==65?m[a]:
  x==66?m[b]:
  x==105?i:
  x==111?p()[c]():
  x==49?1:
  d=1;                            // if it was none of the valid values, die

// Execution loop
for(
  m=                              // m = memory array
    [...(p=prompt)()]             // receive the program
    .map(b=>b[c="charCodeAt"]()); // initialise m to the ASCII values of the program
  !d;                             // finish if an error occured
  i+=3                            // increment i
)
  (y=v(1),d)||                    // get the value of Y and check for errors
  (z=v(2),d)?1:                   // get the value of Z and check for errors

    // Get the result of X
    (x=m[r=y-z,i])==97?a=r:       // r = result of y - z
    x==98?b=r:
    x==65?m[a]=r:
    x==66?m[b]=r:
    x==105?i=r-3:
    x==111?alert(String.fromCharCode(r)):
    d=1

Can the second c="charCodeAt" be replaced with just c?

Does array access with negative indices work in JavaScript?

@Dendrobium Wow, I don't know how I missed that haha! Thanks.

@nimi It works. Arrays themselves don't support negative indices, but this takes advantage of the fact that they also behave as objects. array[-1] = 1 is the same as array = { "-1": 1 }. Both can be accessed with array[-1].

@user81655: Ah nice, didn't know that.

Ceylon, 827 792 671 bytes
import ceylon.language{l=variable,I=Integer,x=nothing,p=process,m=map}shared void run(){try{if(exists d=p.arguments[0]){l value t=m{*d*.hash.indexed};l I a=0;l I b=0;l I i=0;I g(I j)=>t[j]else 0;l{I*}c=[];I o{if(c==[]){if(exists e=p.readLine()){c=e*.hash.chain{10};}else{c={-1}.cycled;}}assert(is I r=c.first);c=c.rest;return r;}value f=m{97->{a},98->{b},65->{g(a)},66->{g(b)},105->{i},111->{o},49->{1}};value s=m{97->((I v)=>a=v),98->((I v)=>b=v),65->((I v)=>t=m{a->v,*t}),66->((I v)=>t=m{b->v,*t}),105->((I v)=>i=v),111->((I v)=>p.write("``v.character``"))};I h(I v)=>f[v]?.first else x;while(0<1){(s[g(i)]else x)(h(g(i+1))-h(g(i+2)));i+=3;}}}catch(AssertionError e){}}

It behaves a bit differently than the reference implementation when the program tries to read input at EOF – the reference implementation crashes with a TypeError, which is too costly to reproduce here (and also likely a bug), so this will return -1 instead (repeatedly, if necessary).
(When trying to write this -1 to stdout, the interpreter will finish with an OverflowError, though. Similar will happen if an Integer outside of the Unicode range is output.)
The interpreter takes the program as its first command line argument (make sure to quote it for your shell when it contains whitespace or other interesting stuff).
In Ceylon we can only easily read input line-wise (I guess this will change in one of the next versions), so when o is used for reading, I'm reading a whole line and buffer the parts for future uses. I guess it works similar in the Python implementation when connected to a terminal.

When trying to execute a command (part) which is not one of the valid characters, the nothing will cause an AssertionError to be thrown, which we then catch in the catch block around the main loop.
I think this should be preferably be a custom Exception type (as AssertionError could also occur at other places if I have a bug), but that would take much more space, eating most improvements I made from the first version.
Some tricks used for golfing:

The previous versions used a ceylon.collection.HashMap – instead we now use an immutable map as created by the map function, and create a new one each time A or B is used as x.
I use alias-imports for all identifiers from ceylon.language which are used more than once (including the variable annotation, which is now l).
I got rid of the class E (for environment) and the s (step) method – everything now happens inside the run function.
Instead of using .integer for getting the codepoint of a character, .hash gives the same result. Thus string*.hash is the same as string.map(Character.integer) (gives an iterable of the codepoints from a string).
When a type is alias-imported, is I ... is shorter than exists ....
When converting something (e.g. x) into a string, "``t``" is shorter than t.string (or, what I used for a character, String{t}).
functions used just once can often be inlined.

Here is the formatted (and commented) version:
// Purple – a self-modifying, "one-instruction" language.
//
// Question:  http://codegolf.stackexchange.com/q/65411/2338
// My answer: http://codegolf.stackexchange.com/a/65492/2338

import ceylon.language {
    l=variable,
    I=Integer,
    x=nothing,
    p=process,
    m=map
}

shared void run() {
    try {
        // Reading code from file certainly takes more than 73 characters,
        // this isn't worth the 10% bonus.
        if (exists d = p.arguments[0]) {

            // The memory tape, as a Map<Integer, Integer>.
            // We can't modify the map itself, but we
            // can replace it by a new map when update is needed.
            l value t = m {
                // It is initialized with the code converted to Integers.
                // We use `.hash` instead of `.integer` because it is shorter.
                *d*.hash.indexed };

            // three registers
            l I a = 0;
            l I b = 0;
            l I i = 0;

            // get value from memory
            I g(I j) =>
                    t[j] else 0;

            // cached input which is still to be read
            l {I*} c = [];

            // get value from stdin.
            // we can only comfortably access stdin by line, so we read a whole line
            // and cache the rest for later.
            I o {
                if (c == []) {
                    if (exists e = p.readLine()) {
                        c = e*.hash.chain { 10 }; // convert string into ints, append \n
                    } else {
                        // EOF – return just -1 from now on.
                        c = { -1 }.cycled;
                    }
                }
                assert (is I r = c.first);
                c = c.rest;
                return r;
            }

            // Map of "functions" for fetching values.
            // We wrap the values in iterable constructors for lazy evaluation
            //  – this is shorter than using (() => ...).
            // The keys are the (Unicode/ASCII) code points of the mapped
            // source code characters.
            value f = m {
                // a
                97 -> { a },
                // b
                98 -> { b },
                // A
                65 -> { g(a) },
                // B
                66 -> { g(b) },
                // i
                105 -> { i },
                // o
                111 -> { o },
                // 1
                49 -> { 1 }
            };

            // Map of functions for "storing" results.
            // The values are void functions taking an Integer,
            // the keys are the ASCII/Unicode code points of the corresponding
            // source code characters.
            value s = m {
                // a
                97 -> ((I v) => a = v),
                // b
                98 -> ((I v) => b = v),
                // Modification of the memory works by replacing the map with a new one.
                // This is certainly not runtime-efficient, but shorter than importing
                // ceylon.collections.HashMap.
                // A
                65 -> ((I v) => t = m { a->v, *t }),
                // B
                66 -> ((I v) => t = m { b->v, *t }),
                // i
                105 -> ((I v) => i = v),
                // o – output as a character.
                111 -> ((I v) => p.write("``v.character``"))
            };

            // accessor function for the f map
            I h(I v) =>
                    f[v]?.first else x;

            // the main loop, can only be left by exception
            while (0 < 1) {
                (s[g(i)] else x)(h(g(i + 1)) - h(g(i + 2)));
                i += 3;
            }
        }
    } catch (AssertionError e) {
        // abort silently
    }
}

I reused part of that code for a "parallel interpreter" trying to find all halting programs. (There are many of them.) (There I used a non-I/O version of Purple, as I/O takes lot of space and is not used in that task.)


text:
Emoji Vending Machine
Can't see emoji? Click here.
You will simulate a vending machine. The items are 56 different emojis, which can be represented as two surrogate UTF-8 characters, from: (U+D83C U+DF45) to
(U+D83C U+DF7C). In HTML these emojis can be represented in UTF-16 form as &#x1F345 through &#x1F37C. In base 10 the first UTF-8 character has value 55356. The value of the second character ranges from 57157 to 57212. Here is a CJam program that generates all the relevant emojis. To avoid confusion, this challenge will be scored in characters, not bytes. Some emojis are 2 characters, some are 3. http://www.lettercount.com will give you an accurate count for this challenge.
Pricing
There are 8 different price categories:

$1.00 :
$1.50 :
$2.00 :
$2.50 :
$3.00 :
$3.50 :
$4.00 :
$4.50 :

Displaying the Vending Machine
This is what the user sees when the program starts and after making a purchase. You can use regular numbers instead of emoji numbers, but emoji numbers have the benefit of being the same width as other emojis. If you use emoji numbers you can subtract 14 characters from your score, because emoji numbers are 3 characters each.
  1⃣2⃣3⃣4⃣5⃣6⃣7⃣
A
B
C
D
E
F
G
H

If the user enters G5 that selects . Entering E6 selects .
Adding Cash
To add money, the user should input / and then the code for a coin or bill. The coins are (N)ickel ($0.05), (D)ime ($0.10), and (Q)uarter ($0.25). The bills are (O)ne ($1.00), (F)ive ($5.00), (T)en ($10.00). Every time the user adds a bill or coin, the program should output Balance: [New Balance]. Only one bill or coin can be added each time.Here is an example containing three lines of input:
/D
Balance: $0.10
/Q
Balance: $0.35
/F
Balance: $5.35

Selecting Items
The user selects an item by entering the item code, like B2 or C3. If the user has not added any money, the program should output Item Cost: [Cost of Item]. If the user has added money, but it is not enough to buy the item, the output should be Insufficient Funds. Item Cost: [Cost of Item]. If the user did add enough money, the program should output: Item at [Item Location] Purchased. Remaining Balance: [Balance - Cost of Item]. Then on its own line, print out the emoji of the purchased item. Then print out the entire vending machine (See "Displaying the Vending Machine") with the purchased item replaced with (U+D83D U+DEAB) Base 10: (55357 57003).
Ending the Program
If the user buys an item which brings his/her balance down to $0.00, the program should automatically terminate. Alternatively, if the user enters "Done" at any time, the program must give the user his/her remaining balance in change. Change must be in only Nickels, Dimes, and Quarters, and must be the smallest amount of coins possible. For example if the remaining balance is $1.45, the output should be QQQQQDD.
Sample Run
(Input starts with "-")
  1⃣2⃣3⃣4⃣5⃣6⃣7⃣
A
B
C
D
E
F
G
H
-E1
Item Cost: $3.00
-/F
Balance: $5.00
-E1
Item at E1 Purchased. Remaining Balance: $2.00

  1⃣2⃣3⃣4⃣5⃣6⃣7⃣
A
B
C
D
E
F
G
H
-Done
QQQQQQQQ

Invalid Codes

If the input starts with / but is not a valid money input, output
Money not Accepted.
If the input is an item that has already been purchased, output Item out of stock
If the input is a digit-letter combination that is not in range (like A0 or J2, output "Invalid code"
For all other invalid input, output "Error"

Bonus (-15%) : Jam
When vending an item, there is a 10% chance the machine will jam, and the item gets stuck. Output JAM!!! one time. In this case the user must input "punch" or "kick". Each time the user does so, there is a 20% chance that the item will break free, and vend as normal. Until the jam clears, the only inputs recognized are "punch" and "kick". All other inputs do nothing.
Here is a sample:
-A4
Item at A4 purchased. Remaining Balance: $1.00
JAM!!!
-punch
-kick
-kick
-punch
-punch

(The jam has been cleared. Resume as normal.)
Bonus (-10%) : ID
If the user tries to buy an alcoholic beverage (any item on the last row except the baby bottle), you must demand proof of age. To do so, you ask the user to multiply two random numbers between 13 and 19 (inclusive). Output ID required: [13-19]x[13-19] = ?. If the user answers correctly, the purchase can go through. If not, print (U+D83D U+DD1E) base 10: (55357 56606)
Alternative Challenge : Minecraft
This challenge seems like something possible in Minecraft. To successfully create a Minecraft version of this program, the player must

Have an 8x7 grid to select from 56 unique items
Be able to add money to the balance (Maybe use different types of stones for the different denominations described above.)
Give the user the item he/she selects if they have put in enough "money"
Return the user the appropriate amount of change at the end.

Compatibility Mode

I can only take input at the beginning of the program

Not to worry, you can make a program that takes all input up front. If your program has not terminated after evaluating all input, assume that "Done" is called at the end. If you do this method, you will not be eligible for any bonuses.

I can't view/output emojis

You can copy and paste your input and output into this Stack Snippet (or here). It can understand both unicode emojis and HTML codes for emojis. If your output looks correct on this page, your program passes. Try pasting in some of the sample input/output to see how it looks.

function parse() {
var o = document.getElementById("output");
var text = document.getElementById("in").value;
o.innerHTML = text.replace(/\n/g,"
").replace(/ /g,"&nbsp");
twemoji.parse(o);
}

Emoji to Image

<textarea id="in" rows="10" cols="50"></textarea>
<input type="submit" onclick="parse()">

Here is an abbreviated compatibility-mode version of the vending machine display that you can test in the Stack Snippet:
   &#x31&#x20E3&#x32&#x20E3&#x33&#x20E3&#x34&#x20E3&#x35&#x20E3...
A&#x1F345&#x1F346&#x1F347&#x1F348&#x1F349...
B
...

I can output emojis, but not to STDOUT.

Seemingly, the Mac OS X Terminal is the only one known to be able to output emojis. If you are not able to output emojis in your terminal, your other options are

Send all output to a file.
Display all output in a window.
Use the technique described in "I can't view/output emojis".

$ can be replaced with your local currency doesn't make much sense if you then require that the coins be (N)ickels (D)imes and (Q)uarters. I suggest you remove it as it adds confusion.

@steveverrill Good point. I've changed it. My question is, do non-U.S. keyboards have a $ button, or is there a code for it?

the $ symbol is part of the ASCII character set, so it's safe to assume pretty much all keyboards and languages can handle it. It is the only currency symbol in the 7-bit ASCII character set. As a result, other symbols such as the GBP symbol or the EUR symbol € can be incorrectly rendered due to incompatible string encodings, but it virtually never happens with $.

@steveverrill I know they can handle it, but is there a physical keyboard button for it?

My British and Spanish keyboards have it in addition to the relevant local currency symbols, and I think the others do too. Besides being the most widely used currency symbol in the world (including for many currencies that are not called dollars), the $ symbol has special meaning in most programming languages, so not having it available on the keyboard would be a serious limitation. I'm typing this on my Spanish keyboard and it's actually easier to get $ (shift + 4) than € (alt gr + E) so you can see that the latter symbol  added as an afterthought.

@geokavel I would hope that all keyboards have the $ button since a lot of programming languages use it.

PHP, (1295 - 14) - 25% = 960.75 characters
Old scores 1315 1351 1361 1295 989 977
That was fun, and it's the first answer – yeah.
$i=[A=>[,,,,,,],B=>[,,,,,,],C=>[,,,,,,],D=>[,,,,,,],E=>[,,,,,,],F=>[,,,,,,],G=>[,,,,,,],H=>[,,,,,,]];$p=[A=>1,B=>1.5,C=>2,D=>2.5,E=>3,F=>3.5,G=>4,H=>4.5];$v=[N=>.05,D=>0.1,Q=>.25,O=>1,F=>5,T=>10];a:$m='';$w=$x=0;$q=$c[0];$r=$c[1];$f=fgets;$n=rand;$u=number_format;if('Done'==$c&&$e=1)foreach([Q,D,N]as$_)while($b&&round($b-$v[$_],2)>=0&&$m.=$_)$b-=$v[$_];elseif('/'==$q){$v[$r]?$b+=$v[$r]:$m="Money not accepted
";$m.="Balance: $".$u($b,2);}elseif(in_array($q,range(A,Z))){if(0<$r&&8>$r--&&($_=$p[$q])){$b&&$b<$_?$m="Insufficient funds. ":0;if($b<$_)$m.="Item cost: $".$u($_,2);elseif(==$i[$q][$r])$m="Item out of stock.";else{$t=0;if(H==$q&&$r<6){$t=$n(13,19);$s=$n(13,19);echo"ID required: {$t}x$s = ?
";if($f(STDIN)!=$t*$s)$m=;else$t=0;}if(!$t){$b-=$_;if(1>$n(0,9)){$w=1;}$x=$i[$q][$r];$m="Item at $c purchased. Remaining balance: $".$u($b,2).($w?"":"
$x");$i[$q][$r]=;if(!$b)$e=1;}}}else$m="Invalid code";}if($c&&!$m&&!$e)$m=Error;system(clear);echo"  1⃣ 2⃣ 3⃣ 4⃣ 5⃣ 6⃣ 7⃣";foreach($i as$k=>$_){echo"
$k ";foreach($_ as$_)echo"$_ ";}echo"
$m
";if($w){echo"JAM!!!
";for(;$c!=kick&&$c!=punch||7>$n(0,9);$c=trim($f(STDIN)));echo"$x
";}$e?exit:$c=trim($f(STDIN));goto a;

As vending machines remind me of the 90s I used goto and for purchased items the Space Invader  is shown. The machine is redrawn after every command.
Ungolfed (somehow)
$i=[A=>[,,,,,,],B=>[,,,,,,],C=>[,,,,,,],D=>[,,,,,,],E=>[,,,,,,],F=>[,,,,,,],G=>[,,,,,,],H=>[,,,,,,]];
$p=[A=>1,B=>1.5,C=>2,D=>2.5,E=>3,F=>3.5,G=>4,H=>4.5];
$v=[N=>.05,D=>0.1,Q=>.25,O=>1,F=>5,T=>10];

a:
$m='';
$w=$x=0;
$q=$c[0];
$r=$c[1];
$f=fgets;
$n=rand;
$u=number_format;

if('Done'==$c&&$e=1)
    foreach([Q,D,N]as$_)
        while($b&&round($b-$v[$_],2)>=0&&$m.=$_)
            $b-=$v[$_];
elseif('/'==$q){
    $v[$r]?$b+=$v[$r]:$m="Money not accepted
";
    $m.="Balance: $".$u($b,2);
}elseif(in_array($q,range(A,Z))){
    if(0<$r&&8>$r--&&($_=$p[$q])){
        $b&&$b<$_?$m="Insufficient funds. ":0;
        if($b<$_)$m.="Item cost: $".$u($_,2);
            elseif(==$i[$q][$r])
                $m="Item out of stock.";
            else{
                $t=0;
                if(H==$q&&$r<6){
                    $t=$n(13,19);
                    $s=$n(13,19);
                    echo"ID required: {$t}x$s = ?
";
                    if($f(STDIN)!=$t*$s)
                        $m=;
                    else
                        $t=0;
                }
                if(!$t){
                    $b-=$_;
                    if(1>$n(0,9)){
                        $w=1;
                    }
                    $x=$i[$q][$r];
                    $m="Item at $c purchased. Remaining balance: $".$u($b,2).($w?"":"
$x");
                    $i[$q][$r]=;
                    if(!$b)$e=1;
                }
            }
    }else
        $m="Invalid code";
}

if($c&&!$m&&!$e)$m=Error;

system(clear);
echo"  1⃣ 2⃣ 3⃣ 4⃣ 5⃣ 6⃣ 7⃣";
foreach($i as$k=>$_){
    echo"
$k ";
    foreach($_ as$_)
        echo"$_ ";
}
echo"
$m
";

if($w){
    echo"JAM!!!
";
    for(;$c!=kick&&$c!=punch||7>$n(0,9);$c=trim($f(STDIN)));
    echo"$x
";
}

$e?exit:$c=trim($f(STDIN));
goto a;

 Tested on OS X with PHP 5.5 and 5.6

Edits

Added 12 bytes. Fixed exit on Done and golfed some strings.
Added 306  bytes. Fixed one or two bugs and added support for the bonuses. With the bonuses it's now nearly 15 bytes shorter.
Added 66 bytes. Had to format the money differently, also had to accept more values ([A-Z][0-9]) for Invalid code.
Saved 10 bytes. Found one whitespace and turned some .= into = were applicable.
Saved 36 bytes due to some refactoring.
Saved 20 bytes by refactoring some loops and assignments.

Wow, that was very fun to play! The only issue I noticed: You need to format prices like 3 and 3.5 into $3.00 and $3.50.

Also, when I type in J5 I should get the message : "Invalid code".

@geokavel Thanks for your feedback. I've added the correct money format and it also accepts more variants for Invalid code now. It's a fun challenge - even though it has lots of options … 1K characters speak for themselves … :)

Congratulations, by a narrow margin, you are the winner! Thank you to both players for being worthy competitors, and fervently trying to out-golf each other!

@geokavel It was a fun challenge and a nice ping pong between Stephan and me. If somebody will come up with a shorter solution in the future, I'll be there. ;)

C# 6 (.Net Framework 4.6), 1356 1324 1304 1311 1307 1238 1235 1231 1220 Letters - 14 Letters (Emoji Numbers) - (15% Jam Bonus + 10% ID Bonus) = 1017 993 978 972.75 969.75 918 915.75 904.5 Letters
using h=System.Console;class c{static void Main(){double b=0,z,p,x=0,i=57157,j,n,r,c,m;var a=1==0;var d=new System.Collections.Hashtable();for(;i<57213;)d.Add(x++,""+(char)55356+(char)i++);for(var e=new System.Random();;){for(w("  1⃣ 2⃣ 3⃣ 4⃣ 5⃣ 6⃣ 7⃣"),x=0;x<8;x++,w(""))for(h.Write((char)('A'+x)),i=0;i<7;)h.Write(" "+d[x*7+i++]);for(;;){var k=h.ReadLine();if(k[0]==47){var l=k[1];z=b;b+=l=='N'?.05:l=='D'?.1:l=='Q'?.25:l=='O'?1:l=='F'?5:l=='T'?10:0;a=a|z!=b;w(z!=b?$"Balance {b:0.00}":"Money not Accepted");}else{if(k=="Done"){for(;b/.25>=1;b-=.25)h.Write("Q");for(;b/.1>=1;b-=.1)h.Write("D");for(;b/.05>=1;b-=.05)h.Write("N");return;}r=k[0]-65;c=k[1]-49;if(r<0|r>7|c<0|c>6)w("Invalid code");else{p=1+r/2;if(!a|p>b)w($"{(a&p>b?"Insufficient Funds. ":"")}Item Cost: ${p:0.00}");else{m=r*7+c;if(d[m]=="")w("Item out of stock");else{if(r>6&c<6){j=e.Next(13,20);n=e.Next(13,20);w($"ID required: {j}x{n} = ?");if(int.Parse(h.ReadLine())!=j*n){w("");break;}}b-=p;w($"Item at {k} Purchased. Remaining Balance: ${b:0.00}");if(e.Next(10)==1)for(w("Jam!!!");;){var f=h.ReadLine();if((f=="punch"|f=="kick")&e.Next(10)<2)break;}w(""+d[m]);d[m]="";if(b==0)return;break;}}}}}}}static void w(string s)=>h.WriteLine(s);}

slightly more ungolfed for use in LinqPad 5 (C# 6). Use h=System.Console in F4.
void Main()
{
    double b=0,z,p,x=0,i=57157,j,n,r,c,m;
    var a = 1==0;
    var d = new Hashtable();
    for (; i < 57213;) d.Add(x++, ""+(char)55356 + (char)i++);
    for (var e = new Random(); ;)
    {
        for (w("  1⃣ 2⃣ 3⃣ 4⃣ 5⃣ 6⃣ 7⃣"), x = 0; x < 8; x++, w(""))
            for (h.Write((char)('A' + x)), i = 0; i < 7;)
                h.Write(" " + d[x * 7 + i++]);

        for (; ;)
        {
            var k = h.ReadLine();
            if (k[0] == 47)
            {
                var l = k[1];
                z = b;
                b += l == 'N' ? .05 : l == 'D' ? .1 : l == 'Q' ? .25 : l == 'O' ? 1 : l == 'F' ? 5 : l == 'T' ? 10 : 0;
                a = a|z!=b;
                w(z != b ? $"Balance {b:0.00}" : "Money not Accepted");
            }
            else
            {
                if (k == "Done")
                {
                    for (; b / .25 >= 1; b -= .25) h.Write("Q");
                    for (; b / .1 >= 1; b -= .1) h.Write("D");
                    for (; b / .05 >= 1; b -= .05) h.Write("N");
                    return;
                }
                r = k[0] - 65;
                c = k[1] - 49;
                if(r<0|r>7|c<0|c>6)w("Invalid code");
                else
                {
                    p = 1 + r / 2;
                    if (!a | p > b) w($"{(a&p>b?"Insufficient Funds. ":"")}Item Cost: ${p:0.00}");
                    else
                    {
                        m = r * 7 + c;
                        if (d[m] == "")
                            w("Item out of stock");
                        else
                        {
                            if (r > 6 & c < 6)
                            {
                                j = e.Next(13, 20);
                                n = e.Next(13, 20);
                                w($"ID required: {j}x{n} = ?");
                                if (int.Parse(h.ReadLine()) != j * n)
                                {
                                    w("");
                                    break;
                                }
                            }

                            b -= p;
                            w($"Item at {k} Purchased. Remaining Balance: ${b:0.00}");
                            if (e.Next(10) == 1)
                                for (w("Jam!!!"); ;)
                                {
                                    var f = h.ReadLine();
                                    if ((f == "punch" | f == "kick") & e.Next(10) < 2)
                                        break;
                                }
                            w(""+d[m]);
                            d[m] = "";
                            if (b == 0) return;
                            break;
                        }
                    }
                }
            }
        }
    }
}

void w(string s)=>h.WriteLine(s);

edit: thanks for the for(;;) hint ;)
edit: Strike !! Better than PHP ;-)
edit: Removed 24 Letters. Still something left for php.
edit: Removed 20 Letters by switching from decimal to double.
edit: Removed 7 Letters by switching to Emoji Numbers
edit: Removed 4 Letters by switching everything to double instead of a mix of double and ints.
edit: Removed 69 Letters - found dead code o_O Best Entry C# :D
edit: Removed 3 Letters - switched last if-else statement
edit: Removed 4 Letters - switched from short-circuit operators (&& and ||) to normal & and |
edit: Removed 11 Letters - switched from h.WriteLine to w() with conditional verbatim string.

Looks good. I was able to test it here with static input. Is there a way for me to test it online or on Mac with dynamic input?

You can test it with dynamic input here, although the emojis show up as ??.

The only issue I've found with yours is that "Invalid code" should only show up for a number-digit combo that is not in range. All unspecified errors should output "Error".

on my way @insertusernamehere :D

hey .... i've got it down to under php :) @insertusernamehere

Nice job!  I think I have to leave him as accepted answer though.

no problem :) is just for the fun of it.

This deserves an accept.

source: Stack Exchange

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

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

sort: votes


text:
You are the Weakest Link, Goodbye
This king-of-the-hill challenge is based off of the game show, Weakest Link.  For those unfamiliar with the show, the crux of this challenge deals with who you vote off:

If the other players are smarter than you, then you have less of a chance of getting the pot.
If the other players are dumber than you, then you have less of a pot to get.

At the start of each round, the Pot starts out with $0.  A group of 9 players is formed, and each player is given a unique Smartness from 1 to 9.
At the start of each turn, Pot += Smartness for each player still in the round.  Then, players vote on the player they wish to remove.  The player with the most votes is removed.  In case of a tie, the smarter player is kept.
When there are only 2 players are left in the round, they face off in a battle of wits.  The chance of the player winning is Smartness/(Smartness+OpponentSmartness).  The winning player then receives the entire pot.
The player who has received the most money at the end of the game wins.
Input / Output
Each turn, you will receive the current list of opponents.  You will have access to your smartness and all players' entire voting history for the round via functions in the Player class.
As output, you must return a single integer, representing the player you wish to vote for (representing their smartness).  Voting for yourself is allowed (but not recommended).
Rounds of 9 will repeat until all players have played at least 100010000 rounds, and all players have played in the same number of rounds.
You can find the controller here: https://github.com/nathanmerrill/WeakestLink
To create a player, you need to extend the Player class, and add your player to the PlayerFactory class.  Your class must follow the following rules:

Communication or interference with any other player (include your other players of the same type) is strictly prohibited.

Reflection and static variables (except for constants) are not allowed.

If you want to use randomness, I have provided a getRandom() function in the Player class.  Use it, so simulations can be deterministic.

I have provided many functions in the Player class for easy access to data.  You can find them online on Github.  Your player will be instantiated each new round.  "Dumb/suicidal" players are allowed (but not players with the same strategy).
Scores
377195  WeakestLink.Players.PrudentSniper
362413  WeakestLink.Players.Sniper
353082  WeakestLink.Players.VengefulSniper
347574  WeakestLink.Players.AntiExtremist
298006  WeakestLink.Players.BobPlayer
273867  WeakestLink.Players.MedianPlayer
247881  WeakestLink.Players.TheCult
240425  WeakestLink.Players.Leech
235480  WeakestLink.Players.SniperAide
223128  WeakestLink.Players.Guard
220760  WeakestLink.Players.Anarchist
216839  WeakestLink.Players.RevengePlayer
215099  WeakestLink.Players.IndependentVoter
213883  WeakestLink.Players.SniperKiller
210653  WeakestLink.Players.MaxPlayer
210262  WeakestLink.Players.Bandwagon
209956  WeakestLink.Players.MeanPlayer
208799  WeakestLink.Players.Coward
207686  WeakestLink.Players.Spy
204335  WeakestLink.Players.Hero
203957  WeakestLink.Players.MiddleMan
198535  WeakestLink.Players.MinPlayer
197589  WeakestLink.Players.FixatedPlayer
197478  WeakestLink.Players.HighOrLowNotSelf
181484  WeakestLink.Players.RandomPlayer
165160  WeakestLink.Players.BridgeBurner

don't get this: "At the start of each round... A group of 9 players is formed, and each player is given a unique Smartness" not at the start of the game start?

@CSᵠ correct.  Your smartness changes from round to round (it would be unfair otherwise).

must be the stress and joy

Should I expect an ant build config or some such?  I'm kinda new to java, and I'm not sure how people usually set up little projects like this one.

From within src\WeakestLink I used javac Game\*.java Players\*.java Main.java to compile and java -cp .. WeakestLink.Main to run.

I feel like this would be a lot more interesting if players could artificaily lower their smartness for each turn.

@immibis I'm not sure how you think that would work.  We refer to players by their smartness, so there would be a possibility of multiple players with the same smartness, or if we refer to players by something else, then we can track that their smartness changed.

@DaleJohnson Or you could easily import the code into your i'd in a new project.

@NathanMerrill I would have loved having a way to know who had reason when they voted.Too bad for me :p. (Wanted to do a bot voting for the one who voted the most successfully ^^).

@Katenkyo figuring out who voted most successfully is definitely possible with the information I've given you.  You can track who was in the round last time, figure out who was removed, and then get all of the people that voted for them the last round.

@NathanMerrill i though the only informations about others I had was : their smartness and their votes. As I can't identify by a name, nor know the exact changement in smartness for each one, I can't actually see an implementation without cases where I don't know who has been excluded. But if you say i can, I'll give it a go when I'll be back Home :). Anyway, well done, it's a pretty funny KotH ^^.

@Katenkyo People's smartness don't change from turn to turn (meaning you can track it within a round).  You can't target players that were successful last round though (intentionally).

@NathanMerrill Ho, didn't understand that, feel stupid now... Voting right gives you an immunity so? Ok taking note, will have to revert it and vote for the least successful so.

Nothing makes you immune from being voted off?  What do you mean by "so"

@NathanMerrill "You can't target players that were successful last round though" wasn't this meaning "they are immune the next turn"? Using the vote list, I could tell if they were right or not, right? and the so was more like "so I will have to revert...."

@Katenkyo You have complete information of what has happened in the current round, but the current round only.  A round starts with 9 people, and lasts until 1 remains.  While the winners of the previous rounds aren't immune, you can't specifically target them, because you have no idea who they are.

@NathanMerrill My bad here, by round, I was meaning turn ^^'

@NathanMerrill It looks like the smartness values in your code are 0-8, doesn't this adversely affect the face-off & pot? Not to mention I wrote some of my code assuming it was 1-9.

@Linus what a huge bug.  I fixed it (and several players that broke because of the bug).  Scores have been updated.

@TheNumberOne within a round, you can store as much data as you'd like.  Each new round, I make a new instance of your bot, so storing results statically is not allowed.  That said, if you can do some statistics on your personal time, and store the results in constants in the code you submit, that's fine as well.

Sniper
The general idea is to keep around one of the stupid players (i.e. ones we are more likely to beat in the face-off) to snipe for the points. After that we try to remove the other low-value players to raise the pot. But when we get to the intelligent players we opt to remove for the most dangerous ones in case our stupid player gets removed. That way if we don't have someone to snipe we should get someone we at least stand a chance against. Also, since we always vote with either a min or max player, I expect we are fairly effective in getting our way.
package WeakestLink.Players;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
public class Sniper extends Player {
    @Override
    public int vote(Set<Integer> currentOpponents) {
        int smrt = getSmartness();

        //count number of players smarter/stupider than me
        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_smrt=0, cnt_stpd=0, opp_smrt, min_stpd=10, max_smrt=0;

        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(opp_smrt > smrt){
                cnt_smrt++;
                if(opp_smrt > max_smrt) max_smrt = opp_smrt;
            }
            else if(opp_smrt < smrt){
                cnt_stpd++;
                if(opp_smrt < min_stpd) min_stpd = opp_smrt;
            }
        }

        //remove low-value, then dangerous players
        if(cnt_stpd>1)
            return min_stpd;
        else
            return max_smrt;
    }
}

So apparently rollback doesn't remove edits. If at all possible I'd like any edits removed to make it abundantly clear this is the original version.

TheCult
The cult players have a mildly esoteric voting scheme by which they attempt to identify each other and vote as a group, using only the voting record. Since each member of the cult knows how to vote, anyone who votes differently is revealed as a non-member and eventually targeted for elimination.
The voting scheme at a glance:

on the first turn vote for weakest contestant, working in concert with min & sniper helps the cult gain power
on subsequent turns vote off known non-members until only the cult remains (we vote off the lowest-value non-member to rack up points as long as we think we are in control).
when only members remain, vote off low-value members for points (indeed sacrificing yourself for the good of the cult).

The Code:
package WeakestLink.Players;
import WeakestLink.Game.Vote;
import java.util.Iterator;
import java.util.Set;
public class TheCult extends Player {
    private int cult_vote;
    private boolean[] isMember = null;
    @Override
    public int vote(Set<Integer> currentOpponents) {
        //on first turn, vote the code
        if(isMember == null){
            isMember = new boolean[10];
            for(int i=10; --i!=0;) isMember[i]=true; //runs 9-1
            return cult_vote = 1;
        }
        //on all other turn, assess who is not voting with the cult
        Vote opp_vote;
        int cult_cnt=0;
        Iterator<Vote> votes = getRecentVotes().iterator();
        while(votes.hasNext()){
            opp_vote = votes.next();
            if(opp_vote.getVoted() != cult_vote)
                isMember[opp_vote.getVoter()] = false;
            else
                cult_cnt++;
        }
        //find weakest and stongest non-members, and weakest members
        Iterator<Integer> opps = currentOpponents.iterator();
        int opp_smrt, min_mem=10, min_non=10, max_non=0;
        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(isMember[opp_smrt]){
                if(opp_smrt < min_mem) min_mem = opp_smrt;
            }else{
                if(opp_smrt < min_non) min_non = opp_smrt;
                if(opp_smrt > max_non) max_non = opp_smrt;
            }
        }
        if(cult_cnt>2 && min_non!=10) cult_vote = min_non;
        else if(max_non!=0)           cult_vote = max_non;
        else                          cult_vote = min_mem;
        return cult_vote;
    }
}

Final Thoughts:
The cult now switch's to voting for the most dangerous players when there are only two or fewer cult-members remaining for the face-off. I tested it several times with cult_cnt>1 and cult_cnt>2 conditions and the later wins more often.
Still, this is a precaution and the cult really isn't designed to work as lone player, so as the number of new players increase the cult should still lose eventually.

Would this not be better to vote off the smartest non-members first?

I have updated the controller code so that the random variable is static (and can be accessed via Game.random).  I've also taken the liberty of updating the code on github: https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/TheCult.java

@NathanMerrill Thanks, but I'm seem to get better results if I allow the cult to be more tolerant (go figure) to unknown non-members who vote in it's interest.

@agweber, Thanks for the suggestion. This probably makes thecult a better sole-player, but as long as it has the numbers it should try to run up the pot. I think my new version is the best of both world.

@Linus Funny enough, this bot pushed RandomPlayer to the bottom.

TheCult bid me to request that unusedPlayers.addAll(allPlayers); in Game.java be duplicated around nine times, so that all players can occur in varied multiplicity (like shuffling together multiple decks of cards)... no don't of course, that's totally a biased request but it's interesting to see just how powerful the team based strategy can still be if they have even a small chance of getting put together.

PrudentSniper
Sniper, but with two special-case behaviors. One is that if there are three bots left, and PrudentSniper is the smartest, it will vote for the middle bot instead of the least smart. This allows it to win a few more showdowns. The other behavior is that if the smartest bot is gunning for it (voted for it or the analogous bot last time) and the least smart isn't, it will vote for the smartest in self defense.
package WeakestLink.Players;
import WeakestLink.Game.Vote;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
public class PrudentSniper extends Player {
    @Override
    public int vote(Set<Integer> currentOpponents) {
        int smrt = getSmartness();

        //count number of players smarter/stupider than me, find max/min
        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_smrt=0, cnt_stpd=0, opp_smrt, min_stpd=10, max_smrt=0;

        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(opp_smrt > max_smrt) max_smrt = opp_smrt;
            if(opp_smrt < min_stpd) min_stpd = opp_smrt;
            if(opp_smrt > smrt){
                cnt_smrt++;
            }
            else if(opp_smrt < smrt){
                cnt_stpd++;
            }
        }

        //identify enemies
        Iterator<Vote> votes = getRecentVotes().iterator();
        boolean[] voted_for_me = new boolean[9];

        while(votes.hasNext()) {
          Vote opp_vote = votes.next();
          voted_for_me[opp_vote.getVoter()] = (opp_vote.getVoted() == getSmartness() ||
                                              (opp_vote.getVoted() < getSmartness() && cnt_stpd < 1) ||
                                              (opp_vote.getVoted() > getSmartness() && cnt_smrt < 1));
        }

        if (currentOpponents.size() < 3 || cnt_stpd < 2 || (voted_for_me[max_smrt] && !voted_for_me[min_stpd] && cnt_smrt > 0) )
          return max_smrt;
        else
          return min_stpd;
    }
}

I'm not sure that both advancements are of equal worth. Have you tried them each separately?

I did, and while the three bots case is an unambiguous improvement (at least against the bots currently in master on the repo), the retribution is about neutral, on net. I left it in as a sort of vague deterrent, a precaution against assassins.

relevant ;)

I recently fixed a bug where smartness was 0-8 instead of 1-9.  This broke your code, so I fixed it (you can find the updated code on the repository): https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/PrudentSniper.java

BridgeBurner
Not somewhere where I can test this right now, and this came out feeling like really ugly/dumb code, but it should work.
This bot just wants to be hated. It votes for whoever has voted against it the least. In the event of a tie, it picks whoever has gone the longest without voting for it. In the event of another tie, it picks the smartest of those (presumably because they will make the worst enemy). It will not vote for itself, because no one will really hate it when it's not around.
package WeakestLink.Players;

import WeakestLink.Game.Vote;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class BridgeBurner extends Player{
    @Override
    public int vote(Set<Integer> currentOpponents) {
        List<Integer> votes_against = Stream.generate(() -> 0).limit(9).collect(Collectors.toList());
        List<Integer> last_voted_against = Stream.generate(() -> 0).limit(9).collect(Collectors.toList());
        Iterator<Vote> votes_against_me = getVotesForSelf().iterator();

        for (int c = 0; c < 9; c++){
            if (!currentOpponents.contains(c)){
                votes_against.set(c,-1);
                last_voted_against.set(c,-1);
            }
        }

        while(votes_against_me.hasNext()){
            Vote vote = votes_against_me.next();

            int voter = vote.getVoter();
            int round = vote.getRound();

            if (currentOpponents.contains(voter)){
                votes_against.set(voter, votes_against.get(voter)+1);
                last_voted_against.set(voter, Math.max(round, last_voted_against.get(voter)));
            } else {
                votes_against.set(voter, -1);
                last_voted_against.set(voter, -1);
            }
        }

        int min_tally = Collections.max(votes_against);
        for (int c = 0; c < 9; c++){
            int current_tally = votes_against.get(c);
            if (current_tally != -1 && current_tally < min_tally){
                min_tally = current_tally;
            }
        }

        if (Collections.frequency(votes_against, min_tally) == 1){
            return votes_against.indexOf(min_tally);
        } else {
            List<Integer> temp_last_against = new ArrayList<>();
            for (int c = 0; c < 9; c++){
                if (votes_against.get(c) == min_tally){
                    temp_last_against.add(last_voted_against.get(c));
                }
            }
            return last_voted_against.lastIndexOf(Collections.min(temp_last_against));
        }
    }
}

I was unable to get this bot to work.  I fixed several bugs, and it is now voting for a non-existent player.  The one change I wasn't sure if it was right was that "last_round_voted" isn't defined, so I changed it to "last_voted_against".  You can find my changes here: https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/BridgeBurner.java

@NathanMerrill This code was apparently even worse than I thought. Now that I can test it, I'll look at both versions and try to get this working.

@NathanMerrill Found a couple issues. Namely, I didn't ignore players who were not in the found that never voted for the bot, which is why it always tried to vote for them. Also used the wrong list to get an index from at one point, resulting in player -1 being voted for. But it should be fixed now.

Well, it works, but does terrible.  Congrats on beating random player!

@NathanMerrill on beating random player sometimes

I recently fixed a bug where smartness was 0-8 instead of 1-9.  This broke your code, so I fixed it (you can find the updated code on the repository)

+1 "because no one will really hate it when it's not around"

RevengePlayer
This bot will vote for whoever voted for him the most times, tiebreaker being the smartest player. The theory is that a player that voted for you in the past will likely vote for you again.
package WeakestLink.Players;
import java.util.Collections;
import java.util.Set;
import java.util.Iterator;
import WeakestLink.Game.Vote;
public class RevengePlayer extends Player{

    @Override
    public int vote(Set<Integer> opponents) {
        int[] A;
        A = new int[10];
        for(int i = 1;i < 10;i++)
            A[i] = opponents.contains(i)? i+1 : 0;
        Set<Vote> H = getVotingHistory();
        Iterator<Vote> I = H.iterator();
        while(I.hasNext()){
            Vote v = I.next();
            if(v.getVoted() == getSmartness())
                A[v.getVoter()] += A[v.getVoter()] != 0?10:0;
        }
        int maxI = 0;
        for(int i = 1;i < 10;i++)
            if(A[i] > A[maxI])
                maxI = i;
        return maxI;
    }
}

I recently fixed a bug where smartness was 0-8 instead of 1-9.  This broke your code, so I fixed it (you can find the updated code on the repository): https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/RevengePlayer.java

@NathanMerrill your fix for my code had a small bug. I edited my code to make it better.

Bandwagon
Follows the crowd in voting, unless he's the one being targeted.
package WeakestLink.Players;

import WeakestLink.Game.Vote;
import java.util.Map;
import java.util.Set;

/**
 * Votes for the currently most voted bot in the game. Or the lowest one.
 */
public class Bandwagon
        extends Player {

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int self = getSmartness(), vote = -1;
        java.util.Map<Integer, Integer> votes = new java.util.TreeMap<>();
        getVotingHistory().stream().map((Vote v)-> v.getVoted()).filter((Integer i)-> !i.equals(self)).forEach((Integer tgt)-> {
            if(!votes.containsKey(tgt)) {
                votes.put(tgt, 1);
            } else {
                votes.put(tgt, votes.get(tgt) + 1);
            }
        });

        do {
            if(votes.entrySet().isEmpty()) {
                vote = currentOpponents.stream().filter((Integer i)-> !i.equals(self)).sorted().findFirst().get();
            } else {
                if(votes.containsKey(vote)) {
                    votes.remove(vote);
                    vote = -1;
                }

                for(Map.Entry<Integer, Integer> vv: votes.entrySet()) {
                    Integer key = vv.getKey();
                    Integer value = vv.getValue();

                    if((vote == -1) || (value > votes.get(vote))) {
                        vote = key;
                    }
                }
            }
        } while(!currentOpponents.contains(vote));

        return vote;
    }
}

I'm guessing this one will just make snipers stronger by following them, but also avoids being targeted by the cult and sniper-aides in a slightly effective manner. It may as well be a meatshield for sniper killers or aid them if there's more of them. (Need to test with the latest updates).
Using java 8 features because the game needs that to run anyway.

It's nice to see some well written code :)

AntiExtremist
This extreme socialist believes that all people should be of equal smartness.  He tries to kill those who are much smarter or dumber than he is.  He considers both but he favors dumb in general.  He favors dumb people in the beginning and smart in the end, but it's weighted based on how extreme those people are.
package WeakestLink.Players;
import java.util.Arrays;
import java.util.Set;

public class AntiExtremist extends Player {

    Object[] currentPlayers;

    @Override
    public int vote(Set<Integer> currentOpponents) {

        currentPlayers = (Object[]) currentOpponents.toArray();
        Arrays.sort(currentPlayers);

        int smartness = getSmartness();
        int turns = getTurnNumber();

        //// Lets get an idea of who's smart and who's dumb ////

        int smarter = 0, dumber = 0;

        int max_smart = 0, min_smart = 10;

        currentOpponents.toArray();

        for (int i = 0; i < currentPlayers.length; i++) {
            int osmart = (int)currentPlayers[i];

            if (osmart == smartness)
                continue;

            if (osmart > smartness) {
                smarter++;

                if (osmart > max_smart)
                    max_smart = osmart;
            }
            else if (osmart < smartness) {
                dumber++;

                if (osmart < min_smart)
                    min_smart = osmart;
            }

        }

        // int total = smarter+dumber;

        double smarter_ratio = smarter > 0 ? (max_smart-smartness)/4.5 : 0;
        double dumber_ratio = dumber > 0 ? (smartness-min_smart)/3.0 : 0;//Favor dumber

        smarter_ratio*=.25+(turns/9.0*.75);
        dumber_ratio*=1-(turns/8.0*.75);

        return smarter_ratio > dumber_ratio ? max_smart : min_smart;

    }

}

NOTE: According to Linus this will vote the same as sniper the vast majority of the time (525602:1228).

I'm going to keep the current run to 10K for now (for quicker testing).  When I do the final run through, I'll likely make it larger.

I'm not trying to accuse you of anything, but this votes the way Sniper would ~99.7% of the time, it's basically going to be a coin flip as to who wins, since they are so close to the same strategy.

Where did you get that statistic from?  I admit it has a semi-similar strategy but my goal was to try at improve upon something as simple as yours by choosing to vote for people whom are very smart if they are significantly smarter than me(aka I'm not likely to win the pot if they survive)

@Linus Originally I also tried targeting those whom had targeted me recently, but that decreased my effectiveness

I gave your class a static Sniper S = new Sniper() and static long agrees=0, disagrees=0;. In your voting method I add S.setSmartness(getSmartness()); int sniper_answer=S.vote(currentOpponents); which calculates how a sniper would vote in your position, then put your answer into a variable to counted whether it agreed or disagreed before returning its answer. Once the game is over you can print agrees:disagress which was 525602:1228.

@Linus That makes sense, sounds legit.  I'll add a note about that.

MeanPlayer
Vote neither the stupidest nor the smartest players, and he's carrying a gun (sneaked it past security)
public class MeanPlayer extends Player{

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int mid = currentOpponents.size() / 2;
        Object[] sortedOpponents = currentOpponents.toArray();
        Arrays.sort(sortedOpponents);
        return (int) sortedOpponents[mid];
    }
}

I don't understand why this player is any meaner than the rest /sarc

Watch out @NathanMerrill, he's got a gun! I'd choose my words carefully if I were you...

@CSᵠ I'm not worried. When he's the average player, he uses the gun on himself.

@quintopia True, that's a sure vote, but maybe he escapes being also voted by others. Remember... he has a gun...

This player is less mean than she could be.  She appears to be more median than mean.

Hah.... took me a minute

@Yakk In this case median and mean are the same.

@PaŭloEbermann that's not strictly true, because players can be voted off.  There could be 1,6,7,8,9 left, with a mean of 6.2 and a median of 7.

@NathanMerrill true, they are only the same at the start (and maybe randomly after). Thanks

MedianPlayer
This player attempt to be the meanest (well, medianness) one left.
It votes to eliminate the smartest and dumbest opponents (with a slight bias towards voting off the smartest), depending on if there are more or less smarter/dumber than themself.
package WeakestLink.Players;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
public class MedianPlayer extends Player {
  @Override
  public int vote(Set<Integer> currentOpponents) {
    int smrt = getSmartness();

    //count number of players smarter/stupider than me
    Iterator<Integer> opps = currentOpponents.iterator();
    int cnt_smrt=0, cnt_stpd=0, min_stpd=10, max_smrt=0;

    while(opps.hasNext()){
      int opp_smrt = opps.next().intValue();
      if(opp_smrt > smrt){
        cnt_smrt++;
        if(opp_smrt > max_smrt)
          max_smrt = opp_smrt;
      } else if(opp_smrt < smrt){
        cnt_stpd++;
        if(opp_smrt < min_stpd)
          min_stpd = opp_smrt;
      }
    }

    // the middle must hold
    if(cnt_stpd>cnt_smrt)
      return min_stpd;
    else
      return max_smrt;
  }
}

framework blatantly stolen from @Linus above.

You made my IDE complain about duplicated code!

@NathanMerrill Copy-pasta attack!  Note I changed the name of the class since I posted.  As I suppose duplicating someone else's class name to ensure that you cannot go against them would be against the spirit of the rules.

Two classes with the same name would actually throw an exception, so its definitely not allowed :)

Thanks for blatantly stealing my work, or admitting so at least.

@Linus You are welcome!  Imitation is the best flattery, I hope.

@Linus he stole some pretty intuitive stuff, and his decision making is different so..  It doesn't strike me as especially grievous

@csga5000 blatantly stole was his joke, and i was just playing along. Any half-competent coder (e.g. myself) would write the loop the same way, so all he really did was steal my variable names. If i had thought to copyright them maybe I could charge royalties  ; )

Coward
package WeakestLink.Players;
import WeakestLink.Game.Vote;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
public class Coward extends Player {
  @Override
  public int vote(Set<Integer> currentOpponents) {

    boolean[] currentOpponent = new boolean[10];

    Iterator<Integer> opps = currentOpponents.iterator();
    while(opps.hasNext()){
      currentOpponent[opps.next().intValue()] = true;
    }

    int[] voteCounts = new int[9];
    for(int i=0; i<9; i++) {
        voteCounts[i] = 0;
    }

    Iterator<Vote> votes = getRecentVotes().iterator();

    while(votes.hasNext()){
      Vote opp_vote = votes.next();
      if(currentOpponent[opp_vote.getVoter()])
        voteCounts[opp_vote.getVoted()] += 1;
      else
        voteCounts[opp_vote.getVoter()] += 100;
    }

    int previous_weakest = -1;
    int max_votes_gotten = 0;
    for(int i=0;i<9;i++){
      if (voteCounts[i] > max_votes_gotten) {
        max_votes_gotten = voteCounts[i];
        previous_weakest = i;
      }
    }
    int min_closeness = 10;
    int to_vote = -1;
    int opp;
    int closeness;
    opps = currentOpponents.iterator();
    while(opps.hasNext()){
      opp = opps.next();
      closeness = Math.abs(opp - previous_weakest);
      if(closeness <= min_closeness) {
        to_vote = opp;
        min_closeness = closeness;
      }
    }

    return to_vote;

  }
}

Just doesn't want to get voted off, so votes for the opponent most similar to the player that got voted off last round in order to maximize the chance of being on the winning team.
Doesn't do particularly well right now, but might as well throw it in the mix.

I recently fixed a bug where smartness was 0-8 instead of 1-9.  This broke your code, so I fixed it (you can find the updated code on the repository): https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/Coward.java

Spy
Spy is reserved. He doesn't like to gun for the smartest people. Likewise, he doesn't like picking on quartata defenseless idiots. So, he likes to eliminate those closest to him in smartness.
package WeakestLink.Players;

import java.util.Iterator;
import java.util.Set;

public class Spy extends Player{
  @Override
  public int vote(Set<Integer> currentOpponents) {
    int selfIntel = getSmartness();
    int closestIntel = 100; // default
    // get closest player
    Iterator<Integer> enemies = currentOpponents.iterator();
    while(enemies.hasNext()){
      int enemyIntel = enemies.next().intValue();
      if(Math.abs(enemyIntel - selfIntel) < closestIntel) closestIntel = enemyIntel;
    }
    return closestIntel;
  }
}

You've just been backstabbed, mes amis. He doesn't care if he wins. He just like the sound of the knife in your back as he votes you off successfully.

That image, though. +1

I think this has a bug. Math.abs(enemyIntel - selfIntel) < closestIntel should be Math.abs(enemyIntel - selfIntel) < Math.abs(closestIntel - selfIntel).

@MegaTom I think you're right. I will check on this further when I have Java available. Thanks for the possible catch!

Statistics
This is not an entry to the contest. This is merely a way to get useful statistics of a game. These statistics print off the percentage likelihood that a particular player will be voted off in a round.
To do this add the following lines to Round.java so that the top of the file looks like this:
package WeakestLink.Game;

import WeakestLink.Players.Player;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Round {

    private static int[][] statistics = new int[Game.NUMBER_PLAYERS_PER_ROUND - 2][Game.NUMBER_PLAYERS_PER_ROUND + 1];
    private static int[] counts = new int[Game.NUMBER_PLAYERS_PER_ROUND - 2];

    static {
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            for (int i = 0; i < Game.NUMBER_PLAYERS_PER_ROUND - 2; i++){
                System.out.println();
                System.out.println("For " + (i+1) + "th round:");
                for (int j = 1; j <= Game.NUMBER_PLAYERS_PER_ROUND; j++){
                    System.out.println(String.format("%f%% voted for %d", 100.0*statistics[i][j]/counts[i], j));
                }
            }
        }));
    }

...

Then modify the vote method to look like this:
private Vote vote(Player player){
    player.setVotingHistory(new HashSet<>(votes));
    player.setTurnNumber(currentTurn);
    player.setPot(pot);
    Set<Integer> players = currentPlayers.stream()
            .filter(p -> p != player)
            .map(playerToSmartness::get)
            .collect(Collectors.toSet());
    int vote = player.vote(players);
    if (!currentPlayers.contains(smartnessToPlayer.get(vote))){
        throw new RuntimeException(player.getClass().getSimpleName()+" voted off non-existent player");
    }
    Vote v = new Vote(playerToSmartness.get(player), vote, currentTurn);
    counts[v.getRound()]++;
    statistics[v.getRound()][v.getVoted()]++;
    return v;
}

Example Output:
For 1th round:
55.554756% voted for 1
4.279166% voted for 2
1.355189% voted for 3
1.778786% voted for 4
3.592771% voted for 5
3.952368% voted for 6
1.779186% voted for 7
6.427149% voted for 8
21.280630% voted for 9

For 2th round:
2.889877% voted for 1
34.080927% voted for 2
6.826895% voted for 3
4.990010% voted for 4
5.914753% voted for 5
4.985510% voted for 6
3.302524% voted for 7
11.304360% voted for 8
25.705144% voted for 9

For 3th round:
2.152783% voted for 1
13.005153% voted for 2
21.399772% voted for 3
7.122286% voted for 4
6.122008% voted for 5
6.761774% voted for 6
11.687049% voted for 7
19.607500% voted for 8
12.141674% voted for 9

For 4th round:
2.122183% voted for 1
10.105719% voted for 2
11.917105% voted for 3
17.547460% voted for 4
8.626131% voted for 5
12.079103% voted for 6
18.819449% voted for 7
11.065111% voted for 8
7.717738% voted for 9

For 5th round:
1.689826% voted for 1
7.364821% voted for 2
9.681763% voted for 3
11.704946% voted for 4
20.336237% voted for 5
20.691914% voted for 6
13.062855% voted for 7
9.332565% voted for 8
6.135071% voted for 9

For 6th round:
1.456188% voted for 1
6.726546% voted for 2
10.154619% voted for 3
16.355569% voted for 4
22.985816% voted for 5
17.777558% voted for 6
11.580207% voted for 7
7.757938% voted for 8
5.205558% voted for 9

For 7th round:
1.037992% voted for 1
6.514748% voted for 2
15.437876% voted for 3
22.151823% voted for 4
17.015864% voted for 5
14.029088% voted for 6
11.907505% voted for 7
7.957136% voted for 8
3.947968% voted for 9

1th, 2th, 3th? I'd suggest changing it to print "For round 1" etc.

Hero
Votes off those who pick on the weak ... or annoy him.
package WeakestLink.Players;

import WeakestLink.Game.Game;
import WeakestLink.Game.Vote;

import java.util.*;

/**
 * Created by thenumberone on 12/2/15.
 * @author thenumberone
 */
public class Hero extends Player{

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int me = getSmartness();
        Set<Vote> history = getVotingHistory();
        history.removeIf(vote -> !currentOpponents.contains(vote.getVoter()) || vote.getVoter() == me);
        int[] evilnessLevel = new int[Game.NUMBER_PLAYERS_PER_ROUND];
        for (Vote vote : history){
            evilnessLevel[vote.getVoter()] += vote.getVoted() == me ? 1_000_000 : Game.NUMBER_PLAYERS_PER_ROUND - vote.getVoted();
        }
        int mostEvilOpponent = -1;
        for (int opponent : currentOpponents){
            if (mostEvilOpponent == -1 || evilnessLevel[opponent] > evilnessLevel[mostEvilOpponent]){
                mostEvilOpponent = opponent;
            }
        }
        return mostEvilOpponent;
    }
}

I recently fixed a bug where smartness was 0-8 instead of 1-9.  This broke your code, so I fixed it (you can find the updated code on the repository): https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/Hero.java

@NathanMerrill Thank you :)

FixatedPlayer
Picks a random target, then votes for them until they're gone. Won't vote for himself though.
package WeakestLink.Players;

import WeakestLink.Game.Vote;

import java.util.*;

public class FixatedPlayer extends Player{
    @Override
    public int vote(Set<Integer> currentOpponents) {
        int self = getSmartness();
        Vote previous_vote = getLastVote();
        if (previous_vote == null || !currentOpponents.contains(previous_vote.getVoted())){
            return (int) currentOpponents.toArray()[getRandom().nextInt(currentOpponents.size())];
        }
        else {
            return previous_vote.getVoted();
        }
    }
}

This code didn't work either, but was an easy fix.  Your do-while is actually not necessary, because I don't give you your smartness when I pass you your currentOpponents.  The fixed code can be found here: https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/FixatedPlayer.java

@NathanMerrill I edited the corrected code into my answer so anyone looking at it here see's what's actually being run

Bob
Bob is just the average guy that thinks he is smarter then he really is.
Cannot win the sniper family but get top 5 in my simulations most of the time.
package WeakestLink.Players;

import java.util.Collections;
import java.util.Set;

import WeakestLink.Game.Vote;

public class BobPlayer extends Player {

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int smartness;

        // Bob sometimes thinks he is smarter than he really is
        if (getRandom().nextInt(10) == 0) {
            smartness = 10;
        } else {
            smartness = getSmartness();
        }

        // If there is still some competition
        if (currentOpponents.size() > 3) {
            // And Bob is the dumbest
            if (smartness < Collections.min(currentOpponents)) {
                // Go for the smartest one
                return Collections.max(currentOpponents);
                // But if he is the smartest
            } else if (smartness > Collections.max(currentOpponents)) {
                // Go for the weak link
                return Collections.min(currentOpponents);
            } else {
                // Else revenge!
                for (Vote v : getRecentVotes()) {
                    if (v.getVoted() == smartness && currentOpponents.contains(v.getVoter())) {
                        return v.getVoter();
                    }
                }
            }
            return Collections.min(currentOpponents);
        } else {
            //If there are few opponents just revenge!
            for (Vote v : getRecentVotes()) {
                if (v.getVoted() == smartness && currentOpponents.contains(v.getVoter())) {
                    return v.getVoter();
                }
            }
            return Collections.max(currentOpponents);
        }
    }

}

MaxPlayer
A know-it-all.  Prefers to remove anybody with high-intelligence (who can therefore challenge his unmatched intellect)
public class MaxPlayer extends Player{

    @Override
    public int vote(Set<Integer> currentOpponents) {
        return Collections.max(currentOpponents);
    }
}

Guard
Votes off those that pick on the strong ... or those that annoy him.
package WeakestLink.Players;

import WeakestLink.Game.Game;
import WeakestLink.Game.Vote;

import java.util.Set;

/**
 * Created by thenumberone on 12/2/15.
 * @author thenumberone
 */
public class Guard extends Player{

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int me = getSmartness();
        Set<Vote> history = getVotingHistory();
        history.removeIf(vote -> !currentOpponents.contains(vote.getVoter()) || vote.getVoter() == me);
        int[] evilnessLevel = new int[Game.NUMBER_PLAYERS_PER_ROUND];
        for (Vote vote : history){
            evilnessLevel[vote.getVoter()] += vote.getVoted() == me ? 1_000_000 : vote.getVoted();
        }
        int mostEvilOpponent = -1;
        for (int opponent : currentOpponents){
            if (mostEvilOpponent == -1 || evilnessLevel[opponent] > evilnessLevel[mostEvilOpponent]){
                mostEvilOpponent = opponent;
            }
        }
        return mostEvilOpponent;
    }
}

I recently fixed a bug where smartness was 0-8 instead of 1-9.  This broke your code, so I fixed it (you can find the updated code on the repository): https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/Guard.java

Leech
Relies on other bots to vote the smartest and dumbest guys off.. sort of.
He is satisfied with turning up somewhere in the middle and eventually splitting the pot with the winner (since he is actually a really decent guy bot).
package WeakestLink.Players;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;

public class Leech extends Player {
    /**
     * Copyrighted (not really, use this however you want friends) by Sweerpotato :~)!
     */
    @Override
    public int vote(Set<Integer> currentOpponents) {
        int mySmartness = getSmartness();

        ArrayList<Integer> opponentSmartness = new ArrayList<Integer>();
        opponentSmartness.addAll(currentOpponents);
        opponentSmartness.add(mySmartness);
        Collections.sort(opponentSmartness);

        if(mySmartness > 4 && mySmartness > Collections.min(opponentSmartness)) {
            //There's somebody dumber than me, vote that dude off
            return opponentSmartness.get(opponentSmartness.indexOf(mySmartness) - 1);
        }
        else {
            //Vote off the smartest guy, so we have a better chance to win
            if(mySmartness == Collections.max(opponentSmartness)) {
                //Apparently, we're the smartest guy
                return opponentSmartness.get(opponentSmartness.indexOf(mySmartness) - 1);
            }
            else {
                return Collections.max(opponentSmartness);
            }
        }
    }
}

I like. I'm concerned it won't do well though because not many will vote the same as you.  That's one flaw with this competition is it seems to me that the other bots force you to conform to a certain type of strategy.

Still fun though! Winning isn't everything :~)!

SniperKiller
Another answer shamelessly stolen from Linus's code. This one in will kill all snipers, not protect them. If it knows that no snipers are left it will act like a sniper itself.
package WeakestLink.Players;
import WeakestLink.Game.Vote;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;

public class SniperKiller extends Player {
    boolean[] sniperish;
    int[] sniperwouldvote;

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int smrt = getSmartness();
        currentOpponents.add(smrt);
        if(sniperish==null){
            sniperish = new boolean[10];
            sniperwouldvote = new int[10];
            for(int i=10;--i!=0;){
                sniperish[i] = true;
                sniperwouldvote[i] = 1;
            }
            sniperish[smrt]=false; //knows we are not the sniper
            return 1;
        }
        //figure out who isn't a sniper
        Vote opp_vote;
        int opp_smrt;
        Iterator<Vote> votes = getRecentVotes().iterator();
        while(votes.hasNext()){
            opp_vote = votes.next();
            opp_smrt = opp_vote.getVoter();
            if(opp_vote.getVoted() != sniperwouldvote[opp_smrt])
                sniperish[opp_smrt] = false;
        }
        //figure out how snipers would vote this round
        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_opp=0, min_opp=10, max_opp=0;
        int[] snpr_votes = new int[10];
        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(smrt == opp_smrt) continue;
            sniperwouldvote[opp_smrt] = hypothetically(opp_smrt, currentOpponents);
            cnt_opp++;
            if(sniperish[opp_smrt]){
                snpr_votes[sniperwouldvote[opp_smrt]]++;
            }
            if(opp_smrt<min_opp) min_opp=opp_smrt;
            if(opp_smrt>max_opp) max_opp=opp_smrt;
        }
        for(int i = 1;i<10;i++){//hit the weakest sniper.
            if(sniperish[i] && currentOpponents.contains(i))
                return i;
        }
        return hypothetically(smrt, currentOpponents);
    }

    private int hypothetically(int smrt, Set<Integer> currentOpponents) {
        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_smrt=0, cnt_stpd=0, opp_smrt, min_stpd=10, max_smrt=0;
        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(opp_smrt > smrt){
                cnt_smrt++;
                if(opp_smrt > max_smrt) max_smrt = opp_smrt;
            }
            else if(opp_smrt < smrt){
                cnt_stpd++;
                if(opp_smrt < min_stpd) min_stpd = opp_smrt;
            }
        }
        if(cnt_stpd>1) return min_stpd;
        return max_smrt;
    }
}

I like the idea, but there seems to be a culture of voting for min or max player. voting for someone else might be throwing your vote away. Maybe if you check if the max is sniperish before voting for someone else you'll catch up a bit... (i can't check, on phone)

ApproximatePosition
This bot is trying to shooting approximately around the missing smartness values, assuming that the group will continue with the same pattern, meaning it will target the same type of target. It always vote for the smartest of two player when there's a choice.
Long time I didn't use Java, and currently at work so... Can't test it, hope it's not too buggy, be gentle please :).
By the way, it uses awt.Point only because I'm too lazy to implement a tuple n_n.
package WeakestLink.Players;
import WeakestLink.Game.Vote;

import java.util.*;
import java.awt.Point;

public class ApproximatePosition extends Player
{

    @Override
    public int vote(Set<Integer> currentOpponent)
    {
        List<Integer> present = new ArrayList<>(currentOpponent);
        List<Integer> emptyPosition = new ArrayList<Integer>();
        Collections.sort(present);

        //If it is the first round, vote for the smartest buddy
        if(present.size()==8)
            return present.get(present.size()-1);

        int lastCheck=present.get(0);
        if(lastCheck>0)
            for(int i=0;i<lastCheck;i++)
                if(i!=getSmartness()&&!emptyPosition.contains(i))
                    emptyPosition.add(i);
        for(int i=1;i<present.size();i++)
        {
            if(present.get(i)-lastCheck>1)
                for (int j=lastCheck+1;j<present.get(i);j++)
                    if(j!=getSmartness()&&!emptyPosition.contains(j))
                        emptyPosition.add(j);
            lastCheck=present.get(i);
        }
        //untill there's at least 3 excluded members, we continue with this behaviour
        if(emptyPosition.size()<=2)
        {
            if(emptyPosition.isEmpty()) return present.get(present.size()-1);
            return decide(emptyPosition.get(0),present.get(present.size()-1),present.get(0),present);
        }

        Point maxRangeOfBlank=new Point(present.get(present.size()-1),present.get(present.size()-1));
        for (int i=0;i<emptyPosition.size()-1;i++)
            if(emptyPosition.get(i+1)-emptyPosition.get(i)==1)
            {
                int size=0;
                while(i+size+1<emptyPosition.size() && emptyPosition.get(i+size+1)-emptyPosition.get(i+size)==1)
                    size++;
                if(size>=sizeOfRange(maxRangeOfBlank))
                    maxRangeOfBlank=new Point(emptyPosition.get(i),emptyPosition.get(size));
                i+=size;
            }

        return decide(maxRangeOfBlank,present.get(present.size()-1),present.get(0),present);
    }

    private int decide(int blankSeat, int smartest,int dumbest,List<Integer> present)
    {
        return decide(new Point(blankSeat,blankSeat),smartest,dumbest,present);
    }

    private int decide(Point rangeBlankSeat, int smartest,int dumbest,List<Integer> present)
    {
        int target= smartest;
        if (rangeBlankSeat.getY()==smartest||((int)rangeBlankSeat.getY()+1)==getSmartness()){
            if ((rangeBlankSeat.getX()==dumbest||(int)rangeBlankSeat.getX()-1==getSmartness())){
                target= smartest; //should not happen
            } else {
                target= (int) rangeBlankSeat.getX()-1; //Vote for dumber than the missing
            }
        } else {
            target= (int) rangeBlankSeat.getY() +1; //Vote for smarter than the missing, default comportment
        }
        if(present.contains(target))
            return target;
        return smartest;
    }
    //Return the number of consecutive values between X and Y (included)
    private int sizeOfRange(Point range)
    {
        return (int)(range.getY()-range.getX())+1;
    }

}

So, there were some bugs. :) First, unfortunately, the Integer[] cast doesn't work, it has to be an Object[] cast (which I don't like).  So I wrapped it all into an ArrayList instead of an array.  Secondly, this line: emptyPosition[emptyPosition.length]=j; will always give you array out of bounds.  Finally, not sure why, but you will vote off players that aren't in the round.

Oh, also, your ternary block was returning a double instead of int, and was super convoluted, I turned it into a standard if/else.  You can find all of my changes on Github: https://github.com/nathanmerrill/WeakestLink/blob/master/src/WeakestLink/Players/ApproximatePosition.java

@NathanMerrill Wow, thanks a lot. For the emptyPosition[emptyPosition.length], it is a dumb mistake as length is always one over the last index ^^. Thanks for the changes, I will use this new version to correct it. About the ternary block... yeah, felt like using it, and maybe way too used to writing for myself, wasn't handy to read I guess. Doing the corrections and updating it.

RandomPlayer
public class RandomPlayer extends Player{

    @Override
    public int vote(Set<Integer> currentOpponents) {
        return (int) currentOpponents.toArray()[getRandom().nextInt(currentOpponents.size())];
    }
}

MinPlayer
An Elitist.  Prefers to remove anybody with low intelligence.
public class MinPlayer extends Player {

    @Override
    public int vote(Set<Integer> currentOpponents) {
        return Collections.min(currentOpponents);
    }
}

HighOrLowNotSelf
Removes randomly lowest or highest intelligence player (but not self).
public class HighOrLowNotSelf extends Player{
    @Override
    public int vote(Set<Integer> ops) {
        int b=Math.round(Math.random()*1);
        int p;
        if(b==1) p=Collections.max(ops) else p=Collections.min(ops);
        if(p==getSmartness()) {
            return vote(ops);
        }
        return p;
    }
}

So, there are a couple of bugs with this submission.  First, Math.round() returns a long, not int.  Secondly, ops does not contain yourself.  (If you wanted to vote for yourself, you'd explicitly have to include it).  Finally, the if/else you included isn't valid Java.  I've fixed your code, and added it to github

VengefulSniper
This started as something I thought was original called StupidBuffering (a name I hated to give up), then ended up being just a PrudentSniper who didn't care if he was being targeted. This also seemed to be the only reason he couldn't beat PrudentSniper, so I tweaked things around a bit to make that his focus.
Now, this is basically a sniper, but if the smartest or dumbest bot targets him, he will target whichever one got the most votes last round. If they both got the same number of votes and both targeted him, he goes back to normal sniper-y behavior. In my tests, this actual beats PrudentSniper on occasion.
package WeakestLink.Players;

import java.util.*;

import WeakestLink.Game.Vote;

public class VengefulSniper extends Player{
    @Override
    public int vote(Set<Integer> currentOpponents) {
        int me = getSmartness();
        int smartOpp = Collections.max(currentOpponents);
        int dumbOpp = Collections.min(currentOpponents);
        int votesAgainstSmart=0, votesAgainstDumb=0;
        Boolean targetedBySmart = false, targetedByDumb = false;

        Set<Vote> votesForMe = getRecentVotes();
        Iterator<Vote> votes = votesForMe.iterator();
        while(votes.hasNext()){
            Vote vote = votes.next();
            int voter = vote.getVoter();
            int voted = vote.getVoted();

            if(voted == me){
                if(voter == smartOpp){
                    targetedBySmart = true;
                }
                if(voter == dumbOpp){
                    targetedByDumb = true;
                }
            } else if (voted == smartOpp){
                votesAgainstSmart++;
            } else if (voted == dumbOpp){
                votesAgainstDumb++;
            }
        }

        // If being targeted by smartest or dumbest, take them out
        // Try to go with the rest of the crowd if they both targeted me
        if(targetedBySmart ^ targetedByDumb){
            return targetedBySmart ? smartOpp : dumbOpp;
        } else if (targetedBySmart && targetedByDumb){
            if (votesAgainstSmart > votesAgainstDumb){
                return smartOpp;
            } else if (votesAgainstDumb > votesAgainstSmart){
                return dumbOpp;
            }
        }

        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_stpd=0;
        while(opps.hasNext()){
            int opp_smrt = opps.next().intValue();
            if(opp_smrt < me){
                cnt_stpd++;
            }
        }

        if (cnt_stpd < 2 || (currentOpponents.size() < 4)){ //buffer is small, protect myself
            return smartOpp;
        } else {
            return dumbOpp;
        }
    }
}

MiddleMan
The MiddleMan trys his best to maximize profits while keeping a wary eye that he's not cut from the game. He keeps around lesser contestants to improve his chance of making it to the next round (and to leave an easy finish). He will vote off someone smarter than him only if there are more smarter contestants than there are lesser contestants. Whichever of the two groups, he always votes for the lowest of the group to keep the pot climbing.
package WeakestLink.Players;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
public class MiddleMan extends Player {
    @Override
    public int vote(Set<Integer> currentOpponents) {
        int smrt = getSmartness();

        //count number of players smarter/stupider than me
        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_smrt=0, cnt_stpd=0, opp_smrt, min_stpd=9, min_smrt=9;

        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(opp_smrt > smrt){
                cnt_smrt++;
                if(opp_smrt < min_smrt) min_smrt = opp_smrt;
            }
            else if(opp_smrt < smrt){
                cnt_stpd++;
                if(opp_smrt < min_stpd) min_stpd = opp_smrt;
            }
        }

        //Keep myself in the middle of the pack, favoring the point earners
        if(cnt_stpd>cnt_smrt)
            return min_stpd;
        else
            return min_smrt;
    }
}

P.S. hope it compiles, I'm not a Java guy.
Had this scheme in mind before reading the other entries. Then I was surprised how close (but critically different) Sniper was so I went ahead and used that as a jumping off point since I don't know Java syntax. Thanks @Linus

Please test your code. don't try to write answers in languages you do not know

@TanMath - Thanks for your input. I have much experience in C/Java-like languages, however not Java specifically, so I'm quite confident that my code is in fact correct and will work. That being said, if there is an error in it and it won't run I wont be offended if the game master disqualifies the entry.

You're right. Thanks @Linus. Edited.

@tbernard I'm happy to fix bugs, but your code didn't have any :)

Ouch. Didn't do as well as I'd hoped. I did seem to help out sniper though, so that's something I guess haha.

IndependentVoter
This bot knows that the general population is always wrong! So it votes for whoever is getting the least votes.
Code is nearly Identical to SolarAaron's "Bandwagon", but the end logic is flipped.
package WeakestLink.Players;

import WeakestLink.Game.Vote;
import java.util.Map;
import java.util.Set;

/**
 * Votes for the currently lest voted bot in the game.
 * Or the lowest one.
 */
public class IndependentVoter
        extends Player {

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int self = getSmartness(), vote = -1;
        java.util.Map<Integer, Integer> votes = new java.util.TreeMap<>();
        getVotingHistory().stream().map((Vote v)-> v.getVoted()).filter((Integer i)-> !i.equals(self)).forEach((Integer tgt)-> {
            if(!votes.containsKey(tgt)) {
                votes.put(tgt, 1);
            } else {
                votes.put(tgt, votes.get(tgt) + 1);
            }
        });

        do {
            if(votes.entrySet().isEmpty()) {
                vote = currentOpponents.stream().filter((Integer i)-> !i.equals(self)).sorted().findFirst().get();
            } else {
                if(votes.containsKey(vote)) {
                    votes.remove(vote);
                    vote = -1;
                }

                for(Map.Entry<Integer, Integer> vv: votes.entrySet()) {
                    Integer key = vv.getKey();
                    Integer value = vv.getValue();

                    if((vote == -1) || (value < votes.get(vote))) {
                        vote = key;
                    }
                }
            }
        } while(!currentOpponents.contains(vote));

        return vote;
    }
}

SniperAide
Before the addition of PrudentSniper I wrote a bot to help Sniper beat AntiExtremist and other frauds (I use the word with love). The bot, SniperAide, looks for players who vote like snipers and votes as it thinks they would when there is a consensuses. If all players look like snipers he votes for the max, protecting lower Snipers (who would also switch to the max at this point), even if it is himself.
The Code:
package WeakestLink.Players;
import WeakestLink.Game.Vote;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;

public class SniperAide extends Player {
    boolean[] sniperish;
    int[] sniperwouldvote;

    @Override
    public int vote(Set<Integer> currentOpponents) {
        int smrt = getSmartness();
        if(sniperish==null){
            sniperish = new boolean[10];
            sniperwouldvote = new int[10];
            for(int i=10;--i!=0;){
                sniperish[i] = true;
                sniperwouldvote[i] = 1;
            }
            sniperish[smrt]=false; //knows we are not the sniper
            return 1;
        }
        //figure out who might isn't a sniper
        Vote opp_vote;
        int opp_smrt;
        Iterator<Vote> votes = getRecentVotes().iterator();
        while(votes.hasNext()){
            opp_vote = votes.next();
            opp_smrt = opp_vote.getVoter();
            if(opp_vote.getVoted() != sniperwouldvote[opp_smrt])
                sniperish[opp_smrt] = false;
        }
        //include ourself in the simulation of other snipers.
        currentOpponents.add(smrt);
        //figure out how snipers would vote this round
        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_snpr=0, cnt_opp=0, min_opp=10, max_opp=0;
        int[] snpr_votes = new int[10];
        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(smrt == opp_smrt) continue;
            sniperwouldvote[opp_smrt] = hypothetically(opp_smrt, currentOpponents);
            cnt_opp++;
            if(sniperish[opp_smrt]){
                cnt_snpr++;
                snpr_votes[sniperwouldvote[opp_smrt]]++;
            }
            if(opp_smrt<min_opp) min_opp=opp_smrt;
            if(opp_smrt>max_opp) max_opp=opp_smrt;
        }
        //figure out how to vote in sniper's intrest when not identified
        if(cnt_snpr == cnt_opp)
            return max_opp;
        if(cnt_snpr == 0)
            return hypothetically(smrt, currentOpponents);
        //if multiple hypothetical snipers only vote how they agree
        int onlyvote = -1;
        for(int i=10; --i!=0;){
            if(onlyvote>0 && snpr_votes[i]!=0) onlyvote=-2;
            if(onlyvote==-1 && snpr_votes[i]!=0) onlyvote=i;
        }
        if(onlyvote>0) return onlyvote;
        return max_opp;
    }

    private int hypothetically(int smrt, Set<Integer> currentOpponents) {
        Iterator<Integer> opps = currentOpponents.iterator();
        int cnt_smrt=0, cnt_stpd=0, opp_smrt, min_stpd=10, max_smrt=0;
        while(opps.hasNext()){
            opp_smrt = opps.next().intValue();
            if(opp_smrt > smrt){
                cnt_smrt++;
                if(opp_smrt > max_smrt) max_smrt = opp_smrt;
            }
            else if(opp_smrt < smrt){
                cnt_stpd++;
                if(opp_smrt < min_stpd) min_stpd = opp_smrt;
            }
        }
        if(cnt_stpd>1) return min_stpd;
        return max_smrt;
    }
}

He currently is not much help against PrudentSniper.

Based on your description and theory I don't see how this would help any sniper-like bot beat any other snipers.. if anything wouldn't it just protect all snipers?  Sorry I don't have more time to dig into your code and really understand it for myself.

@csga5000, Since you may rarely identify Sniper by voting record now it does protect them all a little bit. But when a difference is clear it always acts in the Snipers interest, so it mostly a kind of tie-breaker. The focus on winning is macroscopic games, not individual rounds, in most rounds it really can't do anything more than maintain the coin-flip situation.

Anarchist
The anarchist doesn't like regimes.
The anarchist will try to kill the current president.
If the anarchist is president, he decides to abuse his power and kill useless peagents. Unless he was targeted by one of his inferiors, for they should burn instead.
package WeakestLink.Players;

import WeakestLink.Game.Vote;

import java.util.LinkedList;
import java.util.Set;

public class Anarchist extends Player {

    LinkedList<Integer> opponents;

    @Override
    public int vote(Set<Integer> currentOpponents) {
        opponents = new LinkedList();
        opponents.addAll(currentOpponents);
        opponents.sort(Integer::compare);

        int me = getSmartness();

        if (getPresident() != me) {
            return getPresident();
        } else {
            // treason ?
            Vote voteForMe = getRecentVotes().stream().filter(v -> v.getVoted() == me).findAny().orElse(null);
            if (voteForMe == null) {
                // No treason ! Hurray. Kill the peagants.
                return getPeagant();
            } else {
                // TREASON!
                return opponents.get(opponents.indexOf(voteForMe.getVoter()));
            }
        }
    }

    private int getPresident() {
        return opponents.getLast();
    }

    private int getPeagant() {
        return opponents.getFirst();
    }

}

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