What Book Are You Reading at the Moment?

User avatar
Fife
Posts: 15157
Joined: Wed Nov 30, 2016 9:47 am

Re: What Book Are You Reading at the Moment?

Post by Fife » Sat Jan 05, 2019 9:07 pm

You've shot to a tie atop the leaderboard, StA, well done on the simulation code.

You've left just one player in the cellar struggling to maintain a 0.2.

:goteam: :drunk:

User avatar
Speaker to Animals
Posts: 38685
Joined: Wed Nov 30, 2016 5:59 pm

Re: What Book Are You Reading at the Moment?

Post by Speaker to Animals » Sun Jan 06, 2019 4:53 am

SuburbanFarmer wrote:
Sat Jan 05, 2019 8:00 pm
Speaker to Animals wrote:
Sat Jan 05, 2019 12:23 pm
Well, fuck. I still cannot believe it is true, but wrote it out myself.

Code: Select all

import random


count_first_guess_correct = 0.0
count_second_guess_correct = 0.0
count_total_games_played = 0.0


def run_game ():
    cups = {1:0, 2:0, 3:0}
    keys = list(cups.keys())



    # hide the prize in one of the three cups
    prize_key = random.choice(keys)
    cups[prize_key] = 1

    random.shuffle(keys)

    # player chooses random cup

    first_choice = keys[0]


    # Overturn a cup not containing the prize and not chosen by player
    keys.remove(first_choice)
    if prize_key != first_choice:
        keys.remove(prize_key)


    overturned_cup = keys[0]
    keys.remove(overturned_cup)

    # player chooses other cup

    keys = list(cups.keys())
    keys.remove(first_choice)
    keys.remove(overturned_cup)
    second_choice = random.choice(keys)

    #Sanity checks
    if first_choice == second_choice:
        print ("Error: first choice and second choice are the same")
    elif prize_key == overturned_cup:
        print ("Error: prize key and overturned cup are the same")
    elif second_choice == overturned_cup:
        print ("Error: second choice and overturned cup are the same")

    if prize_key == second_choice:
        return 1
    else:
        return 0





for n in range (0,10000):
    outcome = run_game()
    if outcome == 1:
        count_second_guess_correct = count_second_guess_correct + 1.0
    else:
        count_first_guess_correct = count_first_guess_correct + 1.0

    count_total_games_played = count_total_games_played + 1.0


percent_first_guess_correct = count_first_guess_correct / count_total_games_played
percent_second_guess_correct = count_second_guess_correct / count_total_games_played

print ("percent first guess correct: " + str(percent_first_guess_correct))
print ("percent second guess correct: " + str(percent_second_guess_correct))
print ("total games: " + str(count_total_games_played))


Output:

percent first guess correct: 0.3324
percent second guess correct: 0.6676
total games: 10000.0

Results are repeated numerous time. You actually have about 66% chance of getting the prize if you choose a second time.
The answer is there in your code. You instructed the computer to run a completely random second choice.
second_choice = random.choice(keys)
Effectively, you're counting the number of times that choosing between two remaining cups is correct/incorrect.

Mandating that you switch on Choice 2 will yield an identical result to sticking with the cup chosen in Choice 1.
Only one element left in the list


If you look at the bottom, the sanity check section shows you that it works out. I am not really a Python guy. Just used a quick hack.


I made it more clear instead of fucking around with the random package.

Code: Select all

# player chooses other cup

    keys = list(cups.keys())
    keys.remove(first_choice)
    keys.remove(overturned_cup)
    second_choice = keys[0]
Same result:

percent first guess correct: 0.3286
percent second guess correct: 0.6714
total games: 10000.0

User avatar
SuburbanFarmer
Posts: 25279
Joined: Wed Nov 30, 2016 6:50 am
Location: Ohio

Re: What Book Are You Reading at the Moment?

Post by SuburbanFarmer » Sun Jan 06, 2019 9:01 am

You’ve proven that telling the computer to select between 3 cups, with one known wron will yield success 2/3 of the time.
SJWs are a natural consequence of corporatism.

Formerly GrumpyCatFace

https://youtu.be/CYbT8-rSqo0

User avatar
Speaker to Animals
Posts: 38685
Joined: Wed Nov 30, 2016 5:59 pm

Re: What Book Are You Reading at the Moment?

Post by Speaker to Animals » Sun Jan 06, 2019 10:29 am

SuburbanFarmer wrote:
Sun Jan 06, 2019 9:01 am
You’ve proven that telling the computer to select between 3 cups, with one known wron will yield success 2/3 of the time.
uh.. no.

I fill a list with three cups. I remove two cups (overturned cup and first choice cup). Only one cup remains in the list..

User avatar
SuburbanFarmer
Posts: 25279
Joined: Wed Nov 30, 2016 6:50 am
Location: Ohio

Re: What Book Are You Reading at the Moment?

Post by SuburbanFarmer » Sun Jan 06, 2019 1:20 pm

Speaker to Animals wrote:
Sun Jan 06, 2019 10:29 am
SuburbanFarmer wrote:
Sun Jan 06, 2019 9:01 am
You’ve proven that telling the computer to select between 3 cups, with one known wron will yield success 2/3 of the time.
uh.. no.

I fill a list with three cups. I remove two cups (overturned cup and first choice cup). Only one cup remains in the list..
That’s even worse.
SJWs are a natural consequence of corporatism.

Formerly GrumpyCatFace

https://youtu.be/CYbT8-rSqo0

User avatar
Speaker to Animals
Posts: 38685
Joined: Wed Nov 30, 2016 5:59 pm

Re: What Book Are You Reading at the Moment?

Post by Speaker to Animals » Sun Jan 06, 2019 1:21 pm

SuburbanFarmer wrote:
Sun Jan 06, 2019 1:20 pm
Speaker to Animals wrote:
Sun Jan 06, 2019 10:29 am
SuburbanFarmer wrote:
Sun Jan 06, 2019 9:01 am
You’ve proven that telling the computer to select between 3 cups, with one known wron will yield success 2/3 of the time.
uh.. no.

I fill a list with three cups. I remove two cups (overturned cup and first choice cup). Only one cup remains in the list..
That’s even worse.
LMFAO

User avatar
SuburbanFarmer
Posts: 25279
Joined: Wed Nov 30, 2016 6:50 am
Location: Ohio

Re: What Book Are You Reading at the Moment?

Post by SuburbanFarmer » Sun Jan 06, 2019 1:25 pm

Whatevs, bud. I can’t force you to think.
SJWs are a natural consequence of corporatism.

Formerly GrumpyCatFace

https://youtu.be/CYbT8-rSqo0

User avatar
Speaker to Animals
Posts: 38685
Joined: Wed Nov 30, 2016 5:59 pm

Re: What Book Are You Reading at the Moment?

Post by Speaker to Animals » Sun Jan 06, 2019 1:36 pm

SuburbanFarmer wrote:
Sun Jan 06, 2019 1:25 pm
Whatevs, bud. I can’t force you to think.
I create a list:

cups = [A, B, C]

I remove item A from the list:

del[A]
cups => [B, C]

I remove item C from the list:

del[C]
cups => [C]


What happens when I then write:

cups[0]


???

User avatar
Fife
Posts: 15157
Joined: Wed Nov 30, 2016 9:47 am

Re: What Book Are You Reading at the Moment?

Post by Fife » Sun Jan 06, 2019 1:39 pm

Flounder may be more of a Hollywood Squares guy.

User avatar
Speaker to Animals
Posts: 38685
Joined: Wed Nov 30, 2016 5:59 pm

Re: What Book Are You Reading at the Moment?

Post by Speaker to Animals » Sun Jan 06, 2019 2:00 pm

More python fun..

Code: Select all

cup_A = 'A'
cup_B = 'B'
cup_C = 'C'

cups = [cup_A, cup_B, cup_C]

cups.remove(cup_A)
cups.remove(cup_B)

print(cups)




print("this is the only item in the list you dumbass: " + cups[0])
Output:

['C']
this is the only item in the list you dumbass: C