Jump to content

  • Log In with Google      Sign In   
  • Create Account


K1NNY

Member Since 06 Sep 2011
Offline Last Active Mar 02 2013 10:23 AM

#4984415 A Monty Hall Paradox simulation program

Posted by K1NNY on 27 September 2012 - 11:27 AM

Today i created a simple program that simulates the Monty Hall paradox that i learned about here:

http://betterexplained.com/articles/understanding-the-monty-hall-problem/

It took me about two class periods (about an hour and a half) and helped me teach myself about using and defining functions. It was a cool project and didn't take very long to get working. I'd like to hear feedback on how i did as i am still a beginner! Here's the code:

[source lang="python"]# Monty Hall paradox game #import pygameimport random#variablesdoors = [1, 2, 3]x = random.randint(1, 3)#functiondef show(): print '=================' print '|',doors[0],'| |', doors[1],'| |',doors[2],'|' print '================='def reveal(): if x == 1: doors[0] = 'C' doors[1] = 'G' doors[2] = 'G' show() elif x == 2: doors[0] = 'G' doors[1] = 'C' doors[2] = 'G' show() elif x == 3: doors[0] = 'G' doors[1] = 'G' doors[2] = 'C' show()def switch(): y = str(raw_input("Would you like to switch doors?")) if y == 'yes': new_pick = int(raw_input('Which door?')) user_door = new_pick reveal() elif y == 'no': reveal() show()user_door = int(raw_input('Pick a door!'))#logicif user_door == 1 and x == 3 and x != 2: doors[1] = 'G' show() switch() elif user_door == 1 and x == 2 and x != 3: doors[2] = 'G' show() switch()elif user_door == 2 and x == 3 and x != 1: doors[0] = 'G' show() switch()elif user_door == 2 and x == 1 and x != 3: doors[2] = 'G' show() switch()elif user_door == 3 and x == 1 and x != 2: doors[1] = 'G' show() switch()elif user_door == 3 and x == 2 and x != 1: doors[0] = 'G' show() switch()[/source]


#4900342 Not sure how to get into C++

Posted by K1NNY on 07 January 2012 - 08:43 AM

I have good experience in Python and Pygame so no this isnt my first programming language. I am wanting to step up to the next level and C++ is what ive thought to be the next level


#4873698 Lookng for coding partner/teacher

Posted by K1NNY on 17 October 2011 - 06:44 PM

I am 16 years old, am interested in learning Python along with its add on Pygame. I do know some Python and Pygame as of right now but i would like to be able to implement and learn more skills geared towards game programming. I take advanced math classes in school and learn fast.

All I am looking for really is a person to teach me things like what to use and what not to do. I am not entirely sure how we will end up communicating but i plan on us just sending code back and forth and you (my potential partner and teacher) telling me what i did wrong and what to do next.

We can work out details later on, all i need now is a confirmation.


#4858568 Character Changing Viewing Directions

Posted by K1NNY on 07 September 2011 - 05:58 AM

thanks man. i didnt do this in the first place bc i thot i would have to make a new variable called player.image. i'm a bit of a noob haha. thanks for the help!


PARTNERS