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

here's 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 = 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

           /* later haha

             ArrayList<Integer> looksay = new ArrayList<Integer>(50);

            ArrayList<Integer> newlook = new ArrayList<Integer>(50);

            looksay.add(1); looksay.add(1);

            while (looksay.size() < 50)

            {

                newlook.clear();

                int curvalt = 1; int numcurs = 1;

                for (int tw=1; tw<looksay.size(); tw++)

                {

                    if (looksay.get(tw)==curvalt) numcurs++;

                    else { newlook.add(numcurs); newlook.add(curvalt); numcurs = 0; curvalt = looksay.get(tw); }

                }

                looksay = newlook;

            }

            return looksay.get(i) % 3;


            not working so for now i'll just the array haha:

            */

           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;

            index2 = index1;

         }

         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;

               index1= index2;

            }

         }

      }

      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 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" };


       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, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26 };

        }

        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);

            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 msg;

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

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

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

                    System.out.println("\n"+names[algo1]+" won "+oneWins+" games and "+names[algo2]+" won " +twoWins+ " ~ there were " + ties + " ties");

                    System.out.println(msg);

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

                }

            }

            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 to play again ");

            ohyeah = false;

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

        }

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

    }


}


all algos work except for #23 (phil2)

Running the "x" option (2, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26), this is the results:

Final Results:

test2 vs izzy: test2 wins!!!

test2 vs phil: test2 wins!!!

test2 vs jarze: It was a tie!!!

test2 vs medji: test2 wins!!!

test2 vs mr_apple_pi: It was a tie!!!

test2 vs darth1: darth1 wins!!!

test2 vs izzy1: test2 wins!!!

test2 vs izzy2: test2 wins!!!

test2 vs darth2: test2 wins!!!

test2 vs darth3: darth3 wins!!!

test2 vs mrapple1: mrapple1 wins!!!

test2 vs medji1: It was a tie!!!

test2 vs medji2: medji2 wins!!!

test2 vs patternSeeker: patternSeeker wins!!!

test2 vs phil1: It was a tie!!!

test2 vs unr1: test2 wins!!!

test2 vs unr2: unr2 wins!!!

test2 vs phil3: It was a tie!!!

izzy vs phil: izzy wins!!!

izzy vs jarze: jarze wins!!!

izzy vs medji: It was a tie!!!

izzy vs mr_apple_pi: It was a tie!!!

izzy vs darth1: darth1 wins!!!

izzy vs izzy1: It was a tie!!!

izzy vs izzy2: izzy wins!!!

izzy vs darth2: darth2 wins!!!

izzy vs darth3: izzy wins!!!

izzy vs mrapple1: mrapple1 wins!!!

izzy vs medji1: medji1 wins!!!

izzy vs medji2: medji2 wins!!!

izzy vs patternSeeker: patternSeeker wins!!!

izzy vs phil1: izzy wins!!!

izzy vs unr1: unr1 wins!!!

izzy vs unr2: unr2 wins!!!

izzy vs phil3: It was a tie!!!

phil vs jarze: phil wins!!!

phil vs medji: medji wins!!!

phil vs mr_apple_pi: mr_apple_pi wins!!!

phil vs darth1: darth1 wins!!!

phil vs izzy1: izzy1 wins!!!

phil vs izzy2: izzy2 wins!!!

phil vs darth2: phil wins!!!

phil vs darth3: darth3 wins!!!

phil vs mrapple1: It was a tie!!!

phil vs medji1: medji1 wins!!!

phil vs medji2: phil wins!!!

phil vs patternSeeker: phil wins!!!

phil vs phil1: phil wins!!!

phil vs unr1: phil wins!!!

phil vs unr2: unr2 wins!!!

phil vs phil3: It was a tie!!!

jarze vs medji: jarze wins!!!

jarze vs mr_apple_pi: jarze wins!!!

jarze vs darth1: jarze wins!!!

jarze vs izzy1: jarze wins!!!

jarze vs izzy2: jarze wins!!!

jarze vs darth2: jarze wins!!!

jarze vs darth3: jarze wins!!!

jarze vs mrapple1: It was a tie!!!

jarze vs medji1: medji1 wins!!!

jarze vs medji2: medji2 wins!!!

jarze vs patternSeeker: patternSeeker wins!!!

jarze vs phil1: It was a tie!!!

jarze vs unr1: It was a tie!!!

jarze vs unr2: jarze wins!!!

jarze vs phil3: jarze wins!!!

medji vs mr_apple_pi: It was a tie!!!

medji vs darth1: medji wins!!!

medji vs izzy1: izzy1 wins!!!

medji vs izzy2: medji wins!!!

medji vs darth2: It was a tie!!!

medji vs darth3: medji wins!!!

medji vs mrapple1: mrapple1 wins!!!

medji vs medji1: medji wins!!!

medji vs medji2: medji2 wins!!!

medji vs patternSeeker: patternSeeker wins!!!

medji vs phil1: It was a tie!!!

medji vs unr1: medji wins!!!

medji vs unr2: medji wins!!!

medji vs phil3: medji wins!!!

mr_apple_pi vs darth1: darth1 wins!!!

mr_apple_pi vs izzy1: izzy1 wins!!!

mr_apple_pi vs izzy2: mr_apple_pi wins!!!

mr_apple_pi vs darth2: It was a tie!!!

mr_apple_pi vs darth3: mr_apple_pi wins!!!

mr_apple_pi vs mrapple1: mr_apple_pi wins!!!

mr_apple_pi vs medji1: medji1 wins!!!

mr_apple_pi vs medji2: medji2 wins!!!

mr_apple_pi vs patternSeeker: patternSeeker wins!!!

mr_apple_pi vs phil1: mr_apple_pi wins!!!

mr_apple_pi vs unr1: unr1 wins!!!

mr_apple_pi vs unr2: mr_apple_pi wins!!!

mr_apple_pi vs phil3: mr_apple_pi wins!!!

darth1 vs izzy1: izzy1 wins!!!

darth1 vs izzy2: darth1 wins!!!

darth1 vs darth2: darth1 wins!!!

darth1 vs darth3: darth1 wins!!!

darth1 vs mrapple1: darth1 wins!!!

darth1 vs medji1: darth1 wins!!!

darth1 vs medji2: darth1 wins!!!

darth1 vs patternSeeker: patternSeeker wins!!!

darth1 vs phil1: darth1 wins!!!

darth1 vs unr1: darth1 wins!!!

darth1 vs unr2: darth1 wins!!!

darth1 vs phil3: It was a tie!!!

izzy1 vs izzy2: izzy1 wins!!!

izzy1 vs darth2: izzy1 wins!!!

izzy1 vs darth3: izzy1 wins!!!

izzy1 vs mrapple1: mrapple1 wins!!!

izzy1 vs medji1: medji1 wins!!!

izzy1 vs medji2: medji2 wins!!!

izzy1 vs patternSeeker: patternSeeker wins!!!

izzy1 vs phil1: izzy1 wins!!!

izzy1 vs unr1: unr1 wins!!!

izzy1 vs unr2: izzy1 wins!!!

izzy1 vs phil3: izzy1 wins!!!

izzy2 vs darth2: darth2 wins!!!

izzy2 vs darth3: izzy2 wins!!!

izzy2 vs mrapple1: mrapple1 wins!!!

izzy2 vs medji1: izzy2 wins!!!

izzy2 vs medji2: It was a tie!!!

izzy2 vs patternSeeker: patternSeeker wins!!!

izzy2 vs phil1: phil1 wins!!!

izzy2 vs unr1: It was a tie!!!

izzy2 vs unr2: izzy2 wins!!!

izzy2 vs phil3: izzy2 wins!!!

darth2 vs darth3: darth2 wins!!!

darth2 vs mrapple1: mrapple1 wins!!!

darth2 vs medji1: darth2 wins!!!

darth2 vs medji2: medji2 wins!!!

darth2 vs patternSeeker: patternSeeker wins!!!

darth2 vs phil1: darth2 wins!!!

darth2 vs unr1: unr1 wins!!!

darth2 vs unr2: unr2 wins!!!

darth2 vs phil3: darth2 wins!!!

darth3 vs mrapple1: It was a tie!!!

darth3 vs medji1: darth3 wins!!!

darth3 vs medji2: darth3 wins!!!

darth3 vs patternSeeker: darth3 wins!!!

darth3 vs phil1: darth3 wins!!!

darth3 vs unr1: darth3 wins!!!

darth3 vs unr2: unr2 wins!!!

darth3 vs phil3: darth3 wins!!!

mrapple1 vs medji1: It was a tie!!!

mrapple1 vs medji2: mrapple1 wins!!!

mrapple1 vs patternSeeker: patternSeeker wins!!!

mrapple1 vs phil1: It was a tie!!!

mrapple1 vs unr1: It was a tie!!!

mrapple1 vs unr2: unr2 wins!!!

mrapple1 vs phil3: mrapple1 wins!!!

medji1 vs medji2: It was a tie!!!

medji1 vs patternSeeker: patternSeeker wins!!!

medji1 vs phil1: medji1 wins!!!

medji1 vs unr1: medji1 wins!!!

medji1 vs unr2: medji1 wins!!!

medji1 vs phil3: It was a tie!!!

medji2 vs patternSeeker: medji2 wins!!!

medji2 vs phil1: medji2 wins!!!

medji2 vs unr1: It was a tie!!!

medji2 vs unr2: unr2 wins!!!

medji2 vs phil3: It was a tie!!!

patternSeeker vs phil1: It was a tie!!!

patternSeeker vs unr1: It was a tie!!!

patternSeeker vs unr2: patternSeeker wins!!!

patternSeeker vs phil3: patternSeeker wins!!!

phil1 vs unr1: unr1 wins!!!

phil1 vs unr2: unr2 wins!!!

phil1 vs phil3: phil1 wins!!!

unr1 vs unr2: unr2 wins!!!

unr1 vs phil3: phil3 wins!!!

unr2 vs phil3: unr2 wins!!!

Win Count:

test2: 9.5

izzy: 6.0

phil: 7.0

jarze: 12.0

medji: 10.0

mr_apple_pi: 9.0

darth1: 13.5

izzy1: 10.5

izzy2: 6.0

darth2: 7.0

darth3: 8.5

mrapple1: 11.0

medji1: 10.0

medji2: 11.0

patternSeeker: 14.0

phil1: 4.5

unr1: 7.5

unr2: 10.0

phil3: 4.0

best programs:

patternSeeker

darth1

jarze

mrapple1, medji2

izzy

unr2, medji1, medji

Link to comment
Share on other sites

  • 0

Sweeeeeeeeet! I had higher expectations for my Darth1 than Darth2 or 3, so looks like I actually threw something good together.

Btw, did you run my earlier Fibonacci based program anywhere?

So how does PatternSeeker work? And JarZe's?

Interesting how test2 still got a respectable 9.5

And... aww, Darth1 lost to PatternSeeker and JarZe, haha

Edited by DarthNoob
Link to comment
Share on other sites

  • 0

if you want the exact breakdown of any 1 on 1 match, just ask for it...

I was pleasantly surprised by how well mine did, especially unr1, which outputs the same sequence every time regardless of the enemy's moves

A random program wins 1/3 of the time, ties 1/3 of the time and loses 1/3 of the time, but that's only against another random program and that's not the optimal solution... as we've seen, access to previous moves in the round allows algorithms to make educated attempts to discern the opponent's next move (these are patternSeeker (by dawh), izzy2 and unr2, and to a lesser extent the ones that used information about the enemy's most and least used to do a more general diagnosis (such as darth1 and mr apple pi)) ... there are also some algorithms that make an effort to be random (such as unr1) and then there are the very simple ones (the periodic "test2" and "mrapple1" and the molehill-for-tat strategy of jarze's algorithm).

The whole contest is becoming more interesting to me because different types of algorithms are all successful here.

Link to comment
Share on other sites

  • 0

oops! I didn't use the updated version if izzy2 with the new patterns you've added, so if you did add any more, I can put that into the system (along with phil2 when/if he fixes the infinite loop problem in that)

Just want to mention that I submitted a modified version of BackAtYou a while back that I wanted in T2, but I haven't been checking this thread recently to remind you, so no biggie. :o

I am glad that patternSeeker works the way it's supposed to. :D It should dominate any opponent that uses a fixed pattern. It looks for repetitions in the opponent's moves and then picks the winner of the predicted next move for that iteration. :ph34r:

Link to comment
Share on other sites

  • 0

^ That's what izzy2 does, ish. You either let yours recognize way more patterns than mine does or somehow do something better, though. Mine also has a way to function if no patterns are recognized (which I won't reveal :P), so, woo. (The same as izzy1, I think, which is why I was surprised at it pwning compared to izzy2.)

Link to comment
Share on other sites

  • 0

done

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)

Enter the numbers of the programs you wish to fight, separated by spaces:

21 21 21 21

patternSeeker vs patternSeeker

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

patternSeeker won 0 games and patternSeeker won 0 ~ there were 50 ties

It was a tie!!!

patternSeeker vs patternSeeker

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

patternSeeker won 0 games and patternSeeker won 0 ~ there were 50 ties

It was a tie!!!

patternSeeker vs patternSeeker

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

patternSeeker won 0 games and patternSeeker won 0 ~ there were 50 ties

It was a tie!!!

patternSeeker vs patternSeeker

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

patternSeeker won 0 games and patternSeeker won 0 ~ there were 50 ties

It was a tie!!!

patternSeeker vs patternSeeker

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

patternSeeker won 0 games and patternSeeker won 0 ~ there were 50 ties

It was a tie!!!

patternSeeker vs patternSeeker

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

scissors vs scissors

paper vs paper

patternSeeker won 0 games and patternSeeker won 0 ~ there were 50 ties

It was a tie!!!

Final Results:

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

Win Count:

patternSeeker: 1.5

patternSeeker: 1.5

patternSeeker: 1.5

patternSeeker: 1.5

Type y to play again n

Thanks for playing!

Link to comment
Share on other sites

  • 0

^ That's what izzy2 does, ish. You either let yours recognize way more patterns than mine does or somehow do something better, though. Mine also has a way to function if no patterns are recognized (which I won't reveal :P), so, woo. (The same as izzy1, I think, which is why I was surprised at it pwning compared to izzy2.)

I haven't looked at the code, but mine is probably a lot more complicated (not that complicated makes it better), but it comes straight from my convoluted mind, so chances are that it could be simpler and achieve the same result... :rolleyes: I'll take a look to see if I can see what you're trying to do.

done

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)

Enter the numbers of the programs you wish to fight, separated by spaces:

21 21 21 21

Final Results:

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

patternSeeker vs patternSeeker: It was a tie!!!

Win Count:

patternSeeker: 1.5

patternSeeker: 1.5

patternSeeker: 1.5

patternSeeker: 1.5

Type y to play again n

Thanks for playing!

Um, you insisted that they be deterministic, so you could have done one test and it would have told you all that you needed to know... :lol:

Link to comment
Share on other sites

  • 0

Um, you insisted that they be deterministic, so you could have done one test and it would have told you all that you needed to know... :lol:

yeah haha, I wasn't thinking when I plugged it in - he wanted 4 patternSeekers dueling it out so that's why I put in :P

Since I'm feeling particularly egotistical atm, could I see Darth1 vs PatternSeeker and Darth1 vs JarZe, and hell Darth1 vs Izzy2

sure thing

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)

Enter the numbers of the programs you wish to fight, separated by spaces:

13 21 10 15

darth1 vs patternSeeker

paper vs rock

scissors vs scissors

scissors vs rock

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

scissors vs paper

rock vs rock

paper vs paper

paper vs scissors

rock vs scissors

scissors vs paper

rock vs rock

rock vs paper

rock vs paper

rock vs paper

rock vs paper

paper vs paper

paper vs scissors

paper vs scissors

darth1 won 4 games and patternSeeker won 25 ~ there were 21 ties

patternSeeker wins!!!

darth1 vs jarze

paper vs rock

scissors vs scissors

scissors vs rock

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

paper vs paper

paper vs scissors

scissors vs scissors

scissors vs rock

rock vs rock

rock vs paper

scissors vs paper

rock vs rock

paper vs paper

paper vs scissors

rock vs scissors

scissors vs paper

rock vs rock

rock vs paper

rock vs paper

rock vs paper

rock vs paper

paper vs paper

paper vs scissors

paper vs scissors

darth1 won 4 games and jarze won 25 ~ there were 21 ties

jarze wins!!!

darth1 vs izzy2

paper vs rock

scissors vs paper

rock vs paper

rock vs scissors

rock vs paper

rock vs paper

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs scissors

scissors vs scissors

scissors vs paper

scissors vs rock

scissors vs paper

scissors vs scissors

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs rock

scissors vs paper

scissors vs paper

scissors vs scissors

scissors vs scissors

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs rock

scissors vs scissors

scissors vs paper

scissors vs rock

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs rock

scissors vs paper

scissors vs paper

darth1 won 30 games and izzy2 won 8 ~ there were 12 ties

darth1 wins!!!

patternSeeker vs jarze

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

rock vs rock

paper vs paper

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

scissors vs scissors

paper vs rock

patternSeeker won 21 games and jarze won 0 ~ there were 29 ties

patternSeeker wins!!!

patternSeeker vs izzy2

rock vs rock

paper vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs scissors

scissors vs scissors

scissors vs paper

scissors vs rock

scissors vs paper

scissors vs scissors

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs rock

scissors vs paper

scissors vs paper

scissors vs scissors

scissors vs scissors

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs rock

scissors vs scissors

scissors vs paper

scissors vs rock

scissors vs scissors

scissors vs paper

scissors vs paper

scissors vs rock

scissors vs paper

scissors vs paper

patternSeeker won 26 games and izzy2 won 9 ~ there were 15 ties

patternSeeker wins!!!

jarze vs izzy2

rock vs rock

paper vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs scissors

rock vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs scissors

rock vs scissors

rock vs paper

scissors vs rock

paper vs paper

scissors vs scissors

rock vs scissors

rock vs paper

scissors vs paper

scissors vs paper

scissors vs rock

paper vs paper

scissors vs paper

scissors vs scissors

rock vs scissors

rock vs scissors

rock vs paper

scissors vs paper

scissors vs paper

scissors vs paper

scissors vs rock

paper vs scissors

rock vs paper

scissors vs rock

paper vs scissors

rock vs paper

scissors vs paper

scissors vs rock

paper vs paper

scissors vs paper

jarze won 22 games and izzy2 won 16 ~ there were 12 ties

jarze wins!!!

Final Results:

darth1 vs patternSeeker: patternSeeker wins!!!

darth1 vs jarze: jarze wins!!!

darth1 vs izzy2: darth1 wins!!!

patternSeeker vs jarze: patternSeeker wins!!!

patternSeeker vs izzy2: patternSeeker wins!!!

jarze vs izzy2: jarze wins!!!

Win Count:

darth1: 1.0

patternSeeker: 3.0

jarze: 2.0

izzy2: 0.0

it did round robin of those four, so if only count the three games you wanted to see:

darth1 vs patternSeeker: patternSeeker wins!!!

darth1 vs jarze: jarze wins!!!

darth1 vs izzy2: darth1 wins!!!

darth1: 1.0

patternSeeker: 1.0

jarze: 1.0

izzy2: 0.0

Link to comment
Share on other sites

  • 0

Amusing how most of those were so one-sided... PatternSeeker vs. JarZe was funny.

Weird how Darth1 vs PatternSeeker and Darth1 vs JarZe had the exact same result! O.O

I am a little curious how the modified BackAtYou fared. Because of the mix-up, it didn't get tested with the rest... :o

If JarZe's algorithm is trying to predict PatternSeeker's moves based on previous moves, it's doomed to fail since PS is almost always trying to find a pattern in the opponent's actions and thus any patterns in its moves are unpredictable.

Link to comment
Share on other sites

  • 0

dawh: can you resubmit that modified backatyou please? And if/when phil fixes the problems in the one with the infinite loop, we can factor that in too, then do an "official" T2.

(after which I'm thinking a 100-game-per-match ultimate Tourney 3.0 is needed, with each person submitting just one algorithm [or two???] and we'll try to market it first getting a lot more people)

Link to comment
Share on other sites

  • 0

here's the full new code, including dawh's updated backatyou (listed as backatyou2) and phil2 is currently just an allpaper type thing until it's fixed (i'll send him a PM and see if he wants to work on it or tell me how it works and have me code it).


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

            { 


                return PAPER;

            }

            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, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26 };

        }

        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);

            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 msg;

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

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

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

                    System.out.println("\n"+names[algo1]+" won "+oneWins+" games and "+names[algo2]+" won " +twoWins+ " ~ there were " + ties + " ties");

                    System.out.println(msg);

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

                }

            }

            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 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

alright here is the final code as of T2, including backatyou2 and phil2


// 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);

            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 msg;

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

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

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

                    System.out.println("\n"+names[algo1]+" won "+oneWins+" games and "+names[algo2]+" won " +twoWins+ " ~ there were " + ties + " ties");

                    System.out.println(msg);

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

                }

            }

            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 to play again ");

            ohyeah = false;

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

        }

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

    }


}


Final Official T2 results coming in a moment. These are the contestants and their index in parentheses

Previous Champion: test2 (2)

Izzy's algos: izzy, izzy1, izzy2 (4, 14, 15)

Jarze's champion: jarze (10)

Medji's algos: medji, medji1, medji2 (11, 19, 20)

Mr. Apple's programs: mr_apple_pi, mrapple1, and his recent submission apple3 (12, 18, 27)

DarthNoob's algoritms: darth1, darth2, darth3 (13, 16, 17)

dawh's two destroyers: patternSeeker and backatyou2 (21, 28)

my programs: unr1, unr2 (24, 25) ~ and you might count "test2" as my third but it's already in the list

phillip1882's algos: phil, phil1, phil2 (5, 22, 23)

and there you have it. The list going in for the final T2 is:

2, 4, 14, 15, 10, 11, 19, 20, 12, 18, 27, 13, 16, 17, 21, 28, 24, 25, 5, 22, 23

standby for the results...

Link to comment
Share on other sites

  • 0

well I tried to post the whole thing but it was waaaay too long and Brainden wouldnt accept it even when I split into fourths. So if you want the blow-by-blow of any single matchoff, just ask for it :thumbsup:

The important bit:

Final Results:

test2 vs izzy: test2 wins!!!

test2 vs izzy1: test2 wins!!!

test2 vs izzy2: test2 wins!!!

test2 vs jarze: It was a tie!!!

test2 vs medji: test2 wins!!!

test2 vs medji1: It was a tie!!!

test2 vs medji2: medji2 wins!!!

test2 vs mr_apple_pi: It was a tie!!!

test2 vs mrapple1: mrapple1 wins!!!

test2 vs apple3: It was a tie!!!

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: It was a tie!!!

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: It was a tie!!!

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: izzy1 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: It was a tie!!!

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: jarze wins!!!

izzy2 vs medji: medji wins!!!

izzy2 vs medji1: izzy2 wins!!!

izzy2 vs medji2: It was a tie!!!

izzy2 vs mr_apple_pi: mr_apple_pi wins!!!

izzy2 vs mrapple1: mrapple1 wins!!!

izzy2 vs apple3: It was a tie!!!

izzy2 vs darth1: darth1 wins!!!

izzy2 vs darth2: darth2 wins!!!

izzy2 vs darth3: izzy2 wins!!!

izzy2 vs patternSeeker: patternSeeker wins!!!

izzy2 vs backatyou2: backatyou2 wins!!!

izzy2 vs unr1: It was a tie!!!

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: It was a tie!!!

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: It was a tie!!!

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: It was a tie!!!

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: mrapple1 wins!!!

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: It was a tie!!!

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: mr_apple_pi 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: It was a tie!!!

apple3 vs phil2: It was a tie!!!

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: It was a tie!!!

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: unr2 wins!!!

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: 11.0

izzy: 6.5

izzy1: 12.0

izzy2: 6.5

jarze: 14.0

medji: 9.5

medji1: 10.5

medji2: 11.0

mr_apple_pi: 10.0

mrapple1: 12.0

apple3: 8.5

darth1: 15.0

darth2: 7.0

darth3: 9.5

patternSeeker: 16.0

backatyou2: 15.5

unr1: 8.5

unr2: 10.5

phil: 8.0

phil1: 5.0

phil2: 3.5

in order of score:

patternSeeker: 16.0

backatyou2: 15.5

darth1: 15.0

jarze: 14.0

izzy1: 12.0

mrapple1: 12.0

test2: 11.0

medji2: 11.0

unr2: 10.5

medji1: 10.5

mr_apple_pi: 10.0

medji: 9.5

darth3: 9.5

apple3: 8.5

unr1: 8.5

phil: 8.0

darth2: 7.0

izzy: 6.5

izzy2: 6.5

phil1: 5.0

phil2: 3.5

phew, getting them in order was a bit of a pain. I'm gonna add some code to make the system put them in order of most points to least for future use, and to calculate certain stats like these:

the total # of games is of course pre-determined to n/2 * (n-1) if there are n players, so the average score will always be (n-1)/2, but the standard deviation COULD be calculated (I'll have the system do that too). I'll make those changes in a second but they don't affect the results of course: Dawh's algorithms seem to be most effective :thumbsup: Pattern guessing methods seem to be working to the best, although there are some other interesting strategies that are near the top

Link to comment
Share on other sites

  • 0

Not sure how much work you've already done on this, but for easy ordering, rather than recoding the wheel, you could let a set do the work for you. You'd need to create a subclass to hold the data:


private class AlgorithmScore implements Comparable<AlgorithmScore> {

	public String name = null;

	public double score = 0;


	public AlgorithmScore(String name) {

		this.name = name;

	}


	//This is the function you need to implement for Comparable.

	public int compareTo(AlgorithmScore other) {

		return(this.score.compareTo(other.score));

	}

}
Once you have this Comparable class, you can store them into a set and then iterate over the set to get the items in order:
Set<AlgorithmScore> algScores = new TreeSet<AlgorithmScore>();

...

//from calculated wins - i is the player we want

AlgorithmScore playerScore = new AlgorithmScore(names[i]);

playerScore.score = nw[i];

algScores.add(playerScore);

...

//Display them in order

for(AlgorithmScore player : algScores) {

	System.out.println(player.name + ": " + player.score);

}

I think that you would only need to import Comparable, Set and TreeSet to make it work, but it saves you the trouble of developing your own sort method. Of course, you're welcome to do it as a coding exercise, but this is much easier. :thumbsup: Depending on where you insert the code to add the values to the set, you may need a different index variable. But you'd be better placed to judge as I've only glanced at your code at this point.

As an aside, small coding quibble. It's generally bad form to use l as a variable name. That is an ell, not a one, or a capital I. (That's why it's bad; it's hard to tell the difference in many fonts. :dry: lI1)

Link to comment
Share on other sites

  • 0

Oh yeah I was wondering why you didn't make each algorithm into its own method, like

public int Darth1(int[] enemyMoves, int[] myMoves, int roundNum)

{

//implementation

}

And then in the client program it'd be easier to put everything together, or at least, it wouldn't look so long.

--

I already know what two programs I'm gonna use in T3 =P

Link to comment
Share on other sites

  • 0

Oh yeah I was wondering why you didn't make each algorithm into its own method, like

that's what I did originally, but it required a giant if structure to decide which method to use and then locate that method and run it. However the new system I wrote just has an array and displays them along with a number for the user and the user types in the number which is then used to run the algorithm. It's much easier that way :thumbsup:

and dawh: thanks but I was just going to write it myself and keep it simple (and hopefully as efficient as possible hehe) :)

Link to comment
Share on other sites

  • 0

here's the new 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 = 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);

            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 msg;

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

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

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

                    System.out.println("\n"+names[algo1]+" won "+oneWins+" games and "+names[algo2]+" won " +twoWins+ " ~ there were " + ties + " ties");

                    System.out.println(msg);

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

                }

            }

            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=0; 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.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");

    }


}


and what it outputs for T2 (after all the game summaries)

Final Results:

test2 vs izzy: test2 wins!!!

test2 vs izzy1: test2 wins!!!

test2 vs izzy2: test2 wins!!!

test2 vs jarze: It was a tie!!!

test2 vs medji: test2 wins!!!

test2 vs medji1: It was a tie!!!

test2 vs medji2: medji2 wins!!!

test2 vs mr_apple_pi: It was a tie!!!

test2 vs mrapple1: mrapple1 wins!!!

test2 vs apple3: It was a tie!!!

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: It was a tie!!!

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: It was a tie!!!

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: izzy1 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: It was a tie!!!

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: jarze wins!!!

izzy2 vs medji: medji wins!!!

izzy2 vs medji1: izzy2 wins!!!

izzy2 vs medji2: It was a tie!!!

izzy2 vs mr_apple_pi: mr_apple_pi wins!!!

izzy2 vs mrapple1: mrapple1 wins!!!

izzy2 vs apple3: It was a tie!!!

izzy2 vs darth1: darth1 wins!!!

izzy2 vs darth2: darth2 wins!!!

izzy2 vs darth3: izzy2 wins!!!

izzy2 vs patternSeeker: patternSeeker wins!!!

izzy2 vs backatyou2: backatyou2 wins!!!

izzy2 vs unr1: It was a tie!!!

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: It was a tie!!!

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: It was a tie!!!

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: It was a tie!!!

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: mrapple1 wins!!!

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: It was a tie!!!

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: mr_apple_pi 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: It was a tie!!!

apple3 vs phil2: It was a tie!!!

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: It was a tie!!!

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: unr2 wins!!!

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: 11.0

izzy: 6.5

izzy1: 12.0

izzy2: 6.5

jarze: 14.0

medji: 9.5

medji1: 10.5

medji2: 11.0

mr_apple_pi: 10.0

mrapple1: 12.0

apple3: 8.5

darth1: 15.0

darth2: 7.0

darth3: 9.5

patternSeeker: 16.0

backatyou2: 15.5

unr1: 8.5

unr2: 10.5

phil: 8.0

phil1: 5.0

phil2: 3.5

Type y for analysis y

[Algos: 21] [Games: 210] [Average Score: 10.0] [sdev: 3.291] [MAD: 2.619]

From Greatest to Least:

patternSeeker: 16.0

backatyou2: 15.5

darth1: 15.0

jarze: 14.0

izzy1: 12.0

mrapple1: 12.0

test2: 11.0

medji2: 11.0

medji1: 10.5

unr2: 10.5

mr_apple_pi: 10.0

medji: 9.5

darth3: 9.5

apple3: 8.5

unr1: 8.5

phil: 8.0

darth2: 7.0

izzy: 6.5

izzy2: 6.5

phil1: 5.0

phil2: 3.5

Type y to play again n

Thanks for playing!

Edited by unreality
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...