Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with...Lifelines in who wants to be..game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
McTam




PostPosted: Mon Jan 17, 2005 1:28 pm   Post subject: Help with...Lifelines in who wants to be..game

I can not figure out how to write the lifelines for my who wants to be a millionaire game....i have come a long way with the help of people from our beloved comp sci and it would be a shame if i couldn't figure this out so i can finish my program....
Can anyone help me with this part of my game?
fifty fifty-cancel two out of four answers for the question
ask the audience-since there is no audience....same as fifty fifty...
call a friend-give the answer for the question

Thanks guys.....I owe you HUGE!
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Jan 17, 2005 1:33 pm   Post subject: (No subject)

well you have your list of possible choices. Now to do 50-50, you just create a new list of choices - 2 elements only. First add the correct answer. Then randomly pick another answer. Let the user chose from those two.

As for ask the audience - it is essensially the same, though I suggest also randomly generating some statistics. With a correct answer having a higher chance ofcourse Wink
McTam




PostPosted: Mon Jan 17, 2005 1:37 pm   Post subject: who wants to be a millionaire lifelines

That sounds great! and the response time....astonishing....but.... Embarassed ...
I can not write that in code is that a bother to ask for you to express yourself in computer language? Embarassed Would love you for it! Very Happy Thanks
Tony




PostPosted: Mon Jan 17, 2005 5:14 pm   Post subject: (No subject)

I'm not sure how your questions are set up... lets assume the following
Turing:

var choice:array 1..4 of string
choice[1] = "a"
choice[2] = "b"
choice[3] = "c"
choice[4] = "d"

var answerIndex:int := 2 % the answer is "b"
     %// ofcourse all of the above should be loaded from a datafile


so we have an array full of answers and we know that 2nd one is correct.. aka choice(answerIndex)

now lets say we want to let the user pick just 2 of the above (after using 50-50)

Turing:

var wrongChoices:array 1..3 of int %all the wrong answers
var myChoices:array 1..2 of int %1 correct 1 wrong

var counter:int := 1 %just follow along

for i:1..4
     if i not= answerIndex then
          wrongChoices(counter) := i
          counter += 1
     end if
end for

%now wrongChoices has all of the indexes but answerIndex
%so

myChoice(1) := answerIndex
myChoices(2) := wrongChoices(Rand.Int(1,3))

%myChoice(1) is the correct answer's index
%myChoice(2) is a random incorrect answer's index


and now you're ready! let the user pick between answer # myChoice(1) or myChoice(2).. you might want to keep track of the other two answers that will be crossed out, though those can be figured out since they are not in the list.

Turing:

loop
     put "pick an answer"
     get myAnswer
     if myAnswer = myChoice(1) or myAnswer = myChoice(2) then
          %check if myAnswer = answerIndex, if so - user wins
           exit
     else
           put "what are you, stupid? you can't pick that"
     end if
end loop


hope that helps
McTam




PostPosted: Tue Jan 18, 2005 11:36 am   Post subject: Thanks

Thanks alot you have helped me a great deal...
All the best to you...until next time Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: