Jump to content
BrainDen.com - Brain Teasers
  • 0


unreality
 Share

Question

Here's the challenge: write a little code snippet in java or just generic pseudocode or even just describe your algorithm (you don't even have to know programming, I can just convert your algorithm for you!) that plays ROCK PAPER SCISSORS against an enemy... that enemy is another algorithm!

THE GAME

We all know the game rock paper scissors could use a little strategy... sure there is some psychological merit to it, but most of it is luck. Well, that's about to change.... you will create a deterministic algorithm that will battle against other algorithms for the ultimate title of ROCK PAPER SCISSORS CHAMPION!!! There will be no randomness functions, no chance, no luck. It's about skill. Is your algorithm a simple numerical ninja? Or is it a complex meta-algorithm that attempts to counterguess the enemy's strategy? MAY THE BEST ALGORITHM WIN!!!!!

TECHNICAL SPECS

Your algorithm has access to three different inputs: it has an array of all the moves its used previously. This array is called a. There is another array, b, that contains the moves used by the enemy in this match. You also have a variable, i, that denotes the round number (i=0 is the first round, i=1 is the next round, then i=2, etc).

Right now I have the global var numRounds set to 50. Ie, there will be 50 rounds before we see whose won more games. Let me know if you think that number should be something else.

0 = ROCK

1 = PAPER

2 = SCISSORS

[rock beats scissors, scissors beats paper, paper beats rock]

the arrays a & b are of the datatype int and hold zeroes, ones and twos up to a or b. a and all values after that in the array is NULL, same with b. So the array is only defined from a[0] to a[i-1] or equivalent for b.

For the very first round, i=0, there will be nothing in the arrays. So if your algorithm uses previous data to make future decisions, you'll need to have some primer value for i=0

For anyone interested, here is my java code that runs all this:



// ROCK PAPER SCISSORS CONTEST FOR BRAINDEN

//  BY UNREALITY

//    ENJOY

import java.util.Scanner;

public class ropasc

{

    public static int numGames = 50;

// rock: 0

// paper: 1

// scissors: 2


    private int[] myTurns; private String myName;



    public ropasc(String name)

    {

        myName = name;

        myTurns = new int[numGames];

    }


    public int[] get()

    {

        return myTurns;

    }


    public String getName()

    {

        return myName;

    }


    public int next(int[] enemy, int i)

    {

        int x=0;

        if (myName=="Test1") x = test1(myTurns, enemy, i);

        if (myName=="Test2") x = test2(myTurns, enemy, i);

        if (myName=="Test3") x = test3(myTurns, enemy, i);

        // etc. Could use "java.lang.reflect.*" to do this more elegantly but this way is simpler

        myTurns[i] = x;

        return x;

    }


    public int test1(int[] a, int[] b, int i)

    {

        if (i==0) return 2;

        return b[i-1];

    }


    public int test2(int[] a, int[] b, int i)

    {

        return i % 3;

    }


    public int test3(int[] a, int[] b, int i)

    {

        int sum = 0;

        for (int z=0; z<i; z++)

        {

            sum += (a[z] + b[z]);

        }

        sum %= 3;

        return sum;

    }


    public static String conv(int k)

    {

            if (k==0) return "ROCK";

            if (k==1) return "PAPER";

            if (k==2) return "SCISSORS";

            return "";

    }


    public static void main(String[] args)

    {


        String na = "", nb = "";

     /*   String na = "Test1"; // these two lines

        String nb = "Test2"; // will be the only ones changed to switch who is fighting whom */

        // how about, instead get user input?

        Scanner inp = new Scanner(System.in);

        System.out.print("\n\nFirst Algorithm: ");

        na = inp.next();

        System.out.print("\nSecond Algorithm: ");

        nb = inp.next();


        System.out.print(na + " vs " + nb + "\n\n");

        ropasc rps1 = new ropasc(na);

        ropasc rps2 = new ropasc(nb);

        int res1 = 0, res2 = 0, win1 = 0, win2 = 0, result = 2;

        for (int i=0; i< numGames; i++)

        {

            res1 = rps1.next(rps2.get(), i);

            res2 = rps2.next(rps1.get(), i);

            result = (2+res1+res2) % 3;

            if (result==1) win2++;

            if (result==0) win1++;

            System.out.println(conv(res1) + " vs " + conv(res2));

        }

        String zprint ="";

        if (win1>win2) zprint = rps1.getName() + " wins " + win1 + " games to " + win2 + "!!!\n";

        if (win1<win2) zprint = rps2.getName() + " wins " + win2 + " games to " + win1 + "!!!\n";

        if (win1==win2) { zprint = "Both players won " + win1 + " games! The match was a tie\n"; } else { zprint += "There were " + (numGames - win1 - win2) + " ties\n"; }

        System.out.print(zprint);

    }

}

New entrants will be like this:

public int nameOfAlgorithmint[] a, int[] b, int i)

{

// body here

}

and will be inserted into the program after the algorithm method for test3

All algorithms must return one of these three integers: 0 (ROCK), 1 (PAPER), 2 (SCISSORS)!!!

good luck and post here with remarks, questions, etc.... let's get a signup list?

1) Unreality

2) ...

should we shoot for eight people?

REMEMBER YOU DONT NEED TO KNOW PROGRAMMING... you just need to make a killer algorithm that's a whiz at R/P/S :) I can write the actual code for it for you if you want!

Link to comment
Share on other sites

  • Answers 257
  • Created
  • Last Reply

Top Posters For This Question

Recommended Posts

  • 0

Sorry guys for the inactivity, but I just don't seem to be able to come up with a good algorithm. I'm actually surprised that my original algo is doing quite well out there vs your algo's which sound pretty complex....

Anyways, Merry Christmas everybody... See y'all later!

Link to comment
Share on other sites

  • 0

yeah the good thing about this r/p/s thing is that it doesn't require lots of activity :thumbsup:

And btw I tweaked the code again a bit, making my "rank in order of greatest to least" thing more efficient as well as adding some more info that the analysis gives you ("biggest blowout")


// RPS by Unreality

// for Brainden


import java.util.Scanner;

import java.util.ArrayList;

import java.util.Vector;

import java.util.Random; // for use only in the "rand" test program!

public class rps

{


public static final int ROCK = 0;

public static final int PAPER = 1;

public static final int SCISSORS = 2;

public static final int ROUNDS = 50;


   public static int rpsgo(int algoNum, int i, int[] a, int[] b)

   {

        if (algoNum==0) // hawk

        {

            if (i==0) return (int)Math.pow(2,21) % 3;

            int[] num = new int[3];

            for (int z=0; z<i; z++) { num[b[z]]++; }

            int x=0;

            if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

            if (num[2] > num[x]) x = 2;

            return (x+1)%3;

        }

        else if (algoNum==1) // test1

        {

            if (i==0) return SCISSORS;

            return b[i-1];

        }

        else if (algoNum==2) // test2

        {

            return i % 3;

        }

        else if (algoNum==3) // test3

        {

            int sum = 0;

            for (int z=0; z<i; z++)

            {

                sum += (a[z] + b[z]);

            }

            sum %= 3;

            return sum;

        }

        else if (algoNum==4) // izzy

        {

            // use sci until sci loses; if sci loses at i=0, discard and use sci again til sci loses

            // then use pap til pap loses

            // then rock til rock loses

            // then do whatever beats what they've used most

            if (i==0 || (i==1 && b[0]==0)) return SCISSORS;


            boolean lostWithRock = false;

            search: for (int z=0; z<i; z++) { if (a[z]==0 && b[z]==1) { lostWithRock = true; break search; } }

            if (lostWithRock)

            {

                // do what beats what they've done most

                int[] num = new int[3];

                for (int y=0; y<i; y++) { num[b[y]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else

            {

                // do what won last time, or, if lost last time, advance one from sci -> pap -> rock (2 -> 1 -> 0)

                return a[i-1] - (((a[i-1] - b[i-1] + 3) % 3) / 2);

            }

        }

        else if (algoNum==5) // phil

        {

            if (i==0) return PAPER;

            int[] c = new int[i*3];

            int y = 0;

            for (int z=0; z<i; z++)

            {

                if (b[z]==0) { c[y] = 1; c[y+1] = 2; y+= 2; }

                if (b[z]==1) { c[y] = 1; c[y+1] = 0; c[y+2] = 2; y+= 3; }

                if (b[z]==2) { c[y] = 0; y++; }

            }

            return c[i+1];

        }

        else if (algoNum==6) // backatyou

        {

            int myWins = 0;

            int hisWins = 0;


            int[] hisWinMoves = new int[3];

            int[] hisLoseMoves = new int[3];

            int[] hisTieMoves = new int[3];


            for(int j = 0; j < i; j++) {

                int myMove = a[j];

                int hisMove = b[j];

                if(myMove == ROCK && hisMove == SCISSORS ||

                        myMove == SCISSORS && hisMove == PAPER ||

                        myMove == PAPER && hisMove == ROCK)

                        myWins++;

                if(hisMove == ROCK && myMove == SCISSORS ||

                        hisMove == SCISSORS && myMove == PAPER ||

                        hisMove == PAPER && myMove == ROCK)

                        hisWins++;

                if(hisWins > myWins) {

                        hisWinMoves[hisMove]++;

                } else if(myWins > hisWins) {

                        hisLoseMoves[hisMove]++;

                } else {

                        hisTieMoves[hisMove]++;

                }

        }



            int[] myPick = null;

            if (hisWins > myWins)  myPick = hisWinMoves;

            else if (myWins > hisWins) myPick = hisLoseMoves;

            else myPick = hisTieMoves;

            int max = ROCK;

            if(myPick[PAPER] > myPick[ROCK])

            {

                max = PAPER;

                if(myPick[SCISSORS] > myPick[PAPER]) max = SCISSORS;

            } 

            else if(myPick[SCISSORS] > myPick[ROCK]) max = SCISSORS;


            int move;

                if(max == ROCK)

                     move = PAPER;

                else if(max == PAPER)

                     move = SCISSORS;

                else

                     move = ROCK;

                return(move);

        }

        else if (algoNum==7) // dnoob

        {

            if (i==0) return ROCK;

            int n = i;

            int numsub = 0;

            int fib = 0;

            int fibc = 1;

            int temp;

            while (n - fibc >= 0)

            {

                n -= fibc; numsub++;

                temp = fibc;

                fibc += fib;

                fib = temp;


            }


            int x = ROCK;

            if (i%2 == 1)

            {

                // borrowing some code from hawk here...

                int[] num = new int[3];

                for (int z=0; z<i; z++) { num[b[z]]++; }

                if (num[ROCK] > num[1]) { x = ROCK ; } else if (num[PAPER] > num[ROCK]) { x = PAPER ; } else { x = num[x] % 2 ; /*pseudorandom if tie*/ }

                if (num[SCISSORS] > num[x]) x = SCISSORS;

            } 

            return (numsub + x) % 3;

        }

        else if (algoNum==8) // rand

        {

            Random rangen = new Random();

            return rangen.nextInt(3);

        }

        else if (algoNum==9) // allrock

        {

            return ROCK;

        }

        else if (algoNum==10) // jarze

        {

           if (i==0) return ROCK;

           return (b[i-1]+1)%3;

        }

        else if (algoNum==11) // medji

        {

            if (i==0) return PAPER;

            if (i<5) return b[i-1];

            int sumi=0; for (int zz=i-5; zz<i; zz++){ sumi += b[zz]; }

            if (sumi%2 == 1)

            {

                int[] num = new int[3];

                for (int z=(i-25 + Math.abs(i-25))/2; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else return b[i-1];

        }

        else if (algoNum==12) // mr apple (pi)

        {

            int[] digsPi = { 3,1,4,1,5, 9,2,6,5,3, 5,8,9,7,9, 3,2,3,8,4, 6,2,6,4,3, 3,8,3,2,7, 9,5,0,2,8, 8,4,1,9,7, 1,6,9,3,9, 9,3,7,5,1 };

            int dig = digsPi[i];

            if (dig > 0 && dig < 4) return dig-1;

            else if (dig==4)

            {

                // opp's most move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return x;

            }

            else if (dig==5 || dig==6)

            {

                // counter opp's most move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else if (dig==7 || dig==8)

            {

                // self's least played move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[a[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 1 ; } else if (num[1] > num[0]) { x = 0 ; } else { x = num[x] % 2 ; }

                if (num[x] > num[2]) x = 2;

                return x;

            }

            else if (dig==9)

            {

                // self's most played move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[a[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return x;

            }

            else if (dig==0)

            {

                // opp's most recent move

                return b[i-1];

            }

            else return -1;

        }

        else if (algoNum==13) // darth1

        {

               int[] achose = {0,0,0};

               int[] bchose = {0,0,0};

               for (int vv=0; vv<i; vv++) { achose[a[vv]]++; bchose[b[vv]]++; }

               int enemy_least = ROCK, me_least = ROCK, enemy_most = ROCK, me_most = ROCK;

               int enemy_times_used_least = 0, me_times_used_least = 0, enemy_times_used_most = 0, me_times_used_most = 0;

               int tiebreaker;


               if (achose[PAPER] > achose[ROCK]) me_most = PAPER;

               if (achose[SCISSORS] > achose[me_most]) me_most = SCISSORS;

               me_times_used_most = achose[me_most]; tiebreaker = me_most;

               if (achose[me_most] == achose[(me_most+1)%3] || achose[me_most] == achose[(me_most+2)%3]) { tiebreaker = -2; // two-way tie

               if (achose[me_most] == achose[(me_most+1)%3] && achose[me_most] == achose[(me_most+2)%3]) tiebreaker = -3; /* three way tie */ }

               me_most = tiebreaker;


               if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

               if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;

               enemy_times_used_most = bchose[enemy_most]; tiebreaker = enemy_most;

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] || bchose[enemy_most] == bchose[(enemy_most+2)%3]) { tiebreaker = -2; // two-way tie

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] && bchose[enemy_most] == bchose[(enemy_most+2)%3]) tiebreaker = -3; /* three way tie */ }

               enemy_most = tiebreaker;


               if (achose[PAPER] < achose[ROCK]) me_least = PAPER;

               if (achose[SCISSORS] < achose[me_least]) me_least = SCISSORS;

               me_times_used_least = achose[me_least]; tiebreaker = me_least;

               if (achose[me_least] == achose[(me_least+1)%3] || achose[me_least] == achose[(me_least+2)%3]) { tiebreaker = -2; // two-way tie

               if (achose[me_least] == achose[(me_least+1)%3] && achose[me_least] == achose[(me_least+2)%3]) tiebreaker = -3; /* three way tie */ }

               me_least = tiebreaker;


               if (bchose[PAPER] < bchose[ROCK]) enemy_least = PAPER;

               if (bchose[SCISSORS] < bchose[enemy_least]) enemy_least = SCISSORS;

               enemy_times_used_least = bchose[enemy_least]; tiebreaker = enemy_least;

               if (bchose[enemy_least] == bchose[(enemy_least+1)%3] || bchose[enemy_least] == bchose[(enemy_least+2)%3]) { tiebreaker = -2; // two-way tie

               if (bchose[enemy_least] == bchose[(enemy_least+1)%3] && bchose[enemy_least] == bchose[(enemy_least+2)%3]) tiebreaker = -3; /* three way tie */ }

               enemy_least = tiebreaker;


               int d = enemy_times_used_most - enemy_times_used_least;


               if (d < 3 || d < i/9)

               {

                    if (enemy_least == -2) { return (enemy_most+2)%3; }

                    else if (enemy_least == -3) { return ((i%3)+1)%3; }

                    else { return (enemy_least+1)%3; }

               }

               else if (enemy_least == -2) { return (enemy_most+1)%3; }

               else { return (enemy_least+2)%3; }

        }

        else if (algoNum==14) // izzy1

        {

            if (i==0) return SCISSORS;

            if ((3 + a[i-1] - b[i-1])%3 == 2) return (a[i-1]+1)%3;

            else if ((3 + a[i-1] - b[i-1])%3 == 1) return a[i-1];

            else if (i > 2 && (3 + a[i-2] - b[i-2])%3 == 0 && (3 + a[i-3] - b[i-3])%3 == 0) return (a[i-1]+1)%3;

            else return a[i-1];

        }

        else if (algoNum==15) // izzy2

        {

            if (i==0) return ROCK;

            if (i<8) return (int)Math.ceil((double)(i%3) / 2.0) * -1 + 2;

            int[] first8 = new int[8];

            for (int tz=0; tz<8; tz++) first8[tz] = b[tz];

            int[][] ariz = { {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {2,2,2,2,2,2,2,2}, {0,1,2,0,1,2,0,1}, {1,2,0,1,2,0,1,2}, {2,0,1,2,0,1,2,0}, {0,2,1,0,2,1,0,2}, {1,0,2,1,0,2,1,0}, {2,1,0,2,1,0,2,1}, {0,1,2,2,0,0,0,1} };

            int patt = -1;

            for (int ty=0; ty<ariz.length; ty++) 

            {

                boolean izfound = true;

                for (int tyy=0; tyy<8; tyy++)  { if (ariz[ty][tyy] != first8[tyy]) { izfound = false; } }

                if (izfound) { patt = ty; }

            }

            if (patt > -1)

            {

                int[] beats;

                if (patt==0) beats = new int[]{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

                else if (patt==1) beats = new int[]{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};

                else if (patt==2) beats = new int[]{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

                else if (patt==3) beats = new int[]{ 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0};

                else if (patt==4) beats = new int[]{ 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1};

                else if (patt==5) beats = new int[]{ 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2};

                else if (patt==6) beats = new int[]{ 1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2};

                else if (patt==7) beats = new int[]{ 2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0};

                else if (patt==8) beats = new int[]{ 0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1};

                else if (patt==9) beats = new int[]{ 1,2,0,0,1,1,1,2,2,2,2,2,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2};


                else beats = new int[]{  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};


                if (i<18) return beats[i-8];

                int winsum=0;

                for (int tx=8; tx<18; tx++) { if ((3 + a[tx] - b[tx])%3 == 1) { winsum++; } }

                if (winsum > 4) return beats[i-8];

            }

            // either no pattern was found or pattern beating was unsuccessful. Resort to final plan

            // ie, the look-and-say sequence

           int[] look_say_sequence = { 1,1,1,2,1,1,2,1,1,1,1,1,2,2,1,0,1,2,2,1,1,1,0,1,1,2,2,2,1,1,1,1,0,2,1,0,2,1,1,0,1,1 };

           return look_say_sequence[i-8];

        }

        else if (algoNum==16) // darth2

        {

            if (i<5) return ROCK;

            if (i%5 == 0)

            {

                int[] runli = new int[i/5];

               for (int qrx=0; qrx< i/5; qrx++)

               {

                   int[] bchose = { 0,0,0 };

                   for (int vv=qrx*5; vv< qrx*5 + 5; vv++) {  bchose[b[vv]]++; }

                   int enemy_most = ROCK;


                   if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

                   if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;


                   if (bchose[enemy_most] == bchose[(enemy_most+1)%3])

                   {

                       int setvv = enemy_most;

                       for (int vvv=qrx*5; vvv< qrx*5+5; vvv++)

                       {

                           if (b[vvv]==enemy_most) setvv = enemy_most;

                           if (b[vvv]==(enemy_most+1)%3) setvv = (enemy_most+1)%3;

                        }

                        enemy_most = setvv;

                   }

                   else if (bchose[enemy_most] == bchose[(enemy_most+2)%3])

                   {

                     int setvv = enemy_most;

                       for (int vvv=qrx*5; vvv< qrx*5+5; vvv++)

                       {

                           if (b[vvv]==enemy_most) setvv = enemy_most;

                           if (b[vvv]==(enemy_most+2)%3) setvv = (enemy_most+2)%3;

                        }

                        enemy_most = setvv;

                   }

                    runli[qrx] = enemy_most;

                }

               // beat most often move from runli; if tie, use most recent of the ones tying

               int[] vchose = {0,0,0};

               for (int vvvv=0; vvvv<runli.length; vvvv++) { vchose[runli[vvvv]]++; }

               int vmost = ROCK;

               if (vchose[PAPER] > vchose[ROCK]) vmost = PAPER;

               if (vchose[SCISSORS] > vchose[vmost]) vmost = SCISSORS;

               if (vchose[vmost] == vchose[(vmost+1)%3] && vchose[vmost] == vchose[(vmost+1)%3]) vmost = runli[runli.length-1];

               else if (vchose[vmost] == vchose[(vmost+1)%3])

                   {

                       int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==vmost) setvv = vmost;

                           if (vbv==(vmost+1)%3) setvv = (vmost+1)%3;

                        }

                        vmost = setvv;

                   }

                   else if (vchose[vmost] == vchose[(vmost+2)%3])

                   {

                     int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==vmost) setvv = vmost;

                           if (vbv==(vmost+2)%3) setvv = (vmost+2)%3;

                        }

                        vmost = setvv;

                   }

                   else if (vchose[(vmost+1)%3] == vchose[(vmost+2)%3])

                   {

                     int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==(vmost+1)%3) setvv = (vmost+1)%3;

                           if (vbv==(vmost+2)%3) setvv = (vmost+2)%3;

                        }

                        vmost = setvv;

                   }

                   return (vmost+1)%3;

            }

            else

            {

                return a[i-1];

            }

        }

        else if (algoNum==17) // darth3

        {

            if (i<7) return (i+1)%3;

            if (b[i-1] == b[i-2] && b[i-2] == b[i-3])

            {

                int firstx=0, secondx=0;

                for (int ghgh=i-7; ghgh<i; ghgh++) { if (a[ghgh]==(b[i-1]+1)%3) { firstx++;} if (a[ghgh]==(b[i-1]+2)%3) { secondx++;} }

                if (firstx > secondx || firstx == secondx) return (b[i-1]+1)%3;

                else return (b[i-1]+2)%3;

            }

            else

            {

                int[] achose = {0,0,0};

                int[] bchose = {0,0,0};

               for (int vv=0; vv<i; vv++) { achose[a[vv]]++; bchose[b[vv]]++; }

               int tiebreaker;

               int me_least = ROCK, enemy_most = ROCK;


               if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

               if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;

               tiebreaker = enemy_most;

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] || bchose[enemy_most] == bchose[(enemy_most+2)%3]) { tiebreaker = -2;  }

               enemy_most = tiebreaker;


               if (achose[PAPER] < achose[ROCK]) me_least = PAPER;

               if (achose[SCISSORS] < achose[me_least]) me_least = SCISSORS;

               tiebreaker = me_least;

               if (achose[me_least] == achose[(me_least+1)%3] || achose[me_least] == achose[(me_least+2)%3]) { tiebreaker = -2;  }

               me_least = tiebreaker;


               if (me_least == -2)

               {

                   if (enemy_most == -2) { return (a[i-1]+2)%3; }

                   else { return (enemy_most+2)%3; }

                }

                else return me_least;


            }

        }

        else if (algoNum==18) // mrapple1

        {

            return (i+1)%3;

        }

        else if (algoNum==19) // medji1

        {

            if (i==0) return SCISSORS;

            if (i%5 != 0) return (a[i-1]+2)%3;

            return (a[i-1]+1)%3;

        }

       else if (algoNum==20) // medji2

        {

            if (i==0) return ROCK;

            if (i%3 != 0) return (a[i-1]+1)%3;

            return (a[i-1]+2)%3;

        }

        else if (algoNum==21) // patternSeeker (dawh)

        {

            if(i == 0)

            return(ROCK);

            int predicted = -1;

            int success = 0;

            Vector<Integer> patt = new Vector<Integer>();

            for(int j = 0; j < i; j++) {

                int move = b[j];

                if(patt.contains(move)) {

                    int idx = patt.indexOf(move)+1;

                    if(idx < patt.size()) {

                        predicted = patt.get(idx);

                    }

                }

                patt.add(move);


                if(j < i-1 && predicted == b[j+1])

                success++;

            }

            if(success > i/2) {

                int move = b[i-1];

                int idx = patt.indexOf(move)+1;

                if(idx > 0 && idx < patt.size())

                    return((patt.get(idx)+1)%3);

                }

                return((b[i-1]+1)%3);

            }

            else if (algoNum==22) // phil1

            {

                if (i==0) return PAPER;

                int[] best = {0,0,0};

                int ties = 0;

                for(int j=0; j<i; j++) {

                    if (a[j] == b[j]) ties += 1;

                    else

                    {

                        if (a[j] == ROCK && b[j] == PAPER) best[0] -= 1;

                        if (a[j] == PAPER && b[j] == SCISSORS) best[1] -= 1;

                        if (a[j] == SCISSORS && b[j] == ROCK) best[2] -= 1;


                        if (a[j] == ROCK && b[j] == SCISSORS) best[0] += 1;

                        if (a[j] == PAPER && b[j] == ROCK) best[1] += 1;

                        if (a[j] == SCISSORS && b[j] == PAPER) best[2] += 1;

                    }

                }


                int xx=ROCK;

                if (best[ROCK] < best[PAPER]) xx=ROCK;

                if (best[xx] < best[SCISSORS]) return SCISSORS;

                else if (best[SCISSORS] == best[xx] || best[ROCK]==best[PAPER]) return ties%3;

                else return xx;

                // end of phil1

            }

            else if (algoNum == 23)// phil2

            { 

                //this algorithm strives for an optimal sequence of moves.

                int index = 0;

                if (i == 0){

                    return ROCK;

                }

                else {

                    int[] array, best;

                    int index1 = 0, index2 = 0, check = 0;

                    int j = 0;

                    array = new int[i];

                    best = new int[3];

                    while (index1 < i && index2 < i){

                        if(check == 0){

                            if((a[index1] == ROCK && b[index2] == ROCK || b[index2] == PAPER)

                            || (a[index1] == PAPER && b[index2] == PAPER || b[index2] == SCISSORS)

                            || (a[index1] == SCISSORS && b[index2] == SCISSORS || b[index2] == ROCK)){

                                check = 1;

                                index2 += 1;

                            }

                            else{

                                check = 2;

                                index1 += 1;

                            }

                        }

                        else if(check == 1){

                            if((a[index1] == ROCK && b[index2] == ROCK || b[index2] == PAPER)

                            || (a[index1] == PAPER && b[index2] == PAPER || b[index2] == SCISSORS)

                            || (a[index1] == SCISSORS && b[index2] == SCISSORS || b[index2] == ROCK)){

                                index2 += 1;

                            }

                            else{

                                for(j = index1; j<index2; j++){

                                    array[j] = b[j];

                                }

                            }

                            check = 0;

                            index1 = index2;

                        }

                        else{

                            if((b[index2] == ROCK && a[index1] == ROCK || a[index1] == PAPER)

                            || (b[index2] == PAPER && a[index1] == PAPER || a[index1] == SCISSORS)

                            || (b[index2] == SCISSORS && a[index1] == SCISSORS || a[index1] == ROCK)){

                                index1 += 1;

                            }

                            else{

                                for(j = index1; j<index2; j++){

                                    array[j] = a[j];

                                }

                                check = 0;

                                index2= index1;

                            }

                        }

                    }

                    if(index1 > index2){

                        for(j = index2; j<index1; j++){

                            array[j] = b[j];

                        }

                    }

                    else{

                        for(j = index1; j<index2; j++){

                            array[j] = a[j];

                        }

                    }

                    for(j = 0; j< i; j++){

                        best[array[j]]++;

                    }

                    int y = ROCK;

                    if(best[ROCK] <best[PAPER]){

                        y = PAPER;

                    }

                    if(best[y] <best[SCISSORS]){

                        return SCISSORS;

                    }

                    else{

                        return y;

                    }

                }

            }

            else if (algoNum==24) //unr1

            {

                if (i==0) return PAPER;

                int yeah = PAPER;

                for (int xh=0; xh<i; xh++)

                {

                    yeah = yeah ^ xh;

                }

                return (yeah%3);

            }

            else if (algoNum==25) //unr2

            {

                if (i<6) return (i+1)%3;

                int[] prev = { b[i-6], b[i-5], b[i-4], b[i-3], b[i-2], b[i-1] };

                int[][] patns = {

                               {0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1},

                               {0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2},

                               {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

                               {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

                               {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},

                               {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},

                               {0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2},

                               {1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}

                            };

                boolean match=false;

                int matchPat = -1, matchIndex = -1;

                yeahloop: for (int iiz=0; iiz<patns.length; iiz++)

                {

                    for (int iiiz=0; iiiz<44; iiiz++)

                    {

                        if (patns[iiz][iiiz] == prev[0] 

                        && patns[iiz][iiiz+1] == prev[1]

                        && patns[iiz][iiiz+2] == prev[2]

                        && patns[iiz][iiiz+3] == prev[3]

                        && patns[iiz][iiiz+4] == prev[4]

                        && patns[iiz][iiiz+5] == prev[5]) { match=true; matchPat = iiz; matchIndex = iiiz+6; }

                    }

                    if (match) break yeahloop;

                }

                if (match)

                {

                    return (patns[matchPat][matchIndex] + 1)%3;

                }

                else

                {

                    int sumt = 0;

                    for (int sumin=0; sumin<i; sumin++) {sumt += b[sumin];}

                    double mean = (double)sumt / (double)i;

                    double sdev = 0.0;

                    for (int sumin=0; sumin<i; sumin++) {sdev += (double)((b[sumin] - mean) * (b[sumin] - mean));}

                    sdev /= (double)i; // divide by i, not i-1, because we have a complete population

                    sdev = Math.sqrt(sdev); // sdev is now the standard deviation of b's moves

                    boolean[] withinOne = {false, false, false};

                    if (0 > mean - sdev && 0 < mean + sdev) withinOne[0] = true;

                    if (1 > mean - sdev && 1 < mean + sdev) withinOne[1] = true;

                    if (2 > mean - sdev && 2 < mean + sdev) withinOne[2] = true;

                    if (withinOne[i%3]) return i%3;

                    else if (withinOne[(i+1)%3]) return (i+1)%3;

                    else return (i+2)%3;

                }


            }

            else if (algoNum==26) //phil3

            {

                int[] best;

                if(i == 0){

                    return ROCK;

                }

                best = new int[3];

                for(int j = 0; j <i; j++){

                    if(a[j] == b[j]){

                        best[a[j]]++;

                    }

                    else if(a[j] == ROCK && b[j] == SCISSORS){

                        best[ROCK]++;

                    }

                    else if(a[j] == PAPER && b[j] == ROCK){

                        best[PAPER]++;

                    }

                    else if(a[j] == SCISSORS && b[j] == PAPER){

                        best[SCISSORS]++;

                    }

                    else if(b[j] == ROCK && a[j] == SCISSORS){

                            best[ROCK]++;

                        }

                        else if(b[j] == PAPER && a[j] == ROCK){

                            best[PAPER]++;

                        }

                        else if(b[j] == SCISSORS && a[j] == PAPER){

                            best[SCISSORS]++;

                        }

                    }

                    int y = ROCK;

                    if(best[ROCK] < best[PAPER]){

                        y = PAPER;

                    }

                    if(best[y] < best[SCISSORS]){

                        return SCISSORS;

                    }

                    else{

                        return y;

                    }

             }

            else if (algoNum==27) //apple3

            {

                int nkk = ((i%6) / 3) * 2;

                if (i%6==0) nkk++;

                nkk += (2 * (i /6));

                return (nkk % 3);

            }

            else if (algoNum==28) //backatyou2

            {

                int[] hisWinMoves = new int[3];

                int[] hisLoseMoves = new int[3];

                int[] hisTieMoves = new int[3];


        int myMove = ROCK, hisMove = ROCK;

        int myWins = 0, hisWins = 0;

        for(int j = 0; j < i-1; j++) {

                myMove = a[j];

                hisMove = b[j];

                if(myMove == ROCK && hisMove == SCISSORS)

                        myWins++;

                else if(myMove == SCISSORS && hisMove == PAPER)

                        myWins++;

                else if(myMove == PAPER && hisMove == ROCK)

                        myWins++;


                if(hisMove == ROCK && myMove == SCISSORS)

                        hisWins++;

                else if(hisMove == SCISSORS && myMove == PAPER)

                        hisWins++;

                else if(hisMove == PAPER && myMove == ROCK)

                        hisWins++;


                if(hisWins > myWins) {

                        hisWinMoves[hisMove]++;

                } else if(myWins > hisWins) {

                        hisLoseMoves[hisMove]++;

                } else {

                        hisTieMoves[hisMove]++;

                }

        }


        int[] myPick;

        if(hisWins > myWins) {

                myPick = hisWinMoves;

        } else if(myWins > hisWins) {

                myPick = hisLoseMoves;

        } else {

                myPick = hisTieMoves;

        }

        int max;

        if(i % 2 == 0) {

                max =  ROCK;

                if(myPick[PAPER] > myPick[ROCK]) {

                        max = PAPER;

                        if(myPick[SCISSORS] > myPick[PAPER])

                                max = SCISSORS;

                } else if(myPick[SCISSORS] > myPick[ROCK])

                        max = SCISSORS;

        } else

                max = hisMove;

        int move;

        if(max == ROCK)

                move = PAPER;

        else if(max == PAPER)

                move = SCISSORS;

        else 

                move = ROCK;

        return(move);

            }

            // else if (algoNum==29)

            else return ROCK;

        //return ROCK;

    }


    public static String conv(int yeah)

    {

        if (yeah==ROCK) return "  rock  ";

        if (yeah==PAPER) return " paper  ";

        if (yeah==SCISSORS) return "scissors";

        return "you've got a problem";

    }


   public static void main(String[] args)

   {

       String[] names = { "hawk", "test1", "test2", "test3", "izzy", "phil", "backatyou", "dnoob", "rand", "allrock", "jarze", "medji" , "mr_apple_pi", "darth1", "izzy1", "izzy2", "darth2", "darth3", "mrapple1", "medji1", "medji2", "patternSeeker", "phil1", "phil2", "unr1", "unr2", "phil3", "apple3", "backatyou2" };


       boolean ohyeah = true;

       while (ohyeah)

    {

        Scanner inp = new Scanner(System.in);

       System.out.println("\n\nWelcome to R/P/S!");

       for (int j=0; j<names.length; j++) { System.out.println(j + " (" + names[j] + ")");}

       System.out.print("\n\nEnter the numbers of the programs you wish to fight, separated by spaces:\n");

       String nextln = inp.nextLine();

       int[] algos;

       if (nextln.equals("x"))

       {

           algos = new int[]{ 2, 4, 14, 15, 10, 11, 19, 20, 12, 18, 27, 13, 16, 17, 21, 28, 24, 25, 5, 22, 23 };

        }

        else

        {

       String[] splitup = nextln.split(" ");

       algos = new int[splitup.length];

       for (int hjk=0; hjk<splitup.length; hjk++) { algos[hjk] = Integer.parseInt(splitup[hjk]); }

      }


            String financ = "";

            int n = algos.length;  double[] nw = new double[n];

            //int numGames = n/2 * (n - 1);

            /* some data collection */ int curspread = 0; String spreadmsg = "All games had a spread of zero, weird!";

            for (int nn=0; nn<n; nn++)

            {

                for (int nnn = nn+1; nnn<n; nnn++)

                {

                    // game between algos[nn] and algos[nnn]

                    int algo1 = algos[nn]; int algo2 = algos[nnn];


                    System.out.print("\n\n"+names[algo1]+" vs "+names[algo2]+"\n");


                   int[] ar1 = new int[ROUNDS];

                   int[] ar2 = new int[ROUNDS];


                   int[] wins = new int[ROUNDS];


                   for (int k=0; k<ROUNDS; k++)

                   {

                           ar1[k] = rpsgo(algo1, k, ar1, ar2);

                           ar2[k] = rpsgo(algo2, k, ar2, ar1);

                           wins[k] = ( 3 + ar1[k] - ar2[k] ) % 3;

                           // 0 -> tie

                           // 1 -> one wins

                           // 2 -> two wins

                   }


                   int oneWins=0; int twoWins=0;

                   for (int l=0; l<ROUNDS; l++)

                   {

                       System.out.println(conv(ar1[l]) + " vs " + conv(ar2[l]));

                       if (wins[l]==1) { oneWins++; }

                       if (wins[l]==2) { twoWins++; }

                    }

                    int ties = ROUNDS - oneWins - twoWins; String msg1, msg2;

                    if (oneWins > twoWins + 1) { msg2 = names[algo1]+" wins!!!"; nw[nn]++; }

                    else if (twoWins > oneWins + 1) { msg2 = names[algo2]+" wins!!!"; nw[nnn]++; }

                    else { msg2 = "It was a tie!!!"; nw[nn] += 0.5; nw[nnn] += 0.5; }

                    msg1 = "\n"+names[algo1]+" won "+oneWins+" games and "+names[algo2]+" won " +twoWins+ " ~ there were " + ties + " ties";

                    System.out.println(msg1);

                    System.out.println(msg2);

                    financ += (names[algo1]+" vs "+names[algo2] + ": " + msg2 + "\n");

                    if (Math.abs(oneWins - twoWins) > curspread) { curspread = Math.abs(oneWins - twoWins); spreadmsg = msg1; }

                }

            }

            System.out.print("\n\nFinal Results:\n" + financ + "\n\nWin Count:\n");

            for (int abc=0; abc<n; abc++) System.out.println(names[algos[abc]]+": "+nw[abc]);


            System.out.print("\n\nType y for analysis ");

            if (inp.next().toLowerCase().charAt(0) == 'y')

            {

                double nm = (double)(n-1) / 2.0;

                double sdv = 0.0, mad = 0.0;

                for (int suminx=0; suminx<nw.length; suminx++) {sdv += ((double)((nw[suminx] - nm) * (nw[suminx] - nm))); mad += (double)Math.abs(nw[suminx] - nm);}

                sdv /= (double)(nw.length); mad /= (double)(nw.length);

                sdv = Math.sqrt(sdv);

                System.out.printf("%n%n[Algos: %d] [Games: %d] [Average Score: %.1f] [Sdev: %.3f] [MAD: %.3f]",n, (n*(n-1)) / 2, nm, sdv, mad);

                /* now present in order */ System.out.print("\n\nFrom Greatest to Least:\n");


               int[] nw_o = new int[nw.length]; boolean[] jk = new boolean[nw.length]; int ngr;

               for (int nnhz=0; nnhz<nw.length; nnhz++) jk[nnhz] = true;

               for (int nnh=0; nnh<nw.length; nnh++)

               {

                   ngr=0;

                   nhlp: for (int nindx=0; nindx<nw.length; nindx++)

                   {

                       if (jk[nindx]) { ngr=nindx; break nhlp; }

                    }

                   for (int nind=ngr; nind<nw.length; nind++)

                   {

                       if (nw[nind] > nw[ngr] && jk[nind]) { ngr = nind; }

                    }

                    nw_o[nnh]=ngr; jk[ngr] = false;

                }

                for (int nnhx=0; nnhx<nw.length; nnhx++) System.out.println(names[algos[nw_o[nnhx]]]+": "+nw[nw_o[nnhx]]);

                System.out.println("\nThe biggest blowout game was: " + spreadmsg);

            }


            System.out.print("\n\nType y to play again ");

            ohyeah = false;

            if (inp.next().toLowerCase().charAt(0) == 'y') ohyeah = true;

        }

        System.out.print("\nThanks for playing!\n");

    }


}


so do you guys think we should have an Ultimate T3 where everyone submits exactly one algorithm to battle the masses?

Link to comment
Share on other sites

  • 0

I tweaked the analysis some more and also fixed all the programs so that they could be expanded to 100+ rounds. Then I set ROUNDS to be 100. Here are the results:

Final Results:

test2 vs izzy: test2 wins!!!

test2 vs izzy1: test2 wins!!!

test2 vs izzy2: izzy2 wins!!!

test2 vs jarze: It was a tie!!!

test2 vs medji: test2 wins!!!

test2 vs medji1: It was a tie!!!

test2 vs medji2: It was a tie!!!

test2 vs mr_apple_pi: test2 wins!!!

test2 vs mrapple1: mrapple1 wins!!!

test2 vs apple3: apple3 wins!!!

test2 vs darth1: darth1 wins!!!

test2 vs darth2: test2 wins!!!

test2 vs darth3: darth3 wins!!!

test2 vs patternSeeker: patternSeeker wins!!!

test2 vs backatyou2: test2 wins!!!

test2 vs unr1: test2 wins!!!

test2 vs unr2: unr2 wins!!!

test2 vs phil: test2 wins!!!

test2 vs phil1: It was a tie!!!

test2 vs phil2: It was a tie!!!

izzy vs izzy1: izzy wins!!!

izzy vs izzy2: izzy wins!!!

izzy vs jarze: jarze wins!!!

izzy vs medji: It was a tie!!!

izzy vs medji1: medji1 wins!!!

izzy vs medji2: medji2 wins!!!

izzy vs mr_apple_pi: mr_apple_pi wins!!!

izzy vs mrapple1: mrapple1 wins!!!

izzy vs apple3: apple3 wins!!!

izzy vs darth1: darth1 wins!!!

izzy vs darth2: darth2 wins!!!

izzy vs darth3: izzy wins!!!

izzy vs patternSeeker: patternSeeker wins!!!

izzy vs backatyou2: backatyou2 wins!!!

izzy vs unr1: unr1 wins!!!

izzy vs unr2: unr2 wins!!!

izzy vs phil: izzy wins!!!

izzy vs phil1: izzy wins!!!

izzy vs phil2: izzy wins!!!

izzy1 vs izzy2: izzy2 wins!!!

izzy1 vs jarze: jarze wins!!!

izzy1 vs medji: izzy1 wins!!!

izzy1 vs medji1: medji1 wins!!!

izzy1 vs medji2: medji2 wins!!!

izzy1 vs mr_apple_pi: izzy1 wins!!!

izzy1 vs mrapple1: mrapple1 wins!!!

izzy1 vs apple3: izzy1 wins!!!

izzy1 vs darth1: izzy1 wins!!!

izzy1 vs darth2: izzy1 wins!!!

izzy1 vs darth3: izzy1 wins!!!

izzy1 vs patternSeeker: patternSeeker wins!!!

izzy1 vs backatyou2: backatyou2 wins!!!

izzy1 vs unr1: unr1 wins!!!

izzy1 vs unr2: izzy1 wins!!!

izzy1 vs phil: izzy1 wins!!!

izzy1 vs phil1: izzy1 wins!!!

izzy1 vs phil2: izzy1 wins!!!

izzy2 vs jarze: izzy2 wins!!!

izzy2 vs medji: medji wins!!!

izzy2 vs medji1: It was a tie!!!

izzy2 vs medji2: izzy2 wins!!!

izzy2 vs mr_apple_pi: mr_apple_pi wins!!!

izzy2 vs mrapple1: mrapple1 wins!!!

izzy2 vs apple3: apple3 wins!!!

izzy2 vs darth1: darth1 wins!!!

izzy2 vs darth2: darth2 wins!!!

izzy2 vs darth3: izzy2 wins!!!

izzy2 vs patternSeeker: patternSeeker wins!!!

izzy2 vs backatyou2: It was a tie!!!

izzy2 vs unr1: izzy2 wins!!!

izzy2 vs unr2: izzy2 wins!!!

izzy2 vs phil: izzy2 wins!!!

izzy2 vs phil1: phil1 wins!!!

izzy2 vs phil2: izzy2 wins!!!

jarze vs medji: jarze wins!!!

jarze vs medji1: medji1 wins!!!

jarze vs medji2: medji2 wins!!!

jarze vs mr_apple_pi: jarze wins!!!

jarze vs mrapple1: It was a tie!!!

jarze vs apple3: jarze wins!!!

jarze vs darth1: jarze wins!!!

jarze vs darth2: jarze wins!!!

jarze vs darth3: jarze wins!!!

jarze vs patternSeeker: patternSeeker wins!!!

jarze vs backatyou2: jarze wins!!!

jarze vs unr1: unr1 wins!!!

jarze vs unr2: jarze wins!!!

jarze vs phil: phil wins!!!

jarze vs phil1: It was a tie!!!

jarze vs phil2: jarze wins!!!

medji vs medji1: medji wins!!!

medji vs medji2: medji2 wins!!!

medji vs mr_apple_pi: medji wins!!!

medji vs mrapple1: mrapple1 wins!!!

medji vs apple3: apple3 wins!!!

medji vs darth1: medji wins!!!

medji vs darth2: It was a tie!!!

medji vs darth3: medji wins!!!

medji vs patternSeeker: patternSeeker wins!!!

medji vs backatyou2: backatyou2 wins!!!

medji vs unr1: medji wins!!!

medji vs unr2: medji wins!!!

medji vs phil: medji wins!!!

medji vs phil1: It was a tie!!!

medji vs phil2: It was a tie!!!

medji1 vs medji2: It was a tie!!!

medji1 vs mr_apple_pi: medji1 wins!!!

medji1 vs mrapple1: It was a tie!!!

medji1 vs apple3: medji1 wins!!!

medji1 vs darth1: darth1 wins!!!

medji1 vs darth2: darth2 wins!!!

medji1 vs darth3: darth3 wins!!!

medji1 vs patternSeeker: patternSeeker wins!!!

medji1 vs backatyou2: backatyou2 wins!!!

medji1 vs unr1: medji1 wins!!!

medji1 vs unr2: medji1 wins!!!

medji1 vs phil: medji1 wins!!!

medji1 vs phil1: medji1 wins!!!

medji1 vs phil2: It was a tie!!!

medji2 vs mr_apple_pi: medji2 wins!!!

medji2 vs mrapple1: It was a tie!!!

medji2 vs apple3: apple3 wins!!!

medji2 vs darth1: darth1 wins!!!

medji2 vs darth2: medji2 wins!!!

medji2 vs darth3: darth3 wins!!!

medji2 vs patternSeeker: medji2 wins!!!

medji2 vs backatyou2: backatyou2 wins!!!

medji2 vs unr1: medji2 wins!!!

medji2 vs unr2: unr2 wins!!!

medji2 vs phil: phil wins!!!

medji2 vs phil1: medji2 wins!!!

medji2 vs phil2: It was a tie!!!

mr_apple_pi vs mrapple1: mrapple1 wins!!!

mr_apple_pi vs apple3: mr_apple_pi wins!!!

mr_apple_pi vs darth1: darth1 wins!!!

mr_apple_pi vs darth2: It was a tie!!!

mr_apple_pi vs darth3: mr_apple_pi wins!!!

mr_apple_pi vs patternSeeker: patternSeeker wins!!!

mr_apple_pi vs backatyou2: backatyou2 wins!!!

mr_apple_pi vs unr1: unr1 wins!!!

mr_apple_pi vs unr2: mr_apple_pi wins!!!

mr_apple_pi vs phil: mr_apple_pi wins!!!

mr_apple_pi vs phil1: mr_apple_pi wins!!!

mr_apple_pi vs phil2: mr_apple_pi wins!!!

mrapple1 vs apple3: It was a tie!!!

mrapple1 vs darth1: darth1 wins!!!

mrapple1 vs darth2: mrapple1 wins!!!

mrapple1 vs darth3: It was a tie!!!

mrapple1 vs patternSeeker: patternSeeker wins!!!

mrapple1 vs backatyou2: mrapple1 wins!!!

mrapple1 vs unr1: It was a tie!!!

mrapple1 vs unr2: unr2 wins!!!

mrapple1 vs phil: It was a tie!!!

mrapple1 vs phil1: It was a tie!!!

mrapple1 vs phil2: It was a tie!!!

apple3 vs darth1: darth1 wins!!!

apple3 vs darth2: apple3 wins!!!

apple3 vs darth3: darth3 wins!!!

apple3 vs patternSeeker: patternSeeker wins!!!

apple3 vs backatyou2: backatyou2 wins!!!

apple3 vs unr1: apple3 wins!!!

apple3 vs unr2: It was a tie!!!

apple3 vs phil: phil wins!!!

apple3 vs phil1: apple3 wins!!!

apple3 vs phil2: phil2 wins!!!

darth1 vs darth2: darth1 wins!!!

darth1 vs darth3: darth1 wins!!!

darth1 vs patternSeeker: patternSeeker wins!!!

darth1 vs backatyou2: backatyou2 wins!!!

darth1 vs unr1: darth1 wins!!!

darth1 vs unr2: darth1 wins!!!

darth1 vs phil: darth1 wins!!!

darth1 vs phil1: darth1 wins!!!

darth1 vs phil2: darth1 wins!!!

darth2 vs darth3: darth2 wins!!!

darth2 vs patternSeeker: patternSeeker wins!!!

darth2 vs backatyou2: backatyou2 wins!!!

darth2 vs unr1: unr1 wins!!!

darth2 vs unr2: unr2 wins!!!

darth2 vs phil: phil wins!!!

darth2 vs phil1: darth2 wins!!!

darth2 vs phil2: darth2 wins!!!

darth3 vs patternSeeker: darth3 wins!!!

darth3 vs backatyou2: backatyou2 wins!!!

darth3 vs unr1: darth3 wins!!!

darth3 vs unr2: unr2 wins!!!

darth3 vs phil: darth3 wins!!!

darth3 vs phil1: darth3 wins!!!

darth3 vs phil2: darth3 wins!!!

patternSeeker vs backatyou2: patternSeeker wins!!!

patternSeeker vs unr1: unr1 wins!!!

patternSeeker vs unr2: patternSeeker wins!!!

patternSeeker vs phil: phil wins!!!

patternSeeker vs phil1: It was a tie!!!

patternSeeker vs phil2: patternSeeker wins!!!

backatyou2 vs unr1: backatyou2 wins!!!

backatyou2 vs unr2: backatyou2 wins!!!

backatyou2 vs phil: backatyou2 wins!!!

backatyou2 vs phil1: backatyou2 wins!!!

backatyou2 vs phil2: backatyou2 wins!!!

unr1 vs unr2: unr2 wins!!!

unr1 vs phil: phil wins!!!

unr1 vs phil1: unr1 wins!!!

unr1 vs phil2: unr1 wins!!!

unr2 vs phil: unr2 wins!!!

unr2 vs phil1: It was a tie!!!

unr2 vs phil2: unr2 wins!!!

phil vs phil1: phil wins!!!

phil vs phil2: It was a tie!!!

phil1 vs phil2: phil1 wins!!!

Win Count:

test2: 10.5

izzy: 6.5

izzy1: 10.0

izzy2: 10.0

jarze: 12.5

medji: 10.0

medji1: 11.5

medji2: 11.0

mr_apple_pi: 8.5

mrapple1: 12.5

apple3: 9.0

darth1: 15.0

darth2: 7.0

darth3: 9.5

patternSeeker: 15.5

backatyou2: 15.5

unr1: 8.5

unr2: 10.0

phil: 8.0

phil1: 5.0

phil2: 4.0

Type y for analysis y

[Algos: 21] [Games: 210] [Average Score: 10.0] [sdev: 3.036] [MAD: 2.286]

From Greatest to Least:

patternSeeker: 15.5

backatyou2: 15.5

darth1: 15.0

jarze: 12.5

mrapple1: 12.5

medji1: 11.5

medji2: 11.0

test2: 10.5

izzy1: 10.0

izzy2: 10.0

medji: 10.0

unr2: 10.0

darth3: 9.5

apple3: 9.0

mr_apple_pi: 8.5

unr1: 8.5

phil: 8.0

darth2: 7.0

izzy: 6.5

phil1: 5.0

phil2: 4.0

The biggest blowout game(s) was(were):

test2 won 100 games and izzy1 won 0 ~ there were 0 ties

test2 won 0 games and mrapple1 won 100 ~ there were 0 ties

test2 won 0 games and darth1 won 100 ~ there were 0 ties

test2 won 0 games and unr2 won 100 ~ there were 0 ties

backatyou2 won 100 games and phil2 won 0 ~ there were 0 ties

Type y to play again n

Thanks for playing!

and the code


// RPS by Unreality

// for Brainden


import java.util.Scanner;

import java.util.ArrayList;

import java.util.Vector;

import java.util.Random; // for use only in the "rand" test program!

public class rps

{


public static final int ROCK = 0;

public static final int PAPER = 1;

public static final int SCISSORS = 2;

public static final int ROUNDS = 100;


   public static int rpsgo(int algoNum, int i, int[] a, int[] b)

   {

        if (algoNum==0) // hawk

        {

            if (i==0) return (int)Math.pow(2,21) % 3;

            int[] num = new int[3];

            for (int z=0; z<i; z++) { num[b[z]]++; }

            int x=0;

            if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

            if (num[2] > num[x]) x = 2;

            return (x+1)%3;

        }

        else if (algoNum==1) // test1

        {

            if (i==0) return SCISSORS;

            return b[i-1];

        }

        else if (algoNum==2) // test2

        {

            return i % 3;

        }

        else if (algoNum==3) // test3

        {

            int sum = 0;

            for (int z=0; z<i; z++)

            {

                sum += (a[z] + b[z]);

            }

            sum %= 3;

            return sum;

        }

        else if (algoNum==4) // izzy

        {

            // use sci until sci loses; if sci loses at i=0, discard and use sci again til sci loses

            // then use pap til pap loses

            // then rock til rock loses

            // then do whatever beats what they've used most

            if (i==0 || (i==1 && b[0]==0)) return SCISSORS;


            boolean lostWithRock = false;

            search: for (int z=0; z<i; z++) { if (a[z]==0 && b[z]==1) { lostWithRock = true; break search; } }

            if (lostWithRock)

            {

                // do what beats what they've done most

                int[] num = new int[3];

                for (int y=0; y<i; y++) { num[b[y]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else

            {

                // do what won last time, or, if lost last time, advance one from sci -> pap -> rock (2 -> 1 -> 0)

                return a[i-1] - (((a[i-1] - b[i-1] + 3) % 3) / 2);

            }

        }

        else if (algoNum==5) // phil

        {

            if (i==0) return PAPER;

            int[] c = new int[i*3];

            int y = 0;

            for (int z=0; z<i; z++)

            {

                if (b[z]==0) { c[y] = 1; c[y+1] = 2; y+= 2; }

                if (b[z]==1) { c[y] = 1; c[y+1] = 0; c[y+2] = 2; y+= 3; }

                if (b[z]==2) { c[y] = 0; y++; }

            }

            return c[i+1];

        }

        else if (algoNum==6) // backatyou

        {

            int myWins = 0;

            int hisWins = 0;


            int[] hisWinMoves = new int[3];

            int[] hisLoseMoves = new int[3];

            int[] hisTieMoves = new int[3];


            for(int j = 0; j < i; j++) {

                int myMove = a[j];

                int hisMove = b[j];

                if(myMove == ROCK && hisMove == SCISSORS ||

                        myMove == SCISSORS && hisMove == PAPER ||

                        myMove == PAPER && hisMove == ROCK)

                        myWins++;

                if(hisMove == ROCK && myMove == SCISSORS ||

                        hisMove == SCISSORS && myMove == PAPER ||

                        hisMove == PAPER && myMove == ROCK)

                        hisWins++;

                if(hisWins > myWins) {

                        hisWinMoves[hisMove]++;

                } else if(myWins > hisWins) {

                        hisLoseMoves[hisMove]++;

                } else {

                        hisTieMoves[hisMove]++;

                }

        }



            int[] myPick = null;

            if (hisWins > myWins)  myPick = hisWinMoves;

            else if (myWins > hisWins) myPick = hisLoseMoves;

            else myPick = hisTieMoves;

            int max = ROCK;

            if(myPick[PAPER] > myPick[ROCK])

            {

                max = PAPER;

                if(myPick[SCISSORS] > myPick[PAPER]) max = SCISSORS;

            } 

            else if(myPick[SCISSORS] > myPick[ROCK]) max = SCISSORS;


            int move;

                if(max == ROCK)

                     move = PAPER;

                else if(max == PAPER)

                     move = SCISSORS;

                else

                     move = ROCK;

                return(move);

        }

        else if (algoNum==7) // dnoob

        {

            if (i==0) return ROCK;

            int n = i;

            int numsub = 0;

            int fib = 0;

            int fibc = 1;

            int temp;

            while (n - fibc >= 0)

            {

                n -= fibc; numsub++;

                temp = fibc;

                fibc += fib;

                fib = temp;


            }


            int x = ROCK;

            if (i%2 == 1)

            {

                // borrowing some code from hawk here...

                int[] num = new int[3];

                for (int z=0; z<i; z++) { num[b[z]]++; }

                if (num[ROCK] > num[1]) { x = ROCK ; } else if (num[PAPER] > num[ROCK]) { x = PAPER ; } else { x = num[x] % 2 ; /*pseudorandom if tie*/ }

                if (num[SCISSORS] > num[x]) x = SCISSORS;

            } 

            return (numsub + x) % 3;

        }

        else if (algoNum==8) // rand

        {

            Random rangen = new Random();

            return rangen.nextInt(3);

        }

        else if (algoNum==9) // allrock

        {

            return ROCK;

        }

        else if (algoNum==10) // jarze

        {

           if (i==0) return ROCK;

           return (b[i-1]+1)%3;

        }

        else if (algoNum==11) // medji

        {

            if (i==0) return PAPER;

            if (i<5) return b[i-1];

            int sumi=0; for (int zz=i-5; zz<i; zz++){ sumi += b[zz]; }

            if (sumi%2 == 1)

            {

                int[] num = new int[3];

                for (int z=(i-25 + Math.abs(i-25))/2; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else return b[i-1];

        }

        else if (algoNum==12) // mr apple (pi)

        {

            int[] digsPi = { 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0,2,8,8,4,1,9,7,1,6,9,3,9,9,3,7,5,1,0,5,8,2,0,9,7,4,9,4,4,5,9,2,3,0,7,8,1,6,4,0,6,2,8,6,2,0,8,9,9,8,6,2,8,0,3,4,8,2,5,3,4,2,1,1,7,0,6,7,9,8,2,1,4,8,0,8,6,5,1,3,2,8,2,3,0,6,6,4,7,0,9,3,8,4,4,6,0,9,5,5,0,5,8,2,2,3,1,7,2,5,3,5,9,4,0,8,1,2,8,4,8,1,1,1,7,4,5,0,2,8,4,1,0,2,7,0,1,9,3,8,5,2,1,1,0,5,5,5,9,6,4,4,6,2,2,9,4,8,9,5,4,9,3,0,3,8,1,9,6 };

            int dig = digsPi[i];

            if (dig > 0 && dig < 4) return dig-1;

            else if (dig==4)

            {

                // opp's most move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return x;

            }

            else if (dig==5 || dig==6)

            {

                // counter opp's most move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else if (dig==7 || dig==8)

            {

                // self's least played move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[a[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 1 ; } else if (num[1] > num[0]) { x = 0 ; } else { x = num[x] % 2 ; }

                if (num[x] > num[2]) x = 2;

                return x;

            }

            else if (dig==9)

            {

                // self's most played move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[a[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return x;

            }

            else if (dig==0)

            {

                // opp's most recent move

                return b[i-1];

            }

            else return -1;

        }

        else if (algoNum==13) // darth1

        {

               int[] achose = {0,0,0};

               int[] bchose = {0,0,0};

               for (int vv=0; vv<i; vv++) { achose[a[vv]]++; bchose[b[vv]]++; }

               int enemy_least = ROCK, me_least = ROCK, enemy_most = ROCK, me_most = ROCK;

               int enemy_times_used_least = 0, me_times_used_least = 0, enemy_times_used_most = 0, me_times_used_most = 0;

               int tiebreaker;


               if (achose[PAPER] > achose[ROCK]) me_most = PAPER;

               if (achose[SCISSORS] > achose[me_most]) me_most = SCISSORS;

               me_times_used_most = achose[me_most]; tiebreaker = me_most;

               if (achose[me_most] == achose[(me_most+1)%3] || achose[me_most] == achose[(me_most+2)%3]) { tiebreaker = -2; // two-way tie

               if (achose[me_most] == achose[(me_most+1)%3] && achose[me_most] == achose[(me_most+2)%3]) tiebreaker = -3; /* three way tie */ }

               me_most = tiebreaker;


               if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

               if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;

               enemy_times_used_most = bchose[enemy_most]; tiebreaker = enemy_most;

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] || bchose[enemy_most] == bchose[(enemy_most+2)%3]) { tiebreaker = -2; // two-way tie

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] && bchose[enemy_most] == bchose[(enemy_most+2)%3]) tiebreaker = -3; /* three way tie */ }

               enemy_most = tiebreaker;


               if (achose[PAPER] < achose[ROCK]) me_least = PAPER;

               if (achose[SCISSORS] < achose[me_least]) me_least = SCISSORS;

               me_times_used_least = achose[me_least]; tiebreaker = me_least;

               if (achose[me_least] == achose[(me_least+1)%3] || achose[me_least] == achose[(me_least+2)%3]) { tiebreaker = -2; // two-way tie

               if (achose[me_least] == achose[(me_least+1)%3] && achose[me_least] == achose[(me_least+2)%3]) tiebreaker = -3; /* three way tie */ }

               me_least = tiebreaker;


               if (bchose[PAPER] < bchose[ROCK]) enemy_least = PAPER;

               if (bchose[SCISSORS] < bchose[enemy_least]) enemy_least = SCISSORS;

               enemy_times_used_least = bchose[enemy_least]; tiebreaker = enemy_least;

               if (bchose[enemy_least] == bchose[(enemy_least+1)%3] || bchose[enemy_least] == bchose[(enemy_least+2)%3]) { tiebreaker = -2; // two-way tie

               if (bchose[enemy_least] == bchose[(enemy_least+1)%3] && bchose[enemy_least] == bchose[(enemy_least+2)%3]) tiebreaker = -3; /* three way tie */ }

               enemy_least = tiebreaker;


               int d = enemy_times_used_most - enemy_times_used_least;


               if (d < 3 || d < i/9)

               {

                    if (enemy_least == -2) { return (enemy_most+2)%3; }

                    else if (enemy_least == -3) { return ((i%3)+1)%3; }

                    else { return (enemy_least+1)%3; }

               }

               else if (enemy_least == -2) { return (enemy_most+1)%3; }

               else { return (enemy_least+2)%3; }

        }

        else if (algoNum==14) // izzy1

        {

            if (i==0) return SCISSORS;

            if ((3 + a[i-1] - b[i-1])%3 == 2) return (a[i-1]+1)%3;

            else if ((3 + a[i-1] - b[i-1])%3 == 1) return a[i-1];

            else if (i > 2 && (3 + a[i-2] - b[i-2])%3 == 0 && (3 + a[i-3] - b[i-3])%3 == 0) return (a[i-1]+1)%3;

            else return a[i-1];

        }

        else if (algoNum==15) // izzy2

        {

            if (i==0) return ROCK;

            if (i<8) return (int)Math.ceil((double)(i%3) / 2.0) * -1 + 2;

            int[] first8 = new int[8];

            for (int tz=0; tz<8; tz++) first8[tz] = b[tz];

            int[][] ariz = { {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {2,2,2,2,2,2,2,2}, {0,1,2,0,1,2,0,1}, {1,2,0,1,2,0,1,2}, {2,0,1,2,0,1,2,0}, {0,2,1,0,2,1,0,2}, {1,0,2,1,0,2,1,0}, {2,1,0,2,1,0,2,1}, {0,1,2,2,0,0,0,1} };

            int patt = -1;

            for (int ty=0; ty<ariz.length; ty++) 

            {

                boolean izfound = true;

                for (int tyy=0; tyy<8; tyy++)  { if (ariz[ty][tyy] != first8[tyy]) { izfound = false; } }

                if (izfound) { patt = ty; }

            }

            if (patt > -1)

            {

                int[] beats;

                if (patt==0) beats =      new int[]{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

                else if (patt==1) beats = new int[]{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};

                else if (patt==2) beats = new int[]{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

                else if (patt==3) beats = new int[]{ 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0};

                else if (patt==4) beats = new int[]{ 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1};

                else if (patt==5) beats = new int[]{ 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2};

                else if (patt==6) beats = new int[]{ 1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2};

                else if (patt==7) beats = new int[]{ 2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0};

                else if (patt==8) beats = new int[]{ 0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1};

                else if (patt==9) beats = new int[]{ 1,2,0,0,1,1,1,2,2,2,2,2,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};


                else beats = new int[]{  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};


                if (i<18) return beats[i-8];

                int winsum=0;

                for (int tx=8; tx<18; tx++) { if ((3 + a[tx] - b[tx])%3 == 1) { winsum++; } }

                if (winsum > 4) return beats[i-8];

            }

            // either no pattern was found or pattern beating was unsuccessful. Resort to final plan

            // ie, the look-and-say sequence

           int[] look_say_sequence = { 1,1,1,3,1,2,2,1,1,3,1,2,1,1,1,3,2,2,2,1,2,3,2,1,1,2,1,1,1,3,1,2,1,1,1,2,1,3,1,1,1,2,1,3,2,1,1,2,3,1,1,3,2,1,3,2,2,1,1,2,1,1,1,3,1,2,2,1,1,3,1,2,1,1,2,2,1,3,2,1,1,2,3,1,1,3,2,1,3,2,2,1,1,2,3,1,1,3,1,1,2,2,2,1,1,3,1,1,1,2,3,1,1,3,3,2,2,1,1,2,1,1,1,3,1,2,2,1,1,3,1,2,1,1,1,3,2,2,1,1,1,2,1,3,1,2,2,1,1,2,3,1,1,3,1,1,1,2,3,1,1,2,1,1,2,3,2,2,2,1,1,2,1,3,2,1,1,3,2,1,3,2,2,1,1,3,3,1,1,2,1,3,2,1,2,3,1,2,3,1,1,2,1,1,1,3,1,1,2,2,2,1,1,2,1,3,2,1,1,3,3,1,1,2,1,3,2,1,1,2,3,1,2,3,2,1,1,2,3,1,1,3,1,1,2,2,2,1,1,2,1,1,1,3,1,2,2,1,1,3,1,2,1,1,1,3,1,2,3,1,1,2,1,1,2,3,2,2,1,1,1,2,1,3,2,1,1,3,2,2,2,1,1,3,1,2,1,1,3,2,1,1 }; // when it hits 302 digits, this is it

           return look_say_sequence[i-8] % 3;

        }

        else if (algoNum==16) // darth2

        {

            if (i<5) return ROCK;

            if (i%5 == 0)

            {

                int[] runli = new int[i/5];

               for (int qrx=0; qrx< i/5; qrx++)

               {

                   int[] bchose = { 0,0,0 };

                   for (int vv=qrx*5; vv< qrx*5 + 5; vv++) {  bchose[b[vv]]++; }

                   int enemy_most = ROCK;


                   if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

                   if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;


                   if (bchose[enemy_most] == bchose[(enemy_most+1)%3])

                   {

                       int setvv = enemy_most;

                       for (int vvv=qrx*5; vvv< qrx*5+5; vvv++)

                       {

                           if (b[vvv]==enemy_most) setvv = enemy_most;

                           if (b[vvv]==(enemy_most+1)%3) setvv = (enemy_most+1)%3;

                        }

                        enemy_most = setvv;

                   }

                   else if (bchose[enemy_most] == bchose[(enemy_most+2)%3])

                   {

                     int setvv = enemy_most;

                       for (int vvv=qrx*5; vvv< qrx*5+5; vvv++)

                       {

                           if (b[vvv]==enemy_most) setvv = enemy_most;

                           if (b[vvv]==(enemy_most+2)%3) setvv = (enemy_most+2)%3;

                        }

                        enemy_most = setvv;

                   }

                    runli[qrx] = enemy_most;

                }

               // beat most often move from runli; if tie, use most recent of the ones tying

               int[] vchose = {0,0,0};

               for (int vvvv=0; vvvv<runli.length; vvvv++) { vchose[runli[vvvv]]++; }

               int vmost = ROCK;

               if (vchose[PAPER] > vchose[ROCK]) vmost = PAPER;

               if (vchose[SCISSORS] > vchose[vmost]) vmost = SCISSORS;

               if (vchose[vmost] == vchose[(vmost+1)%3] && vchose[vmost] == vchose[(vmost+1)%3]) vmost = runli[runli.length-1];

               else if (vchose[vmost] == vchose[(vmost+1)%3])

                   {

                       int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==vmost) setvv = vmost;

                           if (vbv==(vmost+1)%3) setvv = (vmost+1)%3;

                        }

                        vmost = setvv;

                   }

                   else if (vchose[vmost] == vchose[(vmost+2)%3])

                   {

                     int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==vmost) setvv = vmost;

                           if (vbv==(vmost+2)%3) setvv = (vmost+2)%3;

                        }

                        vmost = setvv;

                   }

                   else if (vchose[(vmost+1)%3] == vchose[(vmost+2)%3])

                   {

                     int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==(vmost+1)%3) setvv = (vmost+1)%3;

                           if (vbv==(vmost+2)%3) setvv = (vmost+2)%3;

                        }

                        vmost = setvv;

                   }

                   return (vmost+1)%3;

            }

            else

            {

                return a[i-1];

            }

        }

        else if (algoNum==17) // darth3

        {

            if (i<7) return (i+1)%3;

            if (b[i-1] == b[i-2] && b[i-2] == b[i-3])

            {

                int firstx=0, secondx=0;

                for (int ghgh=i-7; ghgh<i; ghgh++) { if (a[ghgh]==(b[i-1]+1)%3) { firstx++;} if (a[ghgh]==(b[i-1]+2)%3) { secondx++;} }

                if (firstx > secondx || firstx == secondx) return (b[i-1]+1)%3;

                else return (b[i-1]+2)%3;

            }

            else

            {

                int[] achose = {0,0,0};

                int[] bchose = {0,0,0};

               for (int vv=0; vv<i; vv++) { achose[a[vv]]++; bchose[b[vv]]++; }

               int tiebreaker;

               int me_least = ROCK, enemy_most = ROCK;


               if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

               if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;

               tiebreaker = enemy_most;

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] || bchose[enemy_most] == bchose[(enemy_most+2)%3]) { tiebreaker = -2;  }

               enemy_most = tiebreaker;


               if (achose[PAPER] < achose[ROCK]) me_least = PAPER;

               if (achose[SCISSORS] < achose[me_least]) me_least = SCISSORS;

               tiebreaker = me_least;

               if (achose[me_least] == achose[(me_least+1)%3] || achose[me_least] == achose[(me_least+2)%3]) { tiebreaker = -2;  }

               me_least = tiebreaker;


               if (me_least == -2)

               {

                   if (enemy_most == -2) { return (a[i-1]+2)%3; }

                   else { return (enemy_most+2)%3; }

                }

                else return me_least;


            }

        }

        else if (algoNum==18) // mrapple1

        {

            return (i+1)%3;

        }

        else if (algoNum==19) // medji1

        {

            if (i==0) return SCISSORS;

            if (i%5 != 0) return (a[i-1]+2)%3;

            return (a[i-1]+1)%3;

        }

       else if (algoNum==20) // medji2

        {

            if (i==0) return ROCK;

            if (i%3 != 0) return (a[i-1]+1)%3;

            return (a[i-1]+2)%3;

        }

        else if (algoNum==21) // patternSeeker (dawh)

        {

            if(i == 0)

            return(ROCK);

            int predicted = -1;

            int success = 0;

            Vector<Integer> patt = new Vector<Integer>();

            for(int j = 0; j < i; j++) {

                int move = b[j];

                if(patt.contains(move)) {

                    int idx = patt.indexOf(move)+1;

                    if(idx < patt.size()) {

                        predicted = patt.get(idx);

                    }

                }

                patt.add(move);


                if(j < i-1 && predicted == b[j+1])

                success++;

            }

            if(success > i/2) {

                int move = b[i-1];

                int idx = patt.indexOf(move)+1;

                if(idx > 0 && idx < patt.size())

                    return((patt.get(idx)+1)%3);

                }

                return((b[i-1]+1)%3);

            }

            else if (algoNum==22) // phil1

            {

                if (i==0) return PAPER;

                int[] best = {0,0,0};

                int ties = 0;

                for(int j=0; j<i; j++) {

                    if (a[j] == b[j]) ties += 1;

                    else

                    {

                        if (a[j] == ROCK && b[j] == PAPER) best[0] -= 1;

                        if (a[j] == PAPER && b[j] == SCISSORS) best[1] -= 1;

                        if (a[j] == SCISSORS && b[j] == ROCK) best[2] -= 1;


                        if (a[j] == ROCK && b[j] == SCISSORS) best[0] += 1;

                        if (a[j] == PAPER && b[j] == ROCK) best[1] += 1;

                        if (a[j] == SCISSORS && b[j] == PAPER) best[2] += 1;

                    }

                }


                int xx=ROCK;

                if (best[ROCK] < best[PAPER]) xx=ROCK;

                if (best[xx] < best[SCISSORS]) return SCISSORS;

                else if (best[SCISSORS] == best[xx] || best[ROCK]==best[PAPER]) return ties%3;

                else return xx;

                // end of phil1

            }

            else if (algoNum == 23)// phil2

            { 

                //this algorithm strives for an optimal sequence of moves.

                int index = 0;

                if (i == 0){

                    return ROCK;

                }

                else {

                    int[] array, best;

                    int index1 = 0, index2 = 0, check = 0;

                    int j = 0;

                    array = new int[i];

                    best = new int[3];

                    while (index1 < i && index2 < i){

                        if(check == 0){

                            if((a[index1] == ROCK && b[index2] == ROCK || b[index2] == PAPER)

                            || (a[index1] == PAPER && b[index2] == PAPER || b[index2] == SCISSORS)

                            || (a[index1] == SCISSORS && b[index2] == SCISSORS || b[index2] == ROCK)){

                                check = 1;

                                index2 += 1;

                            }

                            else{

                                check = 2;

                                index1 += 1;

                            }

                        }

                        else if(check == 1){

                            if((a[index1] == ROCK && b[index2] == ROCK || b[index2] == PAPER)

                            || (a[index1] == PAPER && b[index2] == PAPER || b[index2] == SCISSORS)

                            || (a[index1] == SCISSORS && b[index2] == SCISSORS || b[index2] == ROCK)){

                                index2 += 1;

                            }

                            else{

                                for(j = index1; j<index2; j++){

                                    array[j] = b[j];

                                }

                            }

                            check = 0;

                            index1 = index2;

                        }

                        else{

                            if((b[index2] == ROCK && a[index1] == ROCK || a[index1] == PAPER)

                            || (b[index2] == PAPER && a[index1] == PAPER || a[index1] == SCISSORS)

                            || (b[index2] == SCISSORS && a[index1] == SCISSORS || a[index1] == ROCK)){

                                index1 += 1;

                            }

                            else{

                                for(j = index1; j<index2; j++){

                                    array[j] = a[j];

                                }

                                check = 0;

                                index2= index1;

                            }

                        }

                    }

                    if(index1 > index2){

                        for(j = index2; j<index1; j++){

                            array[j] = b[j];

                        }

                    }

                    else{

                        for(j = index1; j<index2; j++){

                            array[j] = a[j];

                        }

                    }

                    for(j = 0; j< i; j++){

                        best[array[j]]++;

                    }

                    int y = ROCK;

                    if(best[ROCK] <best[PAPER]){

                        y = PAPER;

                    }

                    if(best[y] <best[SCISSORS]){

                        return SCISSORS;

                    }

                    else{

                        return y;

                    }

                }

            }

            else if (algoNum==24) //unr1

            {

                if (i==0) return PAPER;

                int yeah = PAPER;

                for (int xh=0; xh<i; xh++)

                {

                    yeah = yeah ^ xh;

                }

                return (yeah%3);

            }

            else if (algoNum==25) //unr2

            {

                if (i<6) return (i+1)%3;

                int[] prev = { b[i-6], b[i-5], b[i-4], b[i-3], b[i-2], b[i-1] };

                int[][] patns = {

                               {0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2},

                               {0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1},

                               {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

                               {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

                               {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},

                               {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},

                               {0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2},

                               {1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}

                            };

                boolean match=false;

                int matchPat = -1, matchIndex = -1;

                yeahloop: for (int iiz=0; iiz<patns.length; iiz++)

                {

                    for (int iiiz=0; iiiz<44; iiiz++)

                    {

                        if (patns[iiz][iiiz] == prev[0] 

                        && patns[iiz][iiiz+1] == prev[1]

                        && patns[iiz][iiiz+2] == prev[2]

                        && patns[iiz][iiiz+3] == prev[3]

                        && patns[iiz][iiiz+4] == prev[4]

                        && patns[iiz][iiiz+5] == prev[5]) { match=true; matchPat = iiz; matchIndex = iiiz+6; }

                    }

                    if (match) break yeahloop;

                }

                if (match)

                {

                    return (patns[matchPat][matchIndex] + 1)%3;

                }

                else

                {

                    int sumt = 0;

                    for (int sumin=0; sumin<i; sumin++) {sumt += b[sumin];}

                    double mean = (double)sumt / (double)i;

                    double sdev = 0.0;

                    for (int sumin=0; sumin<i; sumin++) {sdev += (double)((b[sumin] - mean) * (b[sumin] - mean));}

                    sdev /= (double)i; // divide by i, not i-1, because we have a complete population

                    sdev = Math.sqrt(sdev); // sdev is now the standard deviation of b's moves

                    boolean[] withinOne = {false, false, false};

                    if (0 > mean - sdev && 0 < mean + sdev) withinOne[0] = true;

                    if (1 > mean - sdev && 1 < mean + sdev) withinOne[1] = true;

                    if (2 > mean - sdev && 2 < mean + sdev) withinOne[2] = true;

                    if (withinOne[i%3]) return i%3;

                    else if (withinOne[(i+1)%3]) return (i+1)%3;

                    else return (i+2)%3;

                }


            }

            else if (algoNum==26) //phil3

            {

                int[] best;

                if(i == 0){

                    return ROCK;

                }

                best = new int[3];

                for(int j = 0; j <i; j++){

                    if(a[j] == b[j]){

                        best[a[j]]++;

                    }

                    else if(a[j] == ROCK && b[j] == SCISSORS){

                        best[ROCK]++;

                    }

                    else if(a[j] == PAPER && b[j] == ROCK){

                        best[PAPER]++;

                    }

                    else if(a[j] == SCISSORS && b[j] == PAPER){

                        best[SCISSORS]++;

                    }

                    else if(b[j] == ROCK && a[j] == SCISSORS){

                            best[ROCK]++;

                        }

                        else if(b[j] == PAPER && a[j] == ROCK){

                            best[PAPER]++;

                        }

                        else if(b[j] == SCISSORS && a[j] == PAPER){

                            best[SCISSORS]++;

                        }

                    }

                    int y = ROCK;

                    if(best[ROCK] < best[PAPER]){

                        y = PAPER;

                    }

                    if(best[y] < best[SCISSORS]){

                        return SCISSORS;

                    }

                    else{

                        return y;

                    }

             }

            else if (algoNum==27) //apple3

            {

                int nkk = ((i%6) / 3) * 2;

                if (i%6==0) nkk++;

                nkk += (2 * (i /6));

                return (nkk % 3);

            }

            else if (algoNum==28) //backatyou2

            {

                int[] hisWinMoves = new int[3];

                int[] hisLoseMoves = new int[3];

                int[] hisTieMoves = new int[3];


        int myMove = ROCK, hisMove = ROCK;

        int myWins = 0, hisWins = 0;

        for(int j = 0; j < i-1; j++) {

                myMove = a[j];

                hisMove = b[j];

                if(myMove == ROCK && hisMove == SCISSORS)

                        myWins++;

                else if(myMove == SCISSORS && hisMove == PAPER)

                        myWins++;

                else if(myMove == PAPER && hisMove == ROCK)

                        myWins++;


                if(hisMove == ROCK && myMove == SCISSORS)

                        hisWins++;

                else if(hisMove == SCISSORS && myMove == PAPER)

                        hisWins++;

                else if(hisMove == PAPER && myMove == ROCK)

                        hisWins++;


                if(hisWins > myWins) {

                        hisWinMoves[hisMove]++;

                } else if(myWins > hisWins) {

                        hisLoseMoves[hisMove]++;

                } else {

                        hisTieMoves[hisMove]++;

                }

        }


        int[] myPick;

        if(hisWins > myWins) {

                myPick = hisWinMoves;

        } else if(myWins > hisWins) {

                myPick = hisLoseMoves;

        } else {

                myPick = hisTieMoves;

        }

        int max;

        if(i % 2 == 0) {

                max =  ROCK;

                if(myPick[PAPER] > myPick[ROCK]) {

                        max = PAPER;

                        if(myPick[SCISSORS] > myPick[PAPER])

                                max = SCISSORS;

                } else if(myPick[SCISSORS] > myPick[ROCK])

                        max = SCISSORS;

        } else

                max = hisMove;

        int move;

        if(max == ROCK)

                move = PAPER;

        else if(max == PAPER)

                move = SCISSORS;

        else 

                move = ROCK;

        return(move);

            }

            // else if (algoNum==29)

            else return ROCK;

        //return ROCK;

    }


    public static String conv(int yeah)

    {

        if (yeah==ROCK) return "  rock  ";

        if (yeah==PAPER) return " paper  ";

        if (yeah==SCISSORS) return "scissors";

        return "you've got a problem";

    }


   public static void main(String[] args)

   {

       String[] names = { "hawk", "test1", "test2", "test3", "izzy", "phil", "backatyou", "dnoob", "rand", "allrock", "jarze", "medji" , "mr_apple_pi", "darth1", "izzy1", "izzy2", "darth2", "darth3", "mrapple1", "medji1", "medji2", "patternSeeker", "phil1", "phil2", "unr1", "unr2", "phil3", "apple3", "backatyou2" };


       boolean ohyeah = true;

       while (ohyeah)

    {

        Scanner inp = new Scanner(System.in);

       System.out.println("\n\nWelcome to R/P/S!");

       for (int j=0; j<names.length; j++) { System.out.println(j + " (" + names[j] + ")");}

       System.out.print("\n\nEnter the numbers of the programs you wish to fight, separated by spaces:\n");

       String nextln = inp.nextLine();

       int[] algos;

       if (nextln.equals("x"))

       {

           algos = new int[]{ 2, 4, 14, 15, 10, 11, 19, 20, 12, 18, 27, 13, 16, 17, 21, 28, 24, 25, 5, 22, 23 };

        }

        else

        {

       String[] splitup = nextln.split(" ");

       algos = new int[splitup.length];

       for (int hjk=0; hjk<splitup.length; hjk++) { algos[hjk] = Integer.parseInt(splitup[hjk]); }

      }


            String financ = "";

            int n = algos.length;  double[] nw = new double[n];

            //int numGames = n/2 * (n - 1);

            /* some data collection */ int curspread = 0; String spreadmsg = "All games had a spread of zero, weird!";

            for (int nn=0; nn<n; nn++)

            {

                for (int nnn = nn+1; nnn<n; nnn++)

                {

                    // game between algos[nn] and algos[nnn]

                    int algo1 = algos[nn]; int algo2 = algos[nnn];


                    System.out.print("\n\n"+names[algo1]+" vs "+names[algo2]+"\n");


                   int[] ar1 = new int[ROUNDS];

                   int[] ar2 = new int[ROUNDS];


                   int[] wins = new int[ROUNDS];


                   for (int k=0; k<ROUNDS; k++)

                   {

                           ar1[k] = rpsgo(algo1, k, ar1, ar2);

                           ar2[k] = rpsgo(algo2, k, ar2, ar1);

                           wins[k] = ( 3 + ar1[k] - ar2[k] ) % 3;

                           // 0 -> tie

                           // 1 -> one wins

                           // 2 -> two wins

                   }


                   int oneWins=0; int twoWins=0;

                   for (int l=0; l<ROUNDS; l++)

                   {

                       System.out.println(conv(ar1[l]) + " vs " + conv(ar2[l]));

                       if (wins[l]==1) { oneWins++; }

                       if (wins[l]==2) { twoWins++; }

                    }

                    int ties = ROUNDS - oneWins - twoWins; String msg1, msg2;

                    if (oneWins > twoWins + 1) { msg2 = names[algo1]+" wins!!!"; nw[nn]++; }

                    else if (twoWins > oneWins + 1) { msg2 = names[algo2]+" wins!!!"; nw[nnn]++; }

                    else { msg2 = "It was a tie!!!"; nw[nn] += 0.5; nw[nnn] += 0.5; }

                    msg1 = "\n"+names[algo1]+" won "+oneWins+" games and "+names[algo2]+" won " +twoWins+ " ~ there were " + ties + " ties";

                    System.out.println(msg1);

                    System.out.println(msg2);

                    financ += (names[algo1]+" vs "+names[algo2] + ": " + msg2 + "\n");

                    if (Math.abs(oneWins - twoWins) > curspread) { curspread = Math.abs(oneWins - twoWins); spreadmsg = msg1; }

                    else if (Math.abs(oneWins - twoWins) == curspread) { spreadmsg += msg1; }

                }

            }

            System.out.print("\n\nFinal Results:\n" + financ + "\n\nWin Count:\n");

            for (int abc=0; abc<n; abc++) System.out.println(names[algos[abc]]+": "+nw[abc]);


            System.out.print("\n\nType y for analysis ");

            if (inp.next().toLowerCase().charAt(0) == 'y')

            {

                double nm = (double)(n-1) / 2.0;

                double sdv = 0.0, mad = 0.0;

                for (int suminx=0; suminx<nw.length; suminx++) {sdv += ((double)((nw[suminx] - nm) * (nw[suminx] - nm))); mad += (double)Math.abs(nw[suminx] - nm);}

                sdv /= (double)(nw.length); mad /= (double)(nw.length);

                sdv = Math.sqrt(sdv);

                System.out.printf("%n%n[Algos: %d] [Games: %d] [Average Score: %.1f] [Sdev: %.3f] [MAD: %.3f]",n, (n*(n-1)) / 2, nm, sdv, mad);

                /* now present in order */ System.out.print("\n\nFrom Greatest to Least:\n");


               int[] nw_o = new int[nw.length]; boolean[] jk = new boolean[nw.length]; int ngr;

               for (int nnhz=0; nnhz<nw.length; nnhz++) jk[nnhz] = true;

               for (int nnh=0; nnh<nw.length; nnh++)

               {

                   ngr=0;

                   nhlp: for (int nindx=0; nindx<nw.length; nindx++)

                   {

                       if (jk[nindx]) { ngr=nindx; break nhlp; }

                    }

                   for (int nind=ngr; nind<nw.length; nind++)

                   {

                       if (nw[nind] > nw[ngr] && jk[nind]) { ngr = nind; }

                    }

                    nw_o[nnh]=ngr; jk[ngr] = false;

                }

                for (int nnhx=0; nnhx<nw.length; nnhx++) System.out.println(names[algos[nw_o[nnhx]]]+": "+nw[nw_o[nnhx]]);

                System.out.println("\nThe biggest blowout game(s) was(were): " + spreadmsg);

            }


            System.out.print("\n\nType y to play again ");

            ohyeah = false;

            if (inp.next().toLowerCase().charAt(0) == 'y') ohyeah = true;

        }

        System.out.print("\nThanks for playing!\n");

    }


}


Link to comment
Share on other sites

  • 0

Could you redo Tourney 2, but replacing Darth2 with "Fib2"?

Basically, return i'th Fibonacci sequence number, mod 3.

Example for the first few rounds:

i, Fibonacci sequence number, what my algorithm returns

0, 1, 1

1, 1, 1

2, 2, 2

3, 5, 2

4, 8, 2

5, 13, 1

6, 21, 0

7, 34, 1

8, 55, 1

9, 89, 2

10, 144, 0

Link to comment
Share on other sites

  • 0

actually the 0th fib number is 0, then 1,1,2,3,5,8,13,etc. Is that okay or do you want me to shift em down by 1 step?

Er, sure. I like zero. Zero is cool.

Btw I feel like I'm making you do extra work. Am I??

Link to comment
Share on other sites

  • 0

Er, sure. I like zero. Zero is cool.

Btw I feel like I'm making you do extra work. Am I??

no. I was getting a strange output until I realized that it was because fibonacci numbers grow exponentially (roughly as powers of the golden ratio) and the 100th fib number is greater than the range for an 'int' variable in java. So i changed it to 'long' and now only the last seven (i=93,94,95,96,97,98,99) are in jeopardy, and Java doesnt support unsigned data types so i just have to figure out what those last seven are manually...

http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibtable.html

93 : 12200160415121876738 = 2 x 557 x 2417 x 4531100550901

94 : 19740274219868223167 = 2971215073 x 6643838879

95 : 31940434634990099905 = 5 x 37 x 113 x 761 x 29641 x 67735001

96 : 51680708854858323072 = 27 x 32 x 7 x 23 x 47 x 769 x 1103 x 2207 x 3167

97 : 83621143489848422977 = 193 x 389 x 3084989 x 361040209

98 : 135301852344706746049 = 13 x 29 x 97 x 6168709 x 599786069

99 : 218922995834555169026 = 2 x 17 x 89 x 197 x 19801 x 18546805133

sum up the digits and mod 3 for the digital root

93: 2

94: 2

95: 1

96: 0

97: 1

98: 2

99: 2

so those last seven will just be locked in :thumbsup:


 else if (algoNum==29) //fib2

            {

                if (i<2) return i;

                if (i==93 || i==99) return 2;

                if (i>92) return Math.abs(i - 96);

                long fa=0,fb=1,tempfib=0;

                for (int fby=0; fby<i-1; fby++)

                {

                    tempfib = fb;

                    fb += fa;

                    fa = tempfib;

                }

                return (int)(fb % 3);

            }

Mr. Apple wanted to replace his apple3 with a new apple4, another locked pattern but different, but there were some things I was unsure about so I can't run the updated T2 yet until I get that straightened out, then I'll run it (with fib2 replacing darth2 as well)

Link to comment
Share on other sites

  • 0

well as requested i'm running a new simulation of T2 at ROUNDS=100 with fib2 instead of darth2 and apple4 instead of apple3....

I was able to do the concept behind apple4 all on one line so that was neat


else if (algoNum==30) //apple4

            {

                return ((((i / 15) % 3) - (i % 3) + 4) % 3);

            }

and I think I already posted the code for fib2, if not it will be in the following copy of the whole code:

remember that it when it prompts I'll enter "x" which initiates the array to:

algos = new int[]{ 2, 4, 14, 15, 10, 11, 19, 20, 12, 18, 30, 13, 29, 17, 21, 28, 24, 25, 5, 22, 23 };

which is all the programs that are in this final emulation of T2...

and the tail end of the results are....

Final Results:

test2 vs izzy: test2 wins!!!

test2 vs izzy1: test2 wins!!!

test2 vs izzy2: izzy2 wins!!!

test2 vs jarze: It was a tie!!!

test2 vs medji: test2 wins!!!

test2 vs medji1: It was a tie!!!

test2 vs medji2: It was a tie!!!

test2 vs mr_apple_pi: test2 wins!!!

test2 vs mrapple1: mrapple1 wins!!!

test2 vs apple4: It was a tie!!!

test2 vs darth1: darth1 wins!!!

test2 vs fib2: It was a tie!!!

test2 vs darth3: darth3 wins!!!

test2 vs patternSeeker: patternSeeker wins!!!

test2 vs backatyou2: test2 wins!!!

test2 vs unr1: test2 wins!!!

test2 vs unr2: unr2 wins!!!

test2 vs phil: test2 wins!!!

test2 vs phil1: It was a tie!!!

test2 vs phil2: It was a tie!!!

izzy vs izzy1: izzy wins!!!

izzy vs izzy2: izzy wins!!!

izzy vs jarze: jarze wins!!!

izzy vs medji: It was a tie!!!

izzy vs medji1: medji1 wins!!!

izzy vs medji2: medji2 wins!!!

izzy vs mr_apple_pi: mr_apple_pi wins!!!

izzy vs mrapple1: mrapple1 wins!!!

izzy vs apple4: apple4 wins!!!

izzy vs darth1: darth1 wins!!!

izzy vs fib2: fib2 wins!!!

izzy vs darth3: izzy wins!!!

izzy vs patternSeeker: patternSeeker wins!!!

izzy vs backatyou2: backatyou2 wins!!!

izzy vs unr1: unr1 wins!!!

izzy vs unr2: unr2 wins!!!

izzy vs phil: izzy wins!!!

izzy vs phil1: izzy wins!!!

izzy vs phil2: izzy wins!!!

izzy1 vs izzy2: izzy2 wins!!!

izzy1 vs jarze: jarze wins!!!

izzy1 vs medji: izzy1 wins!!!

izzy1 vs medji1: medji1 wins!!!

izzy1 vs medji2: medji2 wins!!!

izzy1 vs mr_apple_pi: izzy1 wins!!!

izzy1 vs mrapple1: mrapple1 wins!!!

izzy1 vs apple4: izzy1 wins!!!

izzy1 vs darth1: izzy1 wins!!!

izzy1 vs fib2: fib2 wins!!!

izzy1 vs darth3: izzy1 wins!!!

izzy1 vs patternSeeker: patternSeeker wins!!!

izzy1 vs backatyou2: backatyou2 wins!!!

izzy1 vs unr1: unr1 wins!!!

izzy1 vs unr2: izzy1 wins!!!

izzy1 vs phil: izzy1 wins!!!

izzy1 vs phil1: izzy1 wins!!!

izzy1 vs phil2: izzy1 wins!!!

izzy2 vs jarze: izzy2 wins!!!

izzy2 vs medji: medji wins!!!

izzy2 vs medji1: It was a tie!!!

izzy2 vs medji2: izzy2 wins!!!

izzy2 vs mr_apple_pi: mr_apple_pi wins!!!

izzy2 vs mrapple1: mrapple1 wins!!!

izzy2 vs apple4: apple4 wins!!!

izzy2 vs darth1: darth1 wins!!!

izzy2 vs fib2: izzy2 wins!!!

izzy2 vs darth3: izzy2 wins!!!

izzy2 vs patternSeeker: patternSeeker wins!!!

izzy2 vs backatyou2: It was a tie!!!

izzy2 vs unr1: izzy2 wins!!!

izzy2 vs unr2: izzy2 wins!!!

izzy2 vs phil: izzy2 wins!!!

izzy2 vs phil1: phil1 wins!!!

izzy2 vs phil2: izzy2 wins!!!

jarze vs medji: jarze wins!!!

jarze vs medji1: medji1 wins!!!

jarze vs medji2: medji2 wins!!!

jarze vs mr_apple_pi: jarze wins!!!

jarze vs mrapple1: It was a tie!!!

jarze vs apple4: apple4 wins!!!

jarze vs darth1: jarze wins!!!

jarze vs fib2: fib2 wins!!!

jarze vs darth3: jarze wins!!!

jarze vs patternSeeker: patternSeeker wins!!!

jarze vs backatyou2: jarze wins!!!

jarze vs unr1: unr1 wins!!!

jarze vs unr2: jarze wins!!!

jarze vs phil: phil wins!!!

jarze vs phil1: It was a tie!!!

jarze vs phil2: jarze wins!!!

medji vs medji1: medji wins!!!

medji vs medji2: medji2 wins!!!

medji vs mr_apple_pi: medji wins!!!

medji vs mrapple1: mrapple1 wins!!!

medji vs apple4: medji wins!!!

medji vs darth1: medji wins!!!

medji vs fib2: fib2 wins!!!

medji vs darth3: medji wins!!!

medji vs patternSeeker: patternSeeker wins!!!

medji vs backatyou2: backatyou2 wins!!!

medji vs unr1: medji wins!!!

medji vs unr2: medji wins!!!

medji vs phil: medji wins!!!

medji vs phil1: It was a tie!!!

medji vs phil2: It was a tie!!!

medji1 vs medji2: It was a tie!!!

medji1 vs mr_apple_pi: medji1 wins!!!

medji1 vs mrapple1: It was a tie!!!

medji1 vs apple4: medji1 wins!!!

medji1 vs darth1: darth1 wins!!!

medji1 vs fib2: fib2 wins!!!

medji1 vs darth3: darth3 wins!!!

medji1 vs patternSeeker: patternSeeker wins!!!

medji1 vs backatyou2: backatyou2 wins!!!

medji1 vs unr1: medji1 wins!!!

medji1 vs unr2: medji1 wins!!!

medji1 vs phil: medji1 wins!!!

medji1 vs phil1: medji1 wins!!!

medji1 vs phil2: It was a tie!!!

medji2 vs mr_apple_pi: medji2 wins!!!

medji2 vs mrapple1: It was a tie!!!

medji2 vs apple4: It was a tie!!!

medji2 vs darth1: darth1 wins!!!

medji2 vs fib2: fib2 wins!!!

medji2 vs darth3: darth3 wins!!!

medji2 vs patternSeeker: medji2 wins!!!

medji2 vs backatyou2: backatyou2 wins!!!

medji2 vs unr1: medji2 wins!!!

medji2 vs unr2: unr2 wins!!!

medji2 vs phil: phil wins!!!

medji2 vs phil1: medji2 wins!!!

medji2 vs phil2: It was a tie!!!

mr_apple_pi vs mrapple1: mrapple1 wins!!!

mr_apple_pi vs apple4: mr_apple_pi wins!!!

mr_apple_pi vs darth1: darth1 wins!!!

mr_apple_pi vs fib2: It was a tie!!!

mr_apple_pi vs darth3: mr_apple_pi wins!!!

mr_apple_pi vs patternSeeker: patternSeeker wins!!!

mr_apple_pi vs backatyou2: backatyou2 wins!!!

mr_apple_pi vs unr1: unr1 wins!!!

mr_apple_pi vs unr2: mr_apple_pi wins!!!

mr_apple_pi vs phil: mr_apple_pi wins!!!

mr_apple_pi vs phil1: mr_apple_pi wins!!!

mr_apple_pi vs phil2: mr_apple_pi wins!!!

mrapple1 vs apple4: It was a tie!!!

mrapple1 vs darth1: darth1 wins!!!

mrapple1 vs fib2: mrapple1 wins!!!

mrapple1 vs darth3: It was a tie!!!

mrapple1 vs patternSeeker: patternSeeker wins!!!

mrapple1 vs backatyou2: mrapple1 wins!!!

mrapple1 vs unr1: It was a tie!!!

mrapple1 vs unr2: unr2 wins!!!

mrapple1 vs phil: It was a tie!!!

mrapple1 vs phil1: It was a tie!!!

mrapple1 vs phil2: It was a tie!!!

apple4 vs darth1: darth1 wins!!!

apple4 vs fib2: fib2 wins!!!

apple4 vs darth3: apple4 wins!!!

apple4 vs patternSeeker: patternSeeker wins!!!

apple4 vs backatyou2: apple4 wins!!!

apple4 vs unr1: apple4 wins!!!

apple4 vs unr2: unr2 wins!!!

apple4 vs phil: phil wins!!!

apple4 vs phil1: apple4 wins!!!

apple4 vs phil2: It was a tie!!!

darth1 vs fib2: darth1 wins!!!

darth1 vs darth3: darth1 wins!!!

darth1 vs patternSeeker: patternSeeker wins!!!

darth1 vs backatyou2: backatyou2 wins!!!

darth1 vs unr1: darth1 wins!!!

darth1 vs unr2: darth1 wins!!!

darth1 vs phil: darth1 wins!!!

darth1 vs phil1: darth1 wins!!!

darth1 vs phil2: darth1 wins!!!

fib2 vs darth3: darth3 wins!!!

fib2 vs patternSeeker: fib2 wins!!!

fib2 vs backatyou2: It was a tie!!!

fib2 vs unr1: unr1 wins!!!

fib2 vs unr2: fib2 wins!!!

fib2 vs phil: phil wins!!!

fib2 vs phil1: phil1 wins!!!

fib2 vs phil2: It was a tie!!!

darth3 vs patternSeeker: darth3 wins!!!

darth3 vs backatyou2: backatyou2 wins!!!

darth3 vs unr1: darth3 wins!!!

darth3 vs unr2: unr2 wins!!!

darth3 vs phil: darth3 wins!!!

darth3 vs phil1: darth3 wins!!!

darth3 vs phil2: darth3 wins!!!

patternSeeker vs backatyou2: patternSeeker wins!!!

patternSeeker vs unr1: unr1 wins!!!

patternSeeker vs unr2: patternSeeker wins!!!

patternSeeker vs phil: phil wins!!!

patternSeeker vs phil1: It was a tie!!!

patternSeeker vs phil2: patternSeeker wins!!!

backatyou2 vs unr1: backatyou2 wins!!!

backatyou2 vs unr2: backatyou2 wins!!!

backatyou2 vs phil: backatyou2 wins!!!

backatyou2 vs phil1: backatyou2 wins!!!

backatyou2 vs phil2: backatyou2 wins!!!

unr1 vs unr2: unr2 wins!!!

unr1 vs phil: phil wins!!!

unr1 vs phil1: unr1 wins!!!

unr1 vs phil2: unr1 wins!!!

unr2 vs phil: unr2 wins!!!

unr2 vs phil1: It was a tie!!!

unr2 vs phil2: unr2 wins!!!

phil vs phil1: phil wins!!!

phil vs phil2: It was a tie!!!

phil1 vs phil2: phil1 wins!!!

Win Count:

test2: 10.5

izzy: 6.5

izzy1: 9.0

izzy2: 11.0

jarze: 10.5

medji: 10.5

medji1: 11.5

medji2: 10.5

mr_apple_pi: 8.5

mrapple1: 12.5

apple4: 9.0

darth1: 15.0

fib2: 11.0

darth3: 9.5

patternSeeker: 14.5

backatyou2: 14.0

unr1: 8.5

unr2: 9.5

phil: 8.0

phil1: 6.0

phil2: 4.0

Type y for analysis y

[Algos: 21] [Games: 210] [Average Score: 10.0] [sdev: 2.655] [MAD: 2.048]

From Greatest to Least:

darth1: 15.0

patternSeeker: 14.5

backatyou2: 14.0

mrapple1: 12.5

medji1: 11.5

izzy2: 11.0

fib2: 11.0

test2: 10.5

jarze: 10.5

medji: 10.5

medji2: 10.5

darth3: 9.5

unr2: 9.5

izzy1: 9.0

apple4: 9.0

mr_apple_pi: 8.5

unr1: 8.5

phil: 8.0

izzy: 6.5

phil1: 6.0

phil2: 4.0

The biggest blowout game(s) was(were):

test2 won 100 games and izzy1 won 0 ~ there were 0 ties

test2 won 0 games and mrapple1 won 100 ~ there were 0 ties

test2 won 0 games and darth1 won 100 ~ there were 0 ties

test2 won 0 games and unr2 won 100 ~ there were 0 ties

backatyou2 won 100 games and phil2 won 0 ~ there were 0 ties

Type y to play again n

Thanks for playing!

wow, fib2 did excellent! It didn't get any of the top places but somehow it managed to bump darth1 into the top slot haha


// RPS by Unreality

// for Brainden


import java.util.Scanner;

import java.util.ArrayList;

import java.util.Vector;

import java.util.Random; // for use only in the "rand" test program!

public class rps

{


public static final int ROCK = 0;

public static final int PAPER = 1;

public static final int SCISSORS = 2;

public static final int ROUNDS = 100;


   public static int rpsgo(int algoNum, int i, int[] a, int[] b)

   {

        if (algoNum==0) // hawk

        {

            if (i==0) return (int)Math.pow(2,21) % 3;

            int[] num = new int[3];

            for (int z=0; z<i; z++) { num[b[z]]++; }

            int x=0;

            if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

            if (num[2] > num[x]) x = 2;

            return (x+1)%3;

        }

        else if (algoNum==1) // test1

        {

            if (i==0) return SCISSORS;

            return b[i-1];

        }

        else if (algoNum==2) // test2

        {

            return i % 3;

        }

        else if (algoNum==3) // test3

        {

            int sum = 0;

            for (int z=0; z<i; z++)

            {

                sum += (a[z] + b[z]);

            }

            sum %= 3;

            return sum;

        }

        else if (algoNum==4) // izzy

        {

            // use sci until sci loses; if sci loses at i=0, discard and use sci again til sci loses

            // then use pap til pap loses

            // then rock til rock loses

            // then do whatever beats what they've used most

            if (i==0 || (i==1 && b[0]==0)) return SCISSORS;


            boolean lostWithRock = false;

            search: for (int z=0; z<i; z++) { if (a[z]==0 && b[z]==1) { lostWithRock = true; break search; } }

            if (lostWithRock)

            {

                // do what beats what they've done most

                int[] num = new int[3];

                for (int y=0; y<i; y++) { num[b[y]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else

            {

                // do what won last time, or, if lost last time, advance one from sci -> pap -> rock (2 -> 1 -> 0)

                return a[i-1] - (((a[i-1] - b[i-1] + 3) % 3) / 2);

            }

        }

        else if (algoNum==5) // phil

        {

            if (i==0) return PAPER;

            int[] c = new int[i*3];

            int y = 0;

            for (int z=0; z<i; z++)

            {

                if (b[z]==0) { c[y] = 1; c[y+1] = 2; y+= 2; }

                if (b[z]==1) { c[y] = 1; c[y+1] = 0; c[y+2] = 2; y+= 3; }

                if (b[z]==2) { c[y] = 0; y++; }

            }

            return c[i+1];

        }

        else if (algoNum==6) // backatyou

        {

            int myWins = 0;

            int hisWins = 0;


            int[] hisWinMoves = new int[3];

            int[] hisLoseMoves = new int[3];

            int[] hisTieMoves = new int[3];


            for(int j = 0; j < i; j++) {

                int myMove = a[j];

                int hisMove = b[j];

                if(myMove == ROCK && hisMove == SCISSORS ||

                        myMove == SCISSORS && hisMove == PAPER ||

                        myMove == PAPER && hisMove == ROCK)

                        myWins++;

                if(hisMove == ROCK && myMove == SCISSORS ||

                        hisMove == SCISSORS && myMove == PAPER ||

                        hisMove == PAPER && myMove == ROCK)

                        hisWins++;

                if(hisWins > myWins) {

                        hisWinMoves[hisMove]++;

                } else if(myWins > hisWins) {

                        hisLoseMoves[hisMove]++;

                } else {

                        hisTieMoves[hisMove]++;

                }

        }



            int[] myPick = null;

            if (hisWins > myWins)  myPick = hisWinMoves;

            else if (myWins > hisWins) myPick = hisLoseMoves;

            else myPick = hisTieMoves;

            int max = ROCK;

            if(myPick[PAPER] > myPick[ROCK])

            {

                max = PAPER;

                if(myPick[SCISSORS] > myPick[PAPER]) max = SCISSORS;

            } 

            else if(myPick[SCISSORS] > myPick[ROCK]) max = SCISSORS;


            int move;

                if(max == ROCK)

                     move = PAPER;

                else if(max == PAPER)

                     move = SCISSORS;

                else

                     move = ROCK;

                return(move);

        }

        else if (algoNum==7) // dnoob

        {

            if (i==0) return ROCK;

            int n = i;

            int numsub = 0;

            int fib = 0;

            int fibc = 1;

            int temp;

            while (n - fibc >= 0)

            {

                n -= fibc; numsub++;

                temp = fibc;

                fibc += fib;

                fib = temp;


            }


            int x = ROCK;

            if (i%2 == 1)

            {

                // borrowing some code from hawk here...

                int[] num = new int[3];

                for (int z=0; z<i; z++) { num[b[z]]++; }

                if (num[ROCK] > num[1]) { x = ROCK ; } else if (num[PAPER] > num[ROCK]) { x = PAPER ; } else { x = num[x] % 2 ; /*pseudorandom if tie*/ }

                if (num[SCISSORS] > num[x]) x = SCISSORS;

            } 

            return (numsub + x) % 3;

        }

        else if (algoNum==8) // rand

        {

            Random rangen = new Random();

            return rangen.nextInt(3);

        }

        else if (algoNum==9) // allrock

        {

            return ROCK;

        }

        else if (algoNum==10) // jarze

        {

           if (i==0) return ROCK;

           return (b[i-1]+1)%3;

        }

        else if (algoNum==11) // medji

        {

            if (i==0) return PAPER;

            if (i<5) return b[i-1];

            int sumi=0; for (int zz=i-5; zz<i; zz++){ sumi += b[zz]; }

            if (sumi%2 == 1)

            {

                int[] num = new int[3];

                for (int z=(i-25 + Math.abs(i-25))/2; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else return b[i-1];

        }

        else if (algoNum==12) // mr apple (pi)

        {

            int[] digsPi = { 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0,2,8,8,4,1,9,7,1,6,9,3,9,9,3,7,5,1,0,5,8,2,0,9,7,4,9,4,4,5,9,2,3,0,7,8,1,6,4,0,6,2,8,6,2,0,8,9,9,8,6,2,8,0,3,4,8,2,5,3,4,2,1,1,7,0,6,7,9,8,2,1,4,8,0,8,6,5,1,3,2,8,2,3,0,6,6,4,7,0,9,3,8,4,4,6,0,9,5,5,0,5,8,2,2,3,1,7,2,5,3,5,9,4,0,8,1,2,8,4,8,1,1,1,7,4,5,0,2,8,4,1,0,2,7,0,1,9,3,8,5,2,1,1,0,5,5,5,9,6,4,4,6,2,2,9,4,8,9,5,4,9,3,0,3,8,1,9,6 };

            int dig = digsPi[i];

            if (dig > 0 && dig < 4) return dig-1;

            else if (dig==4)

            {

                // opp's most move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return x;

            }

            else if (dig==5 || dig==6)

            {

                // counter opp's most move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[b[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return (x+1)%3;

            }

            else if (dig==7 || dig==8)

            {

                // self's least played move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[a[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 1 ; } else if (num[1] > num[0]) { x = 0 ; } else { x = num[x] % 2 ; }

                if (num[x] > num[2]) x = 2;

                return x;

            }

            else if (dig==9)

            {

                // self's most played move

                int[] num = {0,0,0};

                for (int z=0; z<i; z++) { num[a[z]]++; }

                int x=0;

                if (num[0] > num[1]) { x = 0 ; } else if (num[1] > num[0]) { x = 1 ; } else { x = num[x] % 2 ; }

                if (num[2] > num[x]) x = 2;

                return x;

            }

            else if (dig==0)

            {

                // opp's most recent move

                return b[i-1];

            }

            else return -1;

        }

        else if (algoNum==13) // darth1

        {

               int[] achose = {0,0,0};

               int[] bchose = {0,0,0};

               for (int vv=0; vv<i; vv++) { achose[a[vv]]++; bchose[b[vv]]++; }

               int enemy_least = ROCK, me_least = ROCK, enemy_most = ROCK, me_most = ROCK;

               int enemy_times_used_least = 0, me_times_used_least = 0, enemy_times_used_most = 0, me_times_used_most = 0;

               int tiebreaker;


               if (achose[PAPER] > achose[ROCK]) me_most = PAPER;

               if (achose[SCISSORS] > achose[me_most]) me_most = SCISSORS;

               me_times_used_most = achose[me_most]; tiebreaker = me_most;

               if (achose[me_most] == achose[(me_most+1)%3] || achose[me_most] == achose[(me_most+2)%3]) { tiebreaker = -2; // two-way tie

               if (achose[me_most] == achose[(me_most+1)%3] && achose[me_most] == achose[(me_most+2)%3]) tiebreaker = -3; /* three way tie */ }

               me_most = tiebreaker;


               if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

               if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;

               enemy_times_used_most = bchose[enemy_most]; tiebreaker = enemy_most;

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] || bchose[enemy_most] == bchose[(enemy_most+2)%3]) { tiebreaker = -2; // two-way tie

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] && bchose[enemy_most] == bchose[(enemy_most+2)%3]) tiebreaker = -3; /* three way tie */ }

               enemy_most = tiebreaker;


               if (achose[PAPER] < achose[ROCK]) me_least = PAPER;

               if (achose[SCISSORS] < achose[me_least]) me_least = SCISSORS;

               me_times_used_least = achose[me_least]; tiebreaker = me_least;

               if (achose[me_least] == achose[(me_least+1)%3] || achose[me_least] == achose[(me_least+2)%3]) { tiebreaker = -2; // two-way tie

               if (achose[me_least] == achose[(me_least+1)%3] && achose[me_least] == achose[(me_least+2)%3]) tiebreaker = -3; /* three way tie */ }

               me_least = tiebreaker;


               if (bchose[PAPER] < bchose[ROCK]) enemy_least = PAPER;

               if (bchose[SCISSORS] < bchose[enemy_least]) enemy_least = SCISSORS;

               enemy_times_used_least = bchose[enemy_least]; tiebreaker = enemy_least;

               if (bchose[enemy_least] == bchose[(enemy_least+1)%3] || bchose[enemy_least] == bchose[(enemy_least+2)%3]) { tiebreaker = -2; // two-way tie

               if (bchose[enemy_least] == bchose[(enemy_least+1)%3] && bchose[enemy_least] == bchose[(enemy_least+2)%3]) tiebreaker = -3; /* three way tie */ }

               enemy_least = tiebreaker;


               int d = enemy_times_used_most - enemy_times_used_least;


               if (d < 3 || d < i/9)

               {

                    if (enemy_least == -2) { return (enemy_most+2)%3; }

                    else if (enemy_least == -3) { return ((i%3)+1)%3; }

                    else { return (enemy_least+1)%3; }

               }

               else if (enemy_least == -2) { return (enemy_most+1)%3; }

               else { return (enemy_least+2)%3; }

        }

        else if (algoNum==14) // izzy1

        {

            if (i==0) return SCISSORS;

            if ((3 + a[i-1] - b[i-1])%3 == 2) return (a[i-1]+1)%3;

            else if ((3 + a[i-1] - b[i-1])%3 == 1) return a[i-1];

            else if (i > 2 && (3 + a[i-2] - b[i-2])%3 == 0 && (3 + a[i-3] - b[i-3])%3 == 0) return (a[i-1]+1)%3;

            else return a[i-1];

        }

        else if (algoNum==15) // izzy2

        {

            if (i==0) return ROCK;

            if (i<8) return (int)Math.ceil((double)(i%3) / 2.0) * -1 + 2;

            int[] first8 = new int[8];

            for (int tz=0; tz<8; tz++) first8[tz] = b[tz];

            int[][] ariz = { {0,0,0,0,0,0,0,0}, {1,1,1,1,1,1,1,1}, {2,2,2,2,2,2,2,2}, {0,1,2,0,1,2,0,1}, {1,2,0,1,2,0,1,2}, {2,0,1,2,0,1,2,0}, {0,2,1,0,2,1,0,2}, {1,0,2,1,0,2,1,0}, {2,1,0,2,1,0,2,1}, {0,1,2,2,0,0,0,1} };

            int patt = -1;

            for (int ty=0; ty<ariz.length; ty++) 

            {

                boolean izfound = true;

                for (int tyy=0; tyy<8; tyy++)  { if (ariz[ty][tyy] != first8[tyy]) { izfound = false; } }

                if (izfound) { patt = ty; }

            }

            if (patt > -1)

            {

                int[] beats;

                if (patt==0) beats =      new int[]{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

                else if (patt==1) beats = new int[]{ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};

                else if (patt==2) beats = new int[]{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

                else if (patt==3) beats = new int[]{ 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0};

                else if (patt==4) beats = new int[]{ 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1};

                else if (patt==5) beats = new int[]{ 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2};

                else if (patt==6) beats = new int[]{ 1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2};

                else if (patt==7) beats = new int[]{ 2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0};

                else if (patt==8) beats = new int[]{ 0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1};

                else if (patt==9) beats = new int[]{ 1,2,0,0,1,1,1,2,2,2,2,2,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};


                else beats = new int[]{  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};


                if (i<18) return beats[i-8];

                int winsum=0;

                for (int tx=8; tx<18; tx++) { if ((3 + a[tx] - b[tx])%3 == 1) { winsum++; } }

                if (winsum > 4) return beats[i-8];

            }

            // either no pattern was found or pattern beating was unsuccessful. Resort to final plan

            // ie, the look-and-say sequence

           int[] look_say_sequence = { 1,1,1,3,1,2,2,1,1,3,1,2,1,1,1,3,2,2,2,1,2,3,2,1,1,2,1,1,1,3,1,2,1,1,1,2,1,3,1,1,1,2,1,3,2,1,1,2,3,1,1,3,2,1,3,2,2,1,1,2,1,1,1,3,1,2,2,1,1,3,1,2,1,1,2,2,1,3,2,1,1,2,3,1,1,3,2,1,3,2,2,1,1,2,3,1,1,3,1,1,2,2,2,1,1,3,1,1,1,2,3,1,1,3,3,2,2,1,1,2,1,1,1,3,1,2,2,1,1,3,1,2,1,1,1,3,2,2,1,1,1,2,1,3,1,2,2,1,1,2,3,1,1,3,1,1,1,2,3,1,1,2,1,1,2,3,2,2,2,1,1,2,1,3,2,1,1,3,2,1,3,2,2,1,1,3,3,1,1,2,1,3,2,1,2,3,1,2,3,1,1,2,1,1,1,3,1,1,2,2,2,1,1,2,1,3,2,1,1,3,3,1,1,2,1,3,2,1,1,2,3,1,2,3,2,1,1,2,3,1,1,3,1,1,2,2,2,1,1,2,1,1,1,3,1,2,2,1,1,3,1,2,1,1,1,3,1,2,3,1,1,2,1,1,2,3,2,2,1,1,1,2,1,3,2,1,1,3,2,2,2,1,1,3,1,2,1,1,3,2,1,1 }; // when it hits 302 digits, this is it

           return look_say_sequence[i-8] % 3;

        }

        else if (algoNum==16) // darth2

        {

            if (i<5) return ROCK;

            if (i%5 == 0)

            {

                int[] runli = new int[i/5];

               for (int qrx=0; qrx< i/5; qrx++)

               {

                   int[] bchose = { 0,0,0 };

                   for (int vv=qrx*5; vv< qrx*5 + 5; vv++) {  bchose[b[vv]]++; }

                   int enemy_most = ROCK;


                   if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

                   if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;


                   if (bchose[enemy_most] == bchose[(enemy_most+1)%3])

                   {

                       int setvv = enemy_most;

                       for (int vvv=qrx*5; vvv< qrx*5+5; vvv++)

                       {

                           if (b[vvv]==enemy_most) setvv = enemy_most;

                           if (b[vvv]==(enemy_most+1)%3) setvv = (enemy_most+1)%3;

                        }

                        enemy_most = setvv;

                   }

                   else if (bchose[enemy_most] == bchose[(enemy_most+2)%3])

                   {

                     int setvv = enemy_most;

                       for (int vvv=qrx*5; vvv< qrx*5+5; vvv++)

                       {

                           if (b[vvv]==enemy_most) setvv = enemy_most;

                           if (b[vvv]==(enemy_most+2)%3) setvv = (enemy_most+2)%3;

                        }

                        enemy_most = setvv;

                   }

                    runli[qrx] = enemy_most;

                }

               // beat most often move from runli; if tie, use most recent of the ones tying

               int[] vchose = {0,0,0};

               for (int vvvv=0; vvvv<runli.length; vvvv++) { vchose[runli[vvvv]]++; }

               int vmost = ROCK;

               if (vchose[PAPER] > vchose[ROCK]) vmost = PAPER;

               if (vchose[SCISSORS] > vchose[vmost]) vmost = SCISSORS;

               if (vchose[vmost] == vchose[(vmost+1)%3] && vchose[vmost] == vchose[(vmost+1)%3]) vmost = runli[runli.length-1];

               else if (vchose[vmost] == vchose[(vmost+1)%3])

                   {

                       int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==vmost) setvv = vmost;

                           if (vbv==(vmost+1)%3) setvv = (vmost+1)%3;

                        }

                        vmost = setvv;

                   }

                   else if (vchose[vmost] == vchose[(vmost+2)%3])

                   {

                     int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==vmost) setvv = vmost;

                           if (vbv==(vmost+2)%3) setvv = (vmost+2)%3;

                        }

                        vmost = setvv;

                   }

                   else if (vchose[(vmost+1)%3] == vchose[(vmost+2)%3])

                   {

                     int setvv = vmost;

                       for (int vbv : runli)

                       {

                           if (vbv==(vmost+1)%3) setvv = (vmost+1)%3;

                           if (vbv==(vmost+2)%3) setvv = (vmost+2)%3;

                        }

                        vmost = setvv;

                   }

                   return (vmost+1)%3;

            }

            else

            {

                return a[i-1];

            }

        }

        else if (algoNum==17) // darth3

        {

            if (i<7) return (i+1)%3;

            if (b[i-1] == b[i-2] && b[i-2] == b[i-3])

            {

                int firstx=0, secondx=0;

                for (int ghgh=i-7; ghgh<i; ghgh++) { if (a[ghgh]==(b[i-1]+1)%3) { firstx++;} if (a[ghgh]==(b[i-1]+2)%3) { secondx++;} }

                if (firstx > secondx || firstx == secondx) return (b[i-1]+1)%3;

                else return (b[i-1]+2)%3;

            }

            else

            {

                int[] achose = {0,0,0};

                int[] bchose = {0,0,0};

               for (int vv=0; vv<i; vv++) { achose[a[vv]]++; bchose[b[vv]]++; }

               int tiebreaker;

               int me_least = ROCK, enemy_most = ROCK;


               if (bchose[PAPER] > bchose[ROCK]) enemy_most = PAPER;

               if (bchose[SCISSORS] > bchose[enemy_most]) enemy_most = SCISSORS;

               tiebreaker = enemy_most;

               if (bchose[enemy_most] == bchose[(enemy_most+1)%3] || bchose[enemy_most] == bchose[(enemy_most+2)%3]) { tiebreaker = -2;  }

               enemy_most = tiebreaker;


               if (achose[PAPER] < achose[ROCK]) me_least = PAPER;

               if (achose[SCISSORS] < achose[me_least]) me_least = SCISSORS;

               tiebreaker = me_least;

               if (achose[me_least] == achose[(me_least+1)%3] || achose[me_least] == achose[(me_least+2)%3]) { tiebreaker = -2;  }

               me_least = tiebreaker;


               if (me_least == -2)

               {

                   if (enemy_most == -2) { return (a[i-1]+2)%3; }

                   else { return (enemy_most+2)%3; }

                }

                else return me_least;


            }

        }

        else if (algoNum==18) // mrapple1

        {

            return (i+1)%3;

        }

        else if (algoNum==19) // medji1

        {

            if (i==0) return SCISSORS;

            if (i%5 != 0) return (a[i-1]+2)%3;

            return (a[i-1]+1)%3;

        }

       else if (algoNum==20) // medji2

        {

            if (i==0) return ROCK;

            if (i%3 != 0) return (a[i-1]+1)%3;

            return (a[i-1]+2)%3;

        }

        else if (algoNum==21) // patternSeeker (dawh)

        {

            if(i == 0)

            return(ROCK);

            int predicted = -1;

            int success = 0;

            Vector<Integer> patt = new Vector<Integer>();

            for(int j = 0; j < i; j++) {

                int move = b[j];

                if(patt.contains(move)) {

                    int idx = patt.indexOf(move)+1;

                    if(idx < patt.size()) {

                        predicted = patt.get(idx);

                    }

                }

                patt.add(move);


                if(j < i-1 && predicted == b[j+1])

                success++;

            }

            if(success > i/2) {

                int move = b[i-1];

                int idx = patt.indexOf(move)+1;

                if(idx > 0 && idx < patt.size())

                    return((patt.get(idx)+1)%3);

                }

                return((b[i-1]+1)%3);

            }

            else if (algoNum==22) // phil1

            {

                if (i==0) return PAPER;

                int[] best = {0,0,0};

                int ties = 0;

                for(int j=0; j<i; j++) {

                    if (a[j] == b[j]) ties += 1;

                    else

                    {

                        if (a[j] == ROCK && b[j] == PAPER) best[0] -= 1;

                        if (a[j] == PAPER && b[j] == SCISSORS) best[1] -= 1;

                        if (a[j] == SCISSORS && b[j] == ROCK) best[2] -= 1;


                        if (a[j] == ROCK && b[j] == SCISSORS) best[0] += 1;

                        if (a[j] == PAPER && b[j] == ROCK) best[1] += 1;

                        if (a[j] == SCISSORS && b[j] == PAPER) best[2] += 1;

                    }

                }


                int xx=ROCK;

                if (best[ROCK] < best[PAPER]) xx=ROCK;

                if (best[xx] < best[SCISSORS]) return SCISSORS;

                else if (best[SCISSORS] == best[xx] || best[ROCK]==best[PAPER]) return ties%3;

                else return xx;

                // end of phil1

            }

            else if (algoNum == 23)// phil2

            { 

                //this algorithm strives for an optimal sequence of moves.

                int index = 0;

                if (i == 0){

                    return ROCK;

                }

                else {

                    int[] array, best;

                    int index1 = 0, index2 = 0, check = 0;

                    int j = 0;

                    array = new int[i];

                    best = new int[3];

                    while (index1 < i && index2 < i){

                        if(check == 0){

                            if((a[index1] == ROCK && b[index2] == ROCK || b[index2] == PAPER)

                            || (a[index1] == PAPER && b[index2] == PAPER || b[index2] == SCISSORS)

                            || (a[index1] == SCISSORS && b[index2] == SCISSORS || b[index2] == ROCK)){

                                check = 1;

                                index2 += 1;

                            }

                            else{

                                check = 2;

                                index1 += 1;

                            }

                        }

                        else if(check == 1){

                            if((a[index1] == ROCK && b[index2] == ROCK || b[index2] == PAPER)

                            || (a[index1] == PAPER && b[index2] == PAPER || b[index2] == SCISSORS)

                            || (a[index1] == SCISSORS && b[index2] == SCISSORS || b[index2] == ROCK)){

                                index2 += 1;

                            }

                            else{

                                for(j = index1; j<index2; j++){

                                    array[j] = b[j];

                                }

                            }

                            check = 0;

                            index1 = index2;

                        }

                        else{

                            if((b[index2] == ROCK && a[index1] == ROCK || a[index1] == PAPER)

                            || (b[index2] == PAPER && a[index1] == PAPER || a[index1] == SCISSORS)

                            || (b[index2] == SCISSORS && a[index1] == SCISSORS || a[index1] == ROCK)){

                                index1 += 1;

                            }

                            else{

                                for(j = index1; j<index2; j++){

                                    array[j] = a[j];

                                }

                                check = 0;

                                index2= index1;

                            }

                        }

                    }

                    if(index1 > index2){

                        for(j = index2; j<index1; j++){

                            array[j] = b[j];

                        }

                    }

                    else{

                        for(j = index1; j<index2; j++){

                            array[j] = a[j];

                        }

                    }

                    for(j = 0; j< i; j++){

                        best[array[j]]++;

                    }

                    int y = ROCK;

                    if(best[ROCK] <best[PAPER]){

                        y = PAPER;

                    }

                    if(best[y] <best[SCISSORS]){

                        return SCISSORS;

                    }

                    else{

                        return y;

                    }

                }

            }

            else if (algoNum==24) //unr1

            {

                if (i==0) return PAPER;

                int yeah = PAPER;

                for (int xh=0; xh<i; xh++)

                {

                    yeah = yeah ^ xh;

                }

                return (yeah%3);

            }

            else if (algoNum==25) //unr2

            {

                if (i<6) return (i+1)%3;

                int[] prev = { b[i-6], b[i-5], b[i-4], b[i-3], b[i-2], b[i-1] };

                int[][] patns = {

                               {0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2},

                               {0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,2,1},

                               {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

                               {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

                               {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},

                               {0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},

                               {0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2},

                               {1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2}

                            };

                boolean match=false;

                int matchPat = -1, matchIndex = -1;

                yeahloop: for (int iiz=0; iiz<patns.length; iiz++)

                {

                    for (int iiiz=0; iiiz<44; iiiz++)

                    {

                        if (patns[iiz][iiiz] == prev[0] 

                        && patns[iiz][iiiz+1] == prev[1]

                        && patns[iiz][iiiz+2] == prev[2]

                        && patns[iiz][iiiz+3] == prev[3]

                        && patns[iiz][iiiz+4] == prev[4]

                        && patns[iiz][iiiz+5] == prev[5]) { match=true; matchPat = iiz; matchIndex = iiiz+6; }

                    }

                    if (match) break yeahloop;

                }

                if (match)

                {

                    return (patns[matchPat][matchIndex] + 1)%3;

                }

                else

                {

                    int sumt = 0;

                    for (int sumin=0; sumin<i; sumin++) {sumt += b[sumin];}

                    double mean = (double)sumt / (double)i;

                    double sdev = 0.0;

                    for (int sumin=0; sumin<i; sumin++) {sdev += (double)((b[sumin] - mean) * (b[sumin] - mean));}

                    sdev /= (double)i; // divide by i, not i-1, because we have a complete population

                    sdev = Math.sqrt(sdev); // sdev is now the standard deviation of b's moves

                    boolean[] withinOne = {false, false, false};

                    if (0 > mean - sdev && 0 < mean + sdev) withinOne[0] = true;

                    if (1 > mean - sdev && 1 < mean + sdev) withinOne[1] = true;

                    if (2 > mean - sdev && 2 < mean + sdev) withinOne[2] = true;

                    if (withinOne[i%3]) return i%3;

                    else if (withinOne[(i+1)%3]) return (i+1)%3;

                    else return (i+2)%3;

                }


            }

            else if (algoNum==26) //phil3

            {

                int[] best;

                if(i == 0){

                    return ROCK;

                }

                best = new int[3];

                for(int j = 0; j <i; j++){

                    if(a[j] == b[j]){

                        best[a[j]]++;

                    }

                    else if(a[j] == ROCK && b[j] == SCISSORS){

                        best[ROCK]++;

                    }

                    else if(a[j] == PAPER && b[j] == ROCK){

                        best[PAPER]++;

                    }

                    else if(a[j] == SCISSORS && b[j] == PAPER){

                        best[SCISSORS]++;

                    }

                    else if(b[j] == ROCK && a[j] == SCISSORS){

                            best[ROCK]++;

                        }

                        else if(b[j] == PAPER && a[j] == ROCK){

                            best[PAPER]++;

                        }

                        else if(b[j] == SCISSORS && a[j] == PAPER){

                            best[SCISSORS]++;

                        }

                    }

                    int y = ROCK;

                    if(best[ROCK] < best[PAPER]){

                        y = PAPER;

                    }

                    if(best[y] < best[SCISSORS]){

                        return SCISSORS;

                    }

                    else{

                        return y;

                    }

             }

            else if (algoNum==27) //apple3

            {

                int nkk = ((i%6) / 3) * 2;

                if (i%6==0) nkk++;

                nkk += (2 * (i /6));

                return (nkk % 3);

            }

            else if (algoNum==28) //backatyou2

            {

                int[] hisWinMoves = new int[3];

                int[] hisLoseMoves = new int[3];

                int[] hisTieMoves = new int[3];


        int myMove = ROCK, hisMove = ROCK;

        int myWins = 0, hisWins = 0;

        for(int j = 0; j < i-1; j++) {

                myMove = a[j];

                hisMove = b[j];

                if(myMove == ROCK && hisMove == SCISSORS)

                        myWins++;

                else if(myMove == SCISSORS && hisMove == PAPER)

                        myWins++;

                else if(myMove == PAPER && hisMove == ROCK)

                        myWins++;


                if(hisMove == ROCK && myMove == SCISSORS)

                        hisWins++;

                else if(hisMove == SCISSORS && myMove == PAPER)

                        hisWins++;

                else if(hisMove == PAPER && myMove == ROCK)

                        hisWins++;


                if(hisWins > myWins) {

                        hisWinMoves[hisMove]++;

                } else if(myWins > hisWins) {

                        hisLoseMoves[hisMove]++;

                } else {

                        hisTieMoves[hisMove]++;

                }

        }


        int[] myPick;

        if(hisWins > myWins) {

                myPick = hisWinMoves;

        } else if(myWins > hisWins) {

                myPick = hisLoseMoves;

        } else {

                myPick = hisTieMoves;

        }

        int max;

        if(i % 2 == 0) {

                max =  ROCK;

                if(myPick[PAPER] > myPick[ROCK]) {

                        max = PAPER;

                        if(myPick[SCISSORS] > myPick[PAPER])

                                max = SCISSORS;

                } else if(myPick[SCISSORS] > myPick[ROCK])

                        max = SCISSORS;

        } else

                max = hisMove;

        int move;

        if(max == ROCK)

                move = PAPER;

        else if(max == PAPER)

                move = SCISSORS;

        else 

                move = ROCK;

        return(move);

            }

            else if (algoNum==29) //fib2

            {

                if (i<2) return i;

                if (i==93 || i==99) return 2;

                if (i>92) return Math.abs(i - 96);

                long fa=0,fb=1,tempfib=0;

                for (int fby=0; fby<i-1; fby++)

                {

                    tempfib = fb;

                    fb += fa;

                    fa = tempfib;

                }

                return (int)(fb % 3);

            }

            else if (algoNum==30) //apple4

            {

                return ((((i / 15) % 3) - (i % 3) + 4) % 3);

            }

            else return ROCK;

        //return ROCK;

    }


    public static String conv(int yeah)

    {

        if (yeah==ROCK) return "  rock  ";

        if (yeah==PAPER) return " paper  ";

        if (yeah==SCISSORS) return "scissors";

        return "you've got a problem";

    }


   public static void main(String[] args)

   {

       String[] names = { "hawk", "test1", "test2", "test3", "izzy", "phil", "backatyou", "dnoob", "rand", "allrock", "jarze", "medji" , "mr_apple_pi", "darth1", "izzy1", "izzy2", "darth2", "darth3", "mrapple1", "medji1", "medji2", "patternSeeker", "phil1", "phil2", "unr1", "unr2", "phil3", "apple3", "backatyou2", "fib2", "apple4" };


       boolean ohyeah = true;

       while (ohyeah)

    {

        Scanner inp = new Scanner(System.in);

       System.out.println("\n\nWelcome to R/P/S!");

       for (int j=0; j<names.length; j++) { System.out.println(j + " (" + names[j] + ")");}

       System.out.print("\n\nEnter the numbers of the programs you wish to fight, separated by spaces:\n");

       String nextln = inp.nextLine();

       int[] algos;

       if (nextln.equals("x"))

       {

           algos = new int[]{ 2, 4, 14, 15, 10, 11, 19, 20, 12, 18, 30, 13, 29, 17, 21, 28, 24, 25, 5, 22, 23 };

        }

        else

        {

       String[] splitup = nextln.split(" ");

       algos = new int[splitup.length];

       for (int hjk=0; hjk<splitup.length; hjk++) { algos[hjk] = Integer.parseInt(splitup[hjk]); }

      }


            String financ = "";

            int n = algos.length;  double[] nw = new double[n];

            //int numGames = n/2 * (n - 1);

            /* some data collection */ int curspread = 0; String spreadmsg = "All games had a spread of zero, weird!";

            for (int nn=0; nn<n; nn++)

            {

                for (int nnn = nn+1; nnn<n; nnn++)

                {

                    // game between algos[nn] and algos[nnn]

                    int algo1 = algos[nn]; int algo2 = algos[nnn];


                    System.out.print("\n\n"+names[algo1]+" vs "+names[algo2]+"\n");


                   int[] ar1 = new int[ROUNDS];

                   int[] ar2 = new int[ROUNDS];


                   int[] wins = new int[ROUNDS];


                   for (int k=0; k<ROUNDS; k++)

                   {

                           ar1[k] = rpsgo(algo1, k, ar1, ar2);

                           ar2[k] = rpsgo(algo2, k, ar2, ar1);

                           wins[k] = ( 3 + ar1[k] - ar2[k] ) % 3;

                           // 0 -> tie

                           // 1 -> one wins

                           // 2 -> two wins

                   }


                   int oneWins=0; int twoWins=0;

                   for (int l=0; l<ROUNDS; l++)

                   {

                       System.out.println(conv(ar1[l]) + " vs " + conv(ar2[l]));

                       if (wins[l]==1) { oneWins++; }

                       if (wins[l]==2) { twoWins++; }

                    }

                    int ties = ROUNDS - oneWins - twoWins; String msg1, msg2;

                    if (oneWins > twoWins + 1) { msg2 = names[algo1]+" wins!!!"; nw[nn]++; }

                    else if (twoWins > oneWins + 1) { msg2 = names[algo2]+" wins!!!"; nw[nnn]++; }

                    else { msg2 = "It was a tie!!!"; nw[nn] += 0.5; nw[nnn] += 0.5; }

                    msg1 = "\n"+names[algo1]+" won "+oneWins+" games and "+names[algo2]+" won " +twoWins+ " ~ there were " + ties + " ties";

                    System.out.println(msg1);

                    System.out.println(msg2);

                    financ += (names[algo1]+" vs "+names[algo2] + ": " + msg2 + "\n");

                    if (Math.abs(oneWins - twoWins) > curspread) { curspread = Math.abs(oneWins - twoWins); spreadmsg = msg1; }

                    else if (Math.abs(oneWins - twoWins) == curspread) { spreadmsg += msg1; }

                }

            }

            System.out.print("\n\nFinal Results:\n" + financ + "\n\nWin Count:\n");

            for (int abc=0; abc<n; abc++) System.out.println(names[algos[abc]]+": "+nw[abc]);


            System.out.print("\n\nType y for analysis ");

            if (inp.next().toLowerCase().charAt(0) == 'y')

            {

                double nm = (double)(n-1) / 2.0;

                double sdv = 0.0, mad = 0.0;

                for (int suminx=0; suminx<nw.length; suminx++) {sdv += ((double)((nw[suminx] - nm) * (nw[suminx] - nm))); mad += (double)Math.abs(nw[suminx] - nm);}

                sdv /= (double)(nw.length); mad /= (double)(nw.length);

                sdv = Math.sqrt(sdv);

                System.out.printf("%n%n[Algos: %d] [Games: %d] [Average Score: %.1f] [Sdev: %.3f] [MAD: %.3f]",n, (n*(n-1)) / 2, nm, sdv, mad);

                /* now present in order */ System.out.print("\n\nFrom Greatest to Least:\n");


               int[] nw_o = new int[nw.length]; boolean[] jk = new boolean[nw.length]; int ngr;

               for (int nnhz=0; nnhz<nw.length; nnhz++) jk[nnhz] = true;

               for (int nnh=0; nnh<nw.length; nnh++)

               {

                   ngr=0;

                   nhlp: for (int nindx=0; nindx<nw.length; nindx++)

                   {

                       if (jk[nindx]) { ngr=nindx; break nhlp; }

                    }

                   for (int nind=ngr; nind<nw.length; nind++)

                   {

                       if (nw[nind] > nw[ngr] && jk[nind]) { ngr = nind; }

                    }

                    nw_o[nnh]=ngr; jk[ngr] = false;

                }

                for (int nnhx=0; nnhx<nw.length; nnhx++) System.out.println(names[algos[nw_o[nnhx]]]+": "+nw[nw_o[nnhx]]);

                System.out.println("\nThe biggest blowout game(s) was(were): " + spreadmsg);

            }


            System.out.print("\n\nType y to play again ");

            ohyeah = false;

            if (inp.next().toLowerCase().charAt(0) == 'y') ohyeah = true;

        }

        System.out.print("\nThanks for playing!\n");

    }


}


Link to comment
Share on other sites

  • 0

I made a new program, unr3, and threw it into the mix...

[Algos: 22] [Games: 231] [Average Score: 10.5] [sdev: 2.796] [MAD: 2.045]

From Greatest to Least:

darth1: 16.0

patternSeeker: 15.5

backatyou2: 15.0

mrapple1: 13.0

test2: 11.5

jarze: 11.5

medji1: 11.5

izzy2: 11.0

medji: 11.0

medji2: 11.0

fib2: 11.0

unr2: 10.5

unr3: 10.5

izzy1: 10.0

apple4: 9.5

darth3: 9.5

mr_apple_pi: 9.0

unr1: 8.5

phil: 8.0

izzy: 7.5

phil1: 6.0

phil2: 4.0

The biggest blowout game(s) was(were):

test2 won 100 games and izzy1 won 0 ~ there were 0 ties

test2 won 0 games and mrapple1 won 100 ~ there were 0 ties

test2 won 0 games and darth1 won 100 ~ there were 0 ties

test2 won 0 games and unr2 won 100 ~ there were 0 ties

backatyou2 won 100 games and phil2 won 0 ~ there were 0 ties

phil2 won 0 games and unr3 won 100 ~ there were 0 ties

Type y to play again n

Thanks for playing!


 else if (algoNum==31) //unr3

            {

                 if (i==0) return PAPER; int sumv=0;

                 for (int zyx=0; zyx<i; zyx++) sumv += b[zyx];

                 return ((int)((double)(sumv) / (double)(i) + 1.2) % 3);

            }

I must admit though that originally it added 1.5 (.5 then truncating to emulating rounding, the +1 to play what beats it), not 1.2, and it won 9.0 games. Through some random trial and error I found that adding 1.2 boosted it all the way to 10.5 wins. Couldn't say why though :P

Link to comment
Share on other sites

  • 0

so we doing a third tourney? not quite sure what I could do for my program.

I have a few ideas bouncing around though.

Yeah I'm thinking we should each write a new program (or at least copy over our previous one if we really want to make no changes it all). We should spend time and care on our programs and make them our champions. We should NOT however test them in a simulated java arena against other algos (I promise not to do so :) ). Tourney Three will be the ultimate. We'll each get one submission, called our name followed by an exclamation point, so mine will be "unreality!" and dawh's will be "dawh!"

At the very least we should get the following:

unreality!

phillip1882!

dawh!

jarze!

mrapple!

darthnoob!

medji!

izzy!

but in addition to those eight we should try to get some more. In a few days we can set a deadline for T3 and from now until T3 we should advertise around Brainden (and beyond) and try to get as many people as possible to participate! We've learned a lot in all the matches up to this point and full source code is available as well as any simulation runs between the algos that are already now inside the machine - just make a request here on the thread to run such a simulation (but any newly conceived algos are not to be electronically tested).

Good luck everybody!!!!!! :D May the best algorithm win

Link to comment
Share on other sites

  • 0

lol @ needing to use long instead of int, and then needing to determine the last 9 rounds manually.

Awesome @ Darth1 getting bumped to 1st place! Huzzah! Hahaha. I think the modified T2 should go down in the record books as the official T2. =P

I wonder if any algorithm was able to defeat Fib2 with a large margin

Hm... what did Phil's algorithms do? They performed poorly overall, but did well against Fib2, and apple4, another static pattern

Link to comment
Share on other sites

  • 0

my first algorithm was kinda weird, it used the square free sub rules to try to get an anti pattern as it were.

my remaining algorithms were variants of the hawk algorithm.

one added all winning moves minus all losing moves, and took move that won the most.

my other two were very similar in nature, except valued ties as well.

Link to comment
Share on other sites

  • 0

also, just because you can't run a simulation of a new algo against other algos doesn't mean you can't work stuff out in your head or on paper :thumbsup: For example, at first I was thinking of doing (i*i) % 3, but then I did it out in my head and realized that it was the simple pattern 0,1,1 repeated

every perfect square (i^2) can be represented as one of these three, where n is an integer:

(3n+0)^2

(3n+1)^2

(3n+2)^2

(3n+0)^2 % 3 = (9n^2) % 3 = 0

(3n+1)^2 % 3 = (9n^2 + 6n + 1) % 3 = 1

(3n+2)^2 % 3 = (9n^2 + 12n + 4) % 3 = 4%3 = 1

so anyway most ideas can be thought through first - sometimes this can be a lot more insightful than just computation anyway :)

Link to comment
Share on other sites

  • 0

I wrote a purely theoretical program (not going to be "unreality!", this one is just to think about) called "collatz" based on the Collatz conjecture/ 3n+1 problem. It's intended to be at the very least, pseudorandom


if (i==0) return SCISSORS;

                int q = 1;

                for (int qqq=0; qqq<i; qqq++) q += (a[qqq] + b[qqq] + qqq);

                int steps = 0;

                while (q != 1)

                {

                    steps++;

                    if (q%2 == 0) q /= 2;

                    else q = 3*q + 1;

                }

                return steps % 3;

a random program is going to win 1/3 of the time, tie 1/3 of the time, and lose 1/3 of the time***. We know that 'n' is the number of programs battling in a tournament, so the random/pseudorandom algo will play n-1 games

points = wins + .5*ties = (n-1)/3 + .5(n-1)/3 = 2(n-1) + 1(n-1) all over 6 = (n-1)/2

which as we know is the average score overall (n(n-1)/2 total possible points for n people, so average score per person will be (n-1)/2). Assuming the standard deviation is at least 1 or 2 (so far it's consistently been around between 2 and 2.5), this means that any (pseudo)random program won't do top notch but should hang around average.

*** this is definitely true for random vs. random, but it applies to random vs. nonrandom too, I'm pretty certain. Any program that has a locked in, static, based-on-'i' or random pattern has 1/3-1/3-1/3 chances against a random opponent. And any algo that uses the enemy's former actions to guess at what they'll do next will fail against a random algorithm and be just as random. Of course if the pseudorandom algo isn't sufficiently pseudorandom and the pattern-predicting algo is VERY good, it might be able to overcome it, and that's all the better for the pattern watcher. So this adds to the above proof that any random program will do around average.

Link to comment
Share on other sites

  • 0

Unreality, could you do me a favor and run a game between two algorithms each Math.random()*3, and then run the game 100 times? I want to see how often the tie when every game is as it is now, with 100 rounds. I'm wondering whether or not 100 rounds is sufficiently large to achieve "the law of large numbers" of probability (or in other words, I want to know if PatternSeeker and Darth1 and the rest are really that much better, or they just got lucky).

Algorithm I thought of looking at your Collatz:


if (i==0) return SCISSORS;

                double allSubtracted = 0;

                double rounds = i;

                for (int roundThru=0; roundThru<i; roundThru++) allSubtracted += (a[roundThru] - b[roundThru]);

                return ((int) Math.pow(rounds, allSubtracted/rounds))%3;

(just so you know... I don't like your use of variables declared as letters or strings of letters. Bad programming practice!) And a Collatz algorithm that isn't supposed to be as random:

if (i==0) return SCISSORS;

                int q = 1;

                for (int roundThru = 0; roundThru<i; roundThru++)

                {

                    if (b[roundThru] < 2) q *= 2//weighs this to be more (on average twice more) likely

                    else q = (q-1)/3;//yeah, I know that would get messy if it weren't for the fact that this uses int. I dun care!

                }

                q += a[i];

                return q % 3;

Link to comment
Share on other sites

  • 0

Unreality, could you do me a favor and run a game between two algorithms each Math.random()*3, and then run the game 100 times? I want to see how often the tie when every game is as it is now, with 100 rounds. I'm wondering whether or not 100 rounds is sufficiently large to achieve "the law of large numbers" of probability (or in other words, I want to know if PatternSeeker and Darth1 and the rest are really that much better, or they just got lucky).

Welcome to R/P/S!

0 (hawk)

1 (test1)

2 (test2)

3 (test3)

4 (izzy)

5 (phil)

6 (backatyou)

7 (dnoob)

8 (rand)

9 (allrock)

10 (jarze)

11 (medji)

12 (mr_apple_pi)

13 (darth1)

14 (izzy1)

15 (izzy2)

16 (darth2)

17 (darth3)

18 (mrapple1)

19 (medji1)

20 (medji2)

21 (patternSeeker)

22 (phil1)

23 (phil2)

24 (unr1)

25 (unr2)

26 (phil3)

27 (apple3)

28 (backatyou2)

29 (fib2)

30 (apple4)

31 (unr3)

32 (phil_pseudo)

33 (collatz)

34 (phillip!)

Enter the numbers of the programs you wish to fight, separated by spaces:

8 8

rand vs rand

scissors vs rock

scissors vs scissors

paper vs rock

rock vs scissors

scissors vs scissors

paper vs rock

rock vs scissors

paper vs paper

rock vs paper

paper vs paper

rock vs rock

paper vs rock

rock vs paper

rock vs scissors

rock vs rock

paper vs scissors

paper vs scissors

scissors vs paper

paper vs scissors

paper vs paper

rock vs rock

rock vs paper

rock vs rock

scissors vs scissors

scissors vs scissors

rock vs paper

paper vs scissors

scissors vs paper

rock vs paper

paper vs paper

rock vs rock

paper vs paper

scissors vs scissors

rock vs paper

scissors vs scissors

rock vs rock

scissors vs paper

rock vs scissors

rock vs paper

paper vs scissors

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs scissors

rock vs scissors

rock vs scissors

paper vs rock

scissors vs scissors

scissors vs rock

paper vs rock

paper vs paper

scissors vs rock

paper vs paper

paper vs paper

paper vs paper

scissors vs paper

rock vs rock

rock vs rock

scissors vs paper

rock vs scissors

scissors vs paper

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

paper vs paper

rock vs paper

rock vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs rock

rock vs paper

scissors vs paper

rock vs scissors

scissors vs paper

paper vs scissors

scissors vs rock

paper vs scissors

paper vs paper

scissors vs scissors

paper vs rock

scissors vs rock

rock vs scissors

paper vs scissors

rock vs rock

rock vs paper

paper vs rock

paper vs scissors

paper vs paper

paper vs scissors

rock vs rock

scissors vs paper

rock vs scissors

rock vs rock

rock vs rock

paper vs paper

scissors vs paper

rock vs paper

paper vs paper

rand won 30 games and rand won 32 ~ there were 38 ties

rand wins!!!

Final Results:

rand vs rand: rand wins!!!

Win Count:

rand: 0.0

rand: 1.0

Type y for analysis y

[Algos: 2] [Games: 1] [Average Score: 0.5] [sdev: 0.500] [MAD: 0.500]

From Greatest to Least:

rand: 1.0

rand: 0.0

The biggest blowout game(s) was(were):

rand won 30 games and rand won 32 ~ there were 38 ties

Type y to play again n

Thanks for playing!

The important part from the single game was this: rand won 30 games and rand won 32 ~ there were 38 ties

I ran some more games:

rand won 41 games and rand won 34 ~ there were 25 ties

rand won 32 games and rand won 29 ~ there were 39 ties

rand won 31 games and rand won 38 ~ there were 31 ties

They're all within the expected deviation from the mean (which would be 33.3333333etc). The probability for them both to win the same or within 1 of each other (and thus tie) is quite low. To make random algos tie eachother ~68% of the time I'd have to extend the range of a tie out more.

To answer your question I think 100 does satisfy the law of large numbers. The pattern seeking algos, darth1 included, didn't just get lucky. All algos are determinstic (except for 'rand' for just testing purposes) and the pattern seeking ones try to discern the enemy's next move based on past behavior...

(just so you know... I don't like your use of variables declared as letters or strings of letters. Bad programming practice!)

Yes it's a bad habit of mine :P

Link to comment
Share on other sites

  • 0

So, a few questions before I submit something:

A.) If I were to write this up myself, what language should it be in? (And if it's Java, do you care what libraries I use?)

B.) Are there any rules other than the basic Rock Paper Scissors?

C.) I'm assuming you just want the code PM'd to you, Unreality?

Link to comment
Share on other sites

  • 0

So, a few questions before I submit something:

A.) If I were to write this up myself, what language should it be in? (And if it's Java, do you care what libraries I use?)

It's in Java. Your code will be run as part of a larger function. Each round (0..99) your code will be executed again and must output 0 (ROCK), 1 (PAPER), or 2 (SCISSORS). We already have Scanner, ArrayList, Vector and Random imported for various purposes, but out of those four the only ones you can use in your algo are ArrayList and Vector. If you need to import something else just ask me first :thumbsup:

You'll get three variables to use in your algo:

int i (contains the current round number 0..99)

int[] a (contains all of your moves so far from a[0] to a[i-1])

int[] b (contains all of the opponent's moves so far from b[0] to b[i-1])

B.) Are there any rules other than the basic Rock Paper Scissors?

Nope... SCISSORS (2) beats PAPER (1) which beats ROCK (0) which beats scissors of course. Each round both algos will output 0, 1 or 2, and you must return it as an int datatype. There are four constants by the way:

public static final int ROCK = 0;

public static final int PAPER = 1;

public static final int SCISSORS = 2;

public static final int ROUNDS = 100;

C.) I'm assuming you just want the code PM'd to you, Unreality?

yeah that's fine :thumbsup:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...