PDA

View Full Version : Yet another event study



PawnXIIX
07-04-2012, 09:32 PM
Hey guys, I have an event simulator that I wrote over the last hour and a half. I guess I need to get out more if this is "fun".

Here is what the algorithm is based on:

- If you are falling behind, you have a better chance of getting an item
- Fail rate is still 2/3, 1/2, 0
- Random items are not calculated. Sorry :P
- Perfect opening theory, meaning 168 openings over 7 days.

The winner took 31 chips in this event trial with 168 attempts. There are 50 players here.

With my events I took an average of just over 28 chips to win the event. Remember...that's even with pefect opening. This I believe is because I was very low with my initial idea on the odds of finding a chip.


public class newEvent
{
public static void main(String [] args)
{
players = new player[TOT_PLAYERS];
for(int i = 0; i < TOT_PLAYERS; i++)
players[i] = new player((int)(Math.random()*3), i);
for(int i = 0; i < TOT_OPENS; i++)
{
for(int j = 0; j < TOT_PLAYERS; j++)
{
players[j].logAttempt();
boolean opened = false;
if(players[j].getOpenType() == 2)
opened = true;
else if((players[j].getOpenType() == 1) && (Math.random() > .5))
opened = true;
else if((players[j].getOpenType() == 0) && (Math.random() > .666))
opened = true;
if(opened)
{
players[j].logOpen();
double tempOdds = calcComputerChipOdds(players[j]);
if(Math.random() < tempOdds)
{
players[j].giveComputerChip();
System.out.println("Computer Chip for player " + j);
}
else
{
System.out.println("Random item for player " + j);
}
}
else
{
System.out.println("Fail for player " + j);
}
}
}
player winner = getCurrentLeader();
System.out.println("Winner is player number: " + winner.getNumber() + " with " + winner.getComputerChips() + " chips.");
}

private static double calcComputerChipOdds(player temp)
{
player leader = getCurrentLeader();
double newRate = CHIP_RATE + (CHIP_RATE * (leader.getComputerChips() - temp.getComputerChips()));
//System.out.println(newRate);
newRate = ((newRate > .5) ? .5 : newRate);
return newRate;
}

private static player getCurrentLeader()
{
int maxLocation = 0;
int leader = players[maxLocation].getComputerChips();
for(int i = 1; i < TOT_PLAYERS; i++)
{
if(players[i].getComputerChips() > leader)
{
maxLocation = i;
leader = players[maxLocation].getComputerChips();
}
}
return players[maxLocation];
}

public static final int TOT_PLAYERS = 50;
public static final int TOT_OPENS = 168;
public static final String [] OPEN_TYPE = {"Free", "Cash", "Gold"};
public static final String [] REWARDS = {"Chip", "300xRP", "$10,000", "$50,000", "Racer Z", "Deviant Coat", "Hitman Sniper Rifle"};
public static final double CHIP_RATE = .5 / REWARDS.length;
public static player [] players;
}


public class player
{
public player(int openType, int playerNumber)
{
goldUsed = 0;
totalAttempts = 0;
computerChips = 0;
successfulOpens = 0;
this.openType = openType;
this.playerNumber = playerNumber;
}

public int getOpenType()
{
return openType;
}

public void giveComputerChip()
{
computerChips++;
}

public void logOpen()
{
successfulOpens++;
if(getOpenType() == 2)
goldUsed++;
}

public void logAttempt()
{
totalAttempts++;
}

public int getComputerChips()
{
return computerChips;
}

public int getNumber()
{
return playerNumber;
}

private int openType, goldUsed, totalAttempts, computerChips, successfulOpens, playerNumber;
}

Later on tonight I am going to run a full scale example with a few hundred people with a realistic opening number. Maybe even later I'll run with a few thousand people.

Anyone have anything that you see wrong? I am open to criticism and anything that I did wrong :)

ShawnBB
07-04-2012, 10:39 PM
Who here actually looked at all these code? Are they just your own written or combined with some of gree's code base?
How can you make sure your based on conditions are all true?

Nudie
07-04-2012, 10:46 PM
What's the point here? Have a drink! :p

dudeman
07-04-2012, 11:18 PM
The 10/20 jacket was missed, so there's an extra zonk prize missing.

Luciferianism
07-05-2012, 12:42 AM
Yeah I see something wrong. You've wrote complicated math instead of getting laid.

Dangerous Greg
07-05-2012, 12:50 AM
Yeah I see something wrong. You've wrote complicated math instead of getting laid.
Sometimes, with a really geeky girlfriend (or boyfriend I imagine), writing complicated math WILL get you laid! Or at least someone that has a fetish-like fascination for geeky men. What can I say, I have geeky friends!

Luciferianism
07-05-2012, 12:54 AM
'Calculators turn me on, baby. Now take off those pants so I can check out your digit. Then maybe I'll think about whether I want to multiply.'

dudeman
07-05-2012, 12:56 AM
Yeah I see something wrong. You've wrote complicated math instead of getting laid.

Nerds are the new jocks. Just like disguised gambling is the new accepted business model apparently. At least according to every Conzio brown-noser around here. :p

nopenopenope
07-05-2012, 02:01 AM
Nerds are the new jocks. Just like disguised gambling is the new accepted business model apparently. At least according to every Conzio brown-noser around here. :p

One thing has nothing to do with the other. You don't need to turn every one of your replies into your negative political viewpoint. Apparently your ban was not helpful after all, LeDude... talk about a broken eff'in record, haven't you quit yet?

dudeman
07-05-2012, 02:05 AM
One thing has nothing to do with the other. You don't need to turn every one of your replies into your negative political viewpoint. Apparently your ban was not helpful after all, LeDude... talk about a broken eff'in record, haven't you quit yet?

Oh, my vacation was more than helpful. It gave me a few days to refine my "language" skills. ;) lol!

Dangerous Greg
07-05-2012, 03:20 AM
'Calculators turn me on, baby. Now take off those pants so I can check out your digit. Then maybe I'll think about whether I want to multiply.'

Hilarious!!

Populouspapa
07-05-2012, 04:49 AM
But since its not based on the correct droprate whats the point?