who wants to be a millionare trouble
Author |
Message |
Jimbo1991
|
Posted: Tue Apr 29, 2008 10:28 am Post subject: who wants to be a millionare trouble |
|
|
how would i start to type up a turing program, who wants to be a millionare, that will have a counter, to keep track of the 'money', no lifelines, but a hint each if the questions in which the hints will be different for each question. like the t.v. show it will start of easy, but get harder at the end...how would i go about this? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
S_Grimm
![](http://compsci.ca/v3/uploads/user_avatars/18926424384e6d86e5cf4d6.jpg)
|
Posted: Tue Apr 29, 2008 11:58 am Post subject: Re: who wants to be a millionare trouble |
|
|
This is the start of my Millionare Code, Use it if you like. It does include lifelines, but no money counter. Just include a variable like "money" and asign a value to it after each right answer. Also, the "Walk" option isn't there
var winID : int
winID := Window.Open ("position:200;200,graphics:800;600")
%Variable Declarations
var contestant, answer, yesno, walk, lifeline, friend : string
var phone, ask, fifty : real
var askthe : array 1 .. 4 of real
phone := 1
ask := 1
fifty := 1
for entire_program : 1 .. 1
%Getting the information
for game : 1 .. 1
put "Disclaimer : Because this is a game, you win NO real money!"
put "Hello, and welcome to Who Wants To Be A Millionaire!"
put "What is your name? : " ..
get contestant
put "Ok, so, ", contestant, ", are you ready to play Who Wants To Be A Millionaire?"
put "Type 'yes' or 'no' and press 'Enter' : " ..
get yesno
loop
if (yesno not= "yes") and (yesno not= "no") then
put "Sorry, I didn't understand your answer."
put "Please type 'yes' or 'no' and press 'Enter' : "
get yesno
end if
exit when (yesno = "yes" or yesno = "no")
end loop
if (yesno = "no") then
put "Please come back and play again ", contestant, "!"
exit
end if
end for
%Rules of the game
for rules : 1 .. 1
if (yesno = "yes") then
put "Great! Now I'll explain the rules."
put "First, to answer a question, type 'a', 'b', 'c', or 'd' and press 'Enter' "
put "Second, you have three lifelines. To use a lifeline, TYPE 'lifeline' and press "
put "'Enter'. Then type your choice and press 'Enter' Your three choices are :"
put " 50/50 Type: " ..
colour (blue)
put "50/50"
colour (black)
put " Phone a friend Type: " ..
colour (blue)
put "phone"
colour (black)
put " Ask the Audience Type: " ..
colour (blue)
put "ask"
colour (black)
put "You can always WALK away, and take all the money you have earned away with you!"
put " Walk Away Type: " ..
colour (blue)
put "WALK"
colour (black)
put "Remember, you can only use each lifeline ONCE!"
end if
put "Are you ready to play? : " ..
get yesno
loop
if (yesno not= "yes") and (yesno not= "no") then
put "Sorry, I didn't understand your answer."
put "Please type 'yes' or 'no' and press 'Enter' : "
get yesno
end if
exit when (yesno = "yes" or yesno = "no")
end loop
if (yesno = "no") then
put "Then we will restart from the begining."
end if
end for
if (yesno = "yes") then
put "Alright! Lets Start!"
delay (5z000)
cls
end if
%Question 1
put "Question One"
colour (9)
put "Who is the author of the best-selling \"Harry Potter\" series of books?"
put " (a) George Lucas"
put " (b) J.K. Rowling"
put " (c) Terry Goodkind"
put " (d) Harry Potter"
colour (black)
put "Type your answer or 'lifeline'"
get answer
loop
if (answer = "lifeline") then
if (phone = 1) then
put "You may Phone a Friend."
end if
if (ask = 1) then
put "You may Ask the Audience."
end if
if (fifty = 1) then
put "You may use 50/50."
end if
put "Which lifeline would you like to use? : " ..
get lifeline
if (lifeline = "none") then
put "What is your answer? : " ..
get answer
end if
if (lifeline = "50/50") and (fifty = 1) then
fifty := 0
put "Two of the incorrect answers are :"
colour (9)
put " (a) George Lucas"
put ""
put " (c) Terry Goodkind"
put ""
colour (black)
put "That leaves you with :"
put ""
colour (9)
put " (b) J.K. Rowling"
put ""
put " (d) Harry Potter"
colour (black)
put ""
put "What is your answer? : " ..
get answer
end if
if (lifeline = "phone") and (phone = 1) then
phone := 0
put "Who would you like to call? : " ..
get friend
delay (5000)
put "Ok, we have ", friend, " on the line. ", friend, ", ", contestant, " is with me on"
put "\"Who Wants To Be A Millionaire\" and needs your help. The question is: Who is the"
put "author of Harry Potter? Is it (a) George Lucas, (b) J.K. Rowling, "
put "(c) Terry Goodkind or (d) Harry Potter?"
put friend, ": I know that the answer is (b) J.K. Rowling."
put ""
put "What is your answer? : " ..
get answer
end if
if (lifeline = "ask") and (ask = 1) then
ask := 0
put "Alright Audience, ", contestant, " needs your help! Input Your answers now."
var a, b, c, d : int
loop
randint (a, 0, 5)
randint (b, 85, 100)
randint (c, 0, 7)
randint (d, 0, 3)
exit when (a + b + c + d = 100)
end loop
put "The answers are in!"
put a, "% believes the answer is (a)."
put b, "% believes the answer is (b)."
put c, "% believes the answer is (c)."
put d, "% believes the answer is (d)."
put ""
put "What is your answer? : " ..
get answer
end if
end if
if (answer = "a") or (answer = "c") or (answer = "d") then
put "Sorry, your answer is incorrect. Please press 'Enter' "
var ch : char := getchar % Wait for input
close (winID)
close (entire_program)
end if
if (answer = "b") then
put "Correct! You have won $1,000!"
put "$1,000,000"
put "$500,000"
put "$250,000"
put "$100,000"
put "$50,000"
put "$25,000"
put "$10,000"
put "$5,000"
put "$2,000"
colour (green)
put "$1,000"
colour (black)
put ""
put "Press \"ENTER\" "
var ch : char := getchar % Wait for input
cls
exit
end if
end loop |
|
|
|
|
![](images/spacer.gif) |
Tallguy
![](http://compsci.ca/v3/uploads/user_avatars/515706924539b443d32a6e.gif)
|
Posted: Wed Apr 30, 2008 7:11 am Post subject: RE:who wants to be a millionare trouble |
|
|
i'm srry but thats way too much code just to do the opening, try to cut it down a bit |
|
|
|
|
![](images/spacer.gif) |
S_Grimm
![](http://compsci.ca/v3/uploads/user_avatars/18926424384e6d86e5cf4d6.jpg)
|
Posted: Wed Apr 30, 2008 10:50 am Post subject: RE:who wants to be a millionare trouble |
|
|
Yeah, I know. But it works and thats what counts in my books. I'm working on a copy using procedures instead of all the code I am using (it's 1000+ lines!), but I really havn't had time to work on it.
Also, can anyone give me a hand here? I want to randimize the selected questions, using three different difficulty levels (easy questions, medium questions, hard questions), so that it doesn't use the same question twice in a row. |
|
|
|
|
![](images/spacer.gif) |
gitoxa
![](http://compsci.ca/v3/uploads/user_avatars/125344263047f801d546bcb.jpg)
|
Posted: Wed Apr 30, 2008 12:27 pm Post subject: Re: who wants to be a millionare trouble |
|
|
In my opinion, put your questions/answers into a seperate text file. You can easily create more/edit old files this way. After getting that down, you could even get it to randomly select questions from the files. |
|
|
|
|
![](images/spacer.gif) |
S_Grimm
![](http://compsci.ca/v3/uploads/user_avatars/18926424384e6d86e5cf4d6.jpg)
|
Posted: Thu May 01, 2008 10:50 am Post subject: RE:who wants to be a millionare trouble |
|
|
I want to avoid text files, because I don't really understand them. I want to do something like this:
[code]
var order : array 1..20 of int
procedure Q1
%%%%%%%%Code For Question1%%%%%%%%%
end Q1
for i : 1..20
randint (order (i) , 1,20)
end for
for i : 1..20
if order (i) = 1 then
Q1
end if
if order (i) = 2 then
Q2
end if
[\code]
thats the gist of it. I'll have 20 Q* procedures. But I want three different levels of difficulty |
|
|
|
|
![](images/spacer.gif) |
|
|