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

Username:   Password: 
 RegisterRegister   
 Going back to the beginning of a deck
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
implosion




PostPosted: Wed Jun 10, 2009 4:52 pm   Post subject: Going back to the beginning of a deck

What is it you are trying to achieve?
when reaching end of array (The deck) going back to the beginning


What is the problem you are having?
keep getting an array out of bound error




Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


 var CARD := Card
        var Game_Over_Check : flexible array 1 .. 0 of int
        var Game_Over : boolean := true
        for i : 1 .. upper (FirstPlayer)
            new Game_Over_Check, i
            if FirstPlayer (i) = -1 then
                Game_Over_Check (i) := -1
            else
                Game_Over_Check (i) := 0
            end if
        end for
        for j : 1 .. upper (Game_Over_Check)
            if Game_Over_Check (j) not= -1 then
                Game_Over := false
            end if
        end for
        if Game_Over = false then
            if CARD > upper (FirstPlayer) then
                CARD := 1
            elsif CARD = upper (FirstPlayer) then
                if FirstPlayer (CARD) = -1 then
                    CARD := 1
                else



Please specify what version of Turing you are using
4.1

i'm also attaching the zip folder of it all



Guess.zip
 Description:

Download
 Filename:  Guess.zip
 Filesize:  310.96 KB
 Downloaded:  86 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Jun 10, 2009 5:42 pm   Post subject: RE:Going back to the beginning of a deck

well you know where you are trying to access the array (index) and how large the array is (upper).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
implosion




PostPosted: Wed Jun 10, 2009 7:17 pm   Post subject: RE:Going back to the beginning of a deck

i understand how i would do this if i wasn't making this game object oriented... its weird because i am passing my counter variable into my object but i don't know how to send an integer back from SHUFFLE into MAIN telling it to go to the start. i have a set deck size, but the hands of each player are flexible... oh and ever since i tried to put this method in of checking to see if a player has no cards it won't show the pictures of a card on the main screen to see if your hand is higher or lower... not sure why.. i know the delay is (1) but that was just to quickly go through the game
implosion




PostPosted: Sun Jun 14, 2009 8:25 pm   Post subject: Re: Going back to the beginning of a deck

I've worked on my game some more... i keep going over all my bases to see if everything is right... i've read over everything and i can't find the problem... what the game is trying to do is you try and get all the cards... if you guess right i add the opponents card to your hand and then give the value of what the computer had to -1 and vise vera if you guess wrong. Attached is the updated folder. On the cheat it shows you the value of your card / oppenents card... for some reason i see -1... and if i'm right i should... any help would be appreciated... this is due tomorrow. (n)

edit : in the 2 functions ignore the boolean variable . i forgot to get rid of it.



Final Card Project.zip
 Description:

Download
 Filename:  Final Card Project.zip
 Filesize:  350.17 KB
 Downloaded:  85 Time(s)

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  [ 4 Posts ]
Jump to:   


Style:  
Search: