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

Username:   Password: 
 RegisterRegister   
 I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hav0c0001




PostPosted: Sat Jun 09, 2007 8:20 am   Post subject: I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops. It is sort of like a Jeopardy game. The glitches in my loops will not allow me to block of the question that has already been answer/clicked on. Do I need to redo it in a procedure format? or is it possible to re-configure my if statements with variables? If any of this is possible please let me know how, or if you require my code, leave your email. Thanks alot.
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Sat Jun 09, 2007 9:11 am   Post subject: Re: I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

You could have a 2D array of boolean in which it stores if the question was used, or you can have a Question Record which stores if it was used
hav0c0001




PostPosted: Sat Jun 09, 2007 9:13 am   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

and you are confident that will work? Do you think you can give me an example? Thanks alot
Saad




PostPosted: Sat Jun 09, 2007 11:30 am   Post subject: Re: I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

Yes i am heres a code to get you started
code:
var Used : array 1 .. 5, 1 .. 5 of boolean
% Sets all questions to used
for i : 1 .. 5
    for b : 1 .. 5
        Used (i, b) := true
    end for
end for
Used (3, 3) := false  % to make 1 question not used
var r, g : int
% Simple Check if question is used/not used
loop
    put "Enter row then column"
    get r, g
    if Used (r, g) then
        put "Used"
    else
        put "Unused"
    end if
end loop


Saad
hav0c0001




PostPosted: Sat Jun 09, 2007 12:01 pm   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

Thanks alot...ill giev it a try
DIIST




PostPosted: Sat Jun 09, 2007 3:07 pm   Post subject: Re: I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

K, you should try the examples the others provided, but also consider using classes. It can help you out on these kind of assignments. It helped my sister. Laughing
hav0c0001




PostPosted: Sat Jun 09, 2007 8:49 pm   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

haha k cool thanks alot, but how do i know what example to check?:S i didnt see any trivia games posted:S
hav0c0001




PostPosted: Mon Jun 11, 2007 9:43 am   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

for the code above...should my whole code in between?
Sponsor
Sponsor
Sponsor
sponsor
hav0c0001




PostPosted: Mon Jun 11, 2007 9:49 am   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

oh, sorry about that question above...it was a little bit confusing...i ment to ask if i need to put ever single one of my questions into that array...?:S thanks!
hav0c0001




PostPosted: Mon Jun 11, 2007 9:55 am   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

Perhaps if you'd like to see my code...it's about 6000 lines long (all repeaditive copy and pasting) you can email me at Pat_5678@hotmail.com you might need to see it...it's a bit confusing... Thanks again:P
berrberr




PostPosted: Mon Jun 11, 2007 2:19 pm   Post subject: Re: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

hav0c0001 @ Mon Jun 11, 2007 9:55 am wrote:
Perhaps if you'd like to see my code...it's about 6000 lines long (all repeaditive copy and pasting) you can email me at Pat_5678@hotmail.com you might need to see it...it's a bit confusing... Thanks again:P


Nope I dont think anyone wants to sort through 6000 lines of if statements Laughing.

To answer your question, use someones suggestion of implementing an array of booleans that when false mean that that particular question has been answered already. One way to do this would be to have 2 seperate arrays - one array holding all your questions, and he second array holding the booleans of wether that question has been answered or not. This method would be really simple to create and implement. Heres a baisc example (in pseudo code of course Razz):

Turing:

%Question array...
question(1) = "Question 1?"
question(2) = "Question 2?"
%And so on....

%Booleans showing wether the question has been used or not
%Set the defaults to false
for i: 1 .. Whatever
    asked(i) := false
end for

%Now we have our questions, and we know weather they have been answered or not.
%To check if they have been answered you can do something like this...
for i: 1 .. num of questions
    if asked(i) := true then
        put "Already asked...next question"
    else
        put question(i)
        asked(i) = true
    end if
end for


And thats about it. Very basic but it works. Also for a bit of a challenge, and to reduce the amount of lines in your code, try to implement an alternative method of storing all of your question/answers. I would suggest storing them in a text file, and then once you start up your program, open up that text file and assign the questions/answers to your various arrays. That would make things much, much better Wink.[syntax=""][/syntax][syntax=""][/syntax]
hav0c0001




PostPosted: Mon Jun 11, 2007 2:38 pm   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

haha thanks...and that array is for each and every question individually? oh and i dont think im gonna sort my code i got about 3 days to finish, ive barely been programming for 4 months in turing haha.
Clayton




PostPosted: Mon Jun 11, 2007 2:50 pm   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

instead of parallell arrays, I would suggest you check out records. This way, you can define your own type, create an array of this custom type, and overall keep things much more tidy.
hav0c0001




PostPosted: Mon Jun 11, 2007 3:12 pm   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

:S more new stufff :S example if you dont mind please...id appreciate it very much... thanks alot!
Clayton




PostPosted: Mon Jun 11, 2007 3:44 pm   Post subject: RE:I am currently workin on a turing trivia game, however, i am at the point where there are glitches in my loops.

There's a full tutorial in the Turing Walkthrough.
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 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: