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

Username:   Password: 
 RegisterRegister   
 I need help finding out how to alter the code in the following way : Within the thread
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
Velocity




PostPosted: Sun Nov 06, 2011 11:49 am   Post subject: I need help finding out how to alter the code in the following way : Within the thread

What is it you are trying to achieve?

I am trying to find out the answer as to what i had wrote below.

What is the problem you are having?

I am trying figure out how to change the code so that after it finishes scene 1, it will switch to scene 2.
I am also trying to figure out how to make it so that when the green light goes on, the car will drive, but when the red light comes it will stop.

Describe what you have tried to solve this problem

I have tried altering the code in many ways, and have tried to find tutorials around this forum for help.
I could not find any tutorials. I have also tried to delete some of the code to possibly make it work, but i am now stumped, and have no clue how to fix either of them.

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

Nothing else relevant.

Turing:


View.Set ("graphics:800;700,offscreenonly,nobuttonbar")
var keyinput : string (1) := "x"
process playstuff
    loop
        sound (160, 516)
        delay (100)
        sound (270, 200)
        delay (100)
        sound (230, 230)
        delay (100)
        sound (476, 520)
        delay (100)
        sound (236, 250)
        delay (100)
    end loop
end playstuff
fork playstuff
loop
    for i : 1 .. 800
        delay (10)
        cls
        %----------------------------------------------------------------%
        colourback (5)
        cls
        %Defense Wall
        drawfillbox (0, 125, 800, 275, 28)
        %end Defense Wall
        %cloud
        drawfillbox (100, 525, 450, 575, white)
        %end cloud
        %sun
        drawfilloval (600, 600, 50, 50, yellow)
        %end sun
        %grass
        drawfillbox (800, 200, 0, 100, green)
        %end grass
        %sidewalk
        drawfillbox (0, 105, 800, 140, 27)
        drawfillbox (75, 105, 199, 150, 27)
        drawfillbox (75, 105, 80, 150, black)
        drawfillbox (194, 105, 199, 150, black)
        drawline (300, 105, 300, 140, black)
        drawline (400, 105, 400, 140, black)
        drawline (500, 105, 500, 140, black)
        drawline (600, 105, 600, 140, black)
        drawline (700, 105, 700, 140, black)
        drawfillbox (70, 105, 75, 105, black)
        %end sidewalk
        %house
        drawfillbox (450, 300, 200, 150, brightred)
        %end house
        %garage
        drawfillbox (75, 150, 199, 250, 4)
        drawfill (135, 170, blue, 4)
        drawline (75, 150, 75, 250, black)
        drawline (199, 150, 199, 250, black)
        drawline (75, 175, 199, 175, black)
        drawline (75, 200, 199, 200, black)
        drawline (75, 225, 199, 225, black)
        drawline (75, 250, 199, 250, black)
        %end garage
        %door
        drawfillbox (313, 130, 347, 150, 27)
        drawfillbox (318, 150, 343, 200, 22)
        drawfilloval (335, 165, 3, 3, black)
        %end door
        %windows
        drawfillbox (250, 240, 300, 280, 77)
        drawline (275, 240, 275, 280, black)
        drawline (250, 260, 300, 260, black)
        drawfillbox (350, 240, 400, 280, 77)
        drawline (375, 240, 375, 280, black)
        drawline (350, 260, 400, 260, black)
        %end windows
        %road
        drawfillbox (800, 0, 0, 105, black)
        %end road
        %Car1
        drawfillbox (70 + i, 11, 120 + i, 31, 141)
        drawfillbox (85 + i, 31, 105 + i, 41, 71)
        drawfilloval (75 + i, 5, 8, 8, 24)
        drawfilloval (115 + i, 5, 8, 8, 24)
        %end Car1
        %Car2
        drawfillbox (670 - i, 75, 720 - i, 105, 14)
        drawfillbox (685 - i, 105, 705 - i, 115, 41)
        drawfilloval (675 - i, 75, 6, 6, 24)
        drawfilloval (715 - i, 75, 6, 6, 24)
        %end Car2
        %YellowRoundStripes
        drawfillbox (150, 55, 40, 45, yellow)
        drawfillbox (350, 55, 240, 45, yellow)
        drawfillbox (550, 55, 440, 45, yellow)
        drawfillbox (750, 55, 640, 45, yellow)
        %end YellowRoundStripes
        %roof
        drawline (200, 300, 325, 350, brown)
        drawline (450, 300, 325, 350, brown)
        drawline (200, 300, 450, 300, brown)
        drawfill (250, 315, 56, brown)
        %end roof
        %trees
        %left tree
        drawline (465, 250, 600, 250, brown)
        drawline (465, 250, 532, 350, brown)
        drawline (600, 250, 532, 350, brown)
        drawfill (500, 300, 10, brown)
        drawfillbox (520, 250, 545, 200, brown)
        %right tree
        drawline (650, 250, 775, 250, brown)
        drawline (650, 250, 712, 350, brown)
        drawline (775, 250, 712, 350, brown)
        drawfill (712, 275, 10, brown)
        drawfillbox (725, 250, 700, 200, brown)
        %end trees
        %chimney
        drawfillbox (200, 300, 250, 365, 56)
        %end chimney
        %traffic light
        if i < 200 then

            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 280, 8, 8, green)

        elsif i < 300 then
            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 280, 8, 8, 11)
            drawfilloval (625, 255, 8, 8, yellow)

        else
            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 255, 8, 8, 11)
            drawfilloval (625, 230, 8, 8, red)

        end if
        View.UpdateArea (0, 0, maxx, maxy)
        %end traffic light
        %END SCENE 1
    end for
end loop
%----------------------------------------------------------------%
%SCENE 2
for i : 1 .. 400
    cls
    delay (1000)
    colourback (blue)
    cls
    %Defense Wall
    drawfillbox (0, 125, 800, 275, 28)
    %end Defense Wall
    %moon
    drawfilloval (700, 600, 50, 50, 24)
    %end moon
    drawfillbox (800, 200, 0, 100, green)
    drawfillbox (0, 105, 800, 140, 27)
    drawfillbox (75, 105, 199, 150, 27)
    drawfillbox (75, 105, 80, 150, black)
    drawfillbox (194, 105, 199, 150, black)
    drawline (300, 105, 300, 140, black)
    drawline (400, 105, 400, 140, black)
    drawline (500, 105, 500, 140, black)
    drawline (600, 105, 600, 140, black)
    drawline (700, 105, 700, 140, black)
    drawfillbox (70, 105, 75, 105, black)
    drawfillbox (75, 150, 199, 250, 4)
    drawfill (135, 170, blue, 4)
    drawline (75, 150, 75, 250, black)
    drawline (199, 150, 199, 250, black)
    drawline (75, 175, 199, 175, black)
    drawline (75, 200, 199, 200, black)
    drawline (75, 225, 199, 225, black)
    drawline (75, 250, 199, 250, black)
    drawfillbox (450, 300, 200, 150, brightred)
    drawfillbox (313, 130, 348, 150, 27)
    drawfillbox (318, 150, 343, 200, 22)
    drawfilloval (335, 165, 3, 3, black)
    drawfillbox (800, 0, 0, 105, black)
    drawfillbox (75, 6, 115, 26, 14)
    drawfillbox (85, 26, 105, 36, 41)
    drawfilloval (78, 5, 6, 6, 24)
    drawfilloval (113, 5, 6, 6, 24)
    drawfillbox (675, 75, 715, 95, 141)
    drawfillbox (685, 95, 705, 105, 71)
    drawfilloval (680, 75, 8, 8, 24)
    drawfilloval (710, 75, 8, 8, 24)
    drawfillbox (150, 55, 40, 45, yellow)
    drawfillbox (350, 55, 240, 45, yellow)
    drawfillbox (550, 55, 440, 45, yellow)
    drawfillbox (750, 55, 640, 45, yellow)
    drawline (200, 300, 325, 350, brown)
    drawfillbox (250, 240, 300, 280, 77)
    drawline (275, 240, 275, 280, black)
    drawline (250, 260, 300, 260, black)
    drawline (450, 300, 325, 350, brown)
    drawline (200, 300, 450, 300, brown)
    drawfill (250, 315, 56, brown)
    drawfillbox (350, 240, 400, 280, 77)
    drawfilloval (375, 260, 15, 15, 31)
    drawfillbox (375, 240, 370, 250, 31)
    drawfillbox (200, 300, 250, 365, 56)
    %stars
    drawfillstar (150, 600, 200, 650, yellow)
    drawfillstar (300, 400, 350, 450, yellow)
    drawfillstar (400, 600, 450, 650, yellow)
    %end stars
    %trees
    %left tree
    drawline (465, 250, 600, 250, brown)
    drawline (465, 250, 532, 350, brown)
    drawline (600, 250, 532, 350, brown)
    drawfill (500, 300, 10, brown)
    drawfillbox (520, 250, 545, 200, brown)
    %right tree
    drawline (650, 250, 775, 250, brown)
    drawline (650, 250, 712, 350, brown)
    drawline (775, 250, 712, 350, brown)
    drawfill (712, 275, 10, brown)
    drawfillbox (725, 250, 700, 200, brown)
    %end trees
    %traffic light
    drawfillbox (615, 140, 635, 300, 11)
    drawfilloval (625, 280, 8, 8, green)
    delay (2000)
    drawfilloval (625, 280, 8, 8, 11)
    drawfilloval (625, 255, 8, 8, yellow)
    delay (2000)
    drawfilloval (625, 255, 8, 8, 11)
    drawfilloval (625, 230, 8, 8, red)
    delay (2000)
    %end traffic light
    %END SCENE 2
    %----------------------------------------------------------------%
    exit when keyinput = chr (10)
    delay (250)
end for




Please specify what version of Turing you are using
I am using 4.11a, but i also need it to run on my school computer which is turing 4.01a
Sponsor
Sponsor
Sponsor
sponsor
Velocity




PostPosted: Sun Nov 06, 2011 12:39 pm   Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread

I will give 3 bits <<<< LOL to the answer-(er).
Velocity




PostPosted: Sun Nov 06, 2011 12:57 pm   Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread

Bump - Still looking for answer... Thanks to anyone who is trying.
Aange10




PostPosted: Sun Nov 06, 2011 1:00 pm   Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread

Velocity wrote:

What is the problem you are having?

I am trying figure out how to change the code so that after it finishes scene 1, it will switch to scene 2.
I am also trying to figure out how to make it so that when the green light goes on, the car will drive, but when the red light comes it will stop.


Okay so lets go one at a time.

Velocity wrote:

I am trying figure out how to change the code so that after it finishes scene 1, it will switch to scene 2.


So how would we let the computer know that we've completed the scene? How about something like

Turing:

var scene : int := 1
var counter : int := 0

loop % A loop containing the scenes
    if scene = 1 then
        loop % Scene one
            counter += 1
            % Coding
            if counter = 200 then
                scene := 2
            end if
            exit when scene not = 1
        end loop
    elsif scene = 2 then
        counter := 0
        loop % Scene two
            counter += 1
            % Coding
            if counter = 300 then
                scene := 3
            end if
            exit when scene not = 2
        end loop
    else % If scene isn't 1 or 2
        % Program complete!
        exit
    end if
end loop



Now, lets tackle your second problem:

Velocity wrote:

I am also trying to figure out how to make it so that when the green light goes on, the car will drive, but when the red light comes it will stop.


Okay, so how could we tell the computer that the light is green or if its red ? Once we tell the computer it's red, how do we stop the car? Or make it stop moving?

Turing:

var red_light : boolean := false
if red_light = true then
     car_velocity := 0 % Stops moving
elsif red_light = false then
     car_velocity := 5 % Keeps going
end if
Velocity




PostPosted: Sun Nov 06, 2011 1:13 pm   Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread

Turing:



View.Set ("graphics:800;700,offscreenonly,nobuttonbar")
var keyinput : string (1) := "x"
var scene : int := 1
var counter : int := 0
var red_light : boolean := false
var car_velocity : int
if red_light = true then
    car_velocity := 0  % Stops moving
elsif red_light = false then
    car_velocity := 5  % Keeps going
end if

process playstuff
    loop
        sound (160, 516)
        delay (100)
        sound (270, 200)
        delay (100)
        sound (230, 230)
        delay (100)
        sound (476, 520)
        delay (100)
        sound (236, 250)
        delay (100)
    end loop
end playstuff
fork playstuff
loop
    for i : 1 .. 800
        delay (10)
        cls
        loop % A loop containing the scenes
            if scene = 1 then
                loop % Scene one
                    counter += 1
                    % Coding
                    if counter = 200 then
                        scene := 2
                    end if
                    exit when scene not= 1
                end loop
            elsif scene = 2 then
                counter := 0
                loop % Scene two
                    counter += 1
                    % Coding
                    if counter = 300 then
                        scene := 3
                    end if
                    exit when scene not= 2
                end loop
            else % If scene isn't 1 or 2
                % Program complete!
                exit
            end if
        end loop

        %----------------------------------------------------------------%
        colourback (5)
        cls
        %Defense Wall
        drawfillbox (0, 125, 800, 275, 28)
        %end Defense Wall
        %cloud
        drawfillbox (100, 525, 450, 575, white)
        %end cloud
        %sun
        drawfilloval (600, 600, 50, 50, yellow)
        %end sun
        %grass
        drawfillbox (800, 200, 0, 100, green)
        %end grass
        %sidewalk
        drawfillbox (0, 105, 800, 140, 27)
        drawfillbox (75, 105, 199, 150, 27)
        drawfillbox (75, 105, 80, 150, black)
        drawfillbox (194, 105, 199, 150, black)
        drawline (300, 105, 300, 140, black)
        drawline (400, 105, 400, 140, black)
        drawline (500, 105, 500, 140, black)
        drawline (600, 105, 600, 140, black)
        drawline (700, 105, 700, 140, black)
        drawfillbox (70, 105, 75, 105, black)
        %end sidewalk
        %house
        drawfillbox (450, 300, 200, 150, brightred)
        %end house
        %garage
        drawfillbox (75, 150, 199, 250, 4)
        drawfill (135, 170, blue, 4)
        drawline (75, 150, 75, 250, black)
        drawline (199, 150, 199, 250, black)
        drawline (75, 175, 199, 175, black)
        drawline (75, 200, 199, 200, black)
        drawline (75, 225, 199, 225, black)
        drawline (75, 250, 199, 250, black)
        %end garage
        %door
        drawfillbox (313, 130, 347, 150, 27)
        drawfillbox (318, 150, 343, 200, 22)
        drawfilloval (335, 165, 3, 3, black)
        %end door
        %windows
        drawfillbox (250, 240, 300, 280, 77)
        drawline (275, 240, 275, 280, black)
        drawline (250, 260, 300, 260, black)
        drawfillbox (350, 240, 400, 280, 77)
        drawline (375, 240, 375, 280, black)
        drawline (350, 260, 400, 260, black)
        %end windows
        %road
        drawfillbox (800, 0, 0, 105, black)
        %end road
        %Car1
        drawfillbox (70 + i, 11, 120 + i, 31, 141)
        drawfillbox (85 + i, 31, 105 + i, 41, 71)
        drawfilloval (75 + i, 5, 8, 8, 24)
        drawfilloval (115 + i, 5, 8, 8, 24)
        %end Car1
        %Car2
        drawfillbox (670 - i, 75, 720 - i, 105, 14)
        drawfillbox (685 - i, 105, 705 - i, 115, 41)
        drawfilloval (675 - i, 75, 6, 6, 24)
        drawfilloval (715 - i, 75, 6, 6, 24)
        %end Car2
        %YellowRoundStripes
        drawfillbox (150, 55, 40, 45, yellow)
        drawfillbox (350, 55, 240, 45, yellow)
        drawfillbox (550, 55, 440, 45, yellow)
        drawfillbox (750, 55, 640, 45, yellow)
        %end YellowRoundStripes
        %roof
        drawline (200, 300, 325, 350, brown)
        drawline (450, 300, 325, 350, brown)
        drawline (200, 300, 450, 300, brown)
        drawfill (250, 315, 56, brown)
        %end roof
        %trees
        %left tree
        drawline (465, 250, 600, 250, brown)
        drawline (465, 250, 532, 350, brown)
        drawline (600, 250, 532, 350, brown)
        drawfill (500, 300, 10, brown)
        drawfillbox (520, 250, 545, 200, brown)
        %right tree
        drawline (650, 250, 775, 250, brown)
        drawline (650, 250, 712, 350, brown)
        drawline (775, 250, 712, 350, brown)
        drawfill (712, 275, 10, brown)
        drawfillbox (725, 250, 700, 200, brown)
        %end trees
        %chimney
        drawfillbox (200, 300, 250, 365, 56)
        %end chimney
        %traffic light

        if i < 200 then

            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 280, 8, 8, green)

        elsif i < 300 then
            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 280, 8, 8, 11)
            drawfilloval (625, 255, 8, 8, yellow)

        else
            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 255, 8, 8, 11)
            drawfilloval (625, 230, 8, 8, red)

        end if
        View.UpdateArea (0, 0, maxx, maxy)

        %end traffic light
        %END SCENE 1
    end for
end loop
%----------------------------------------------------------------%
%SCENE 2
loop
    for i : 1 .. 800
        delay (10)
        cls
        colourback (blue)
        cls
        %Defense Wall
        drawfillbox (0, 125, 800, 275, 28)
        %end Defense Wall
        %moon
        drawfilloval (700, 600, 50, 50, 24)
        %end moon
        drawfillbox (800, 200, 0, 100, green)
        drawfillbox (0, 105, 800, 140, 27)
        drawfillbox (75, 105, 199, 150, 27)
        drawfillbox (75, 105, 80, 150, black)
        drawfillbox (194, 105, 199, 150, black)
        drawline (300, 105, 300, 140, black)
        drawline (400, 105, 400, 140, black)
        drawline (500, 105, 500, 140, black)
        drawline (600, 105, 600, 140, black)
        drawline (700, 105, 700, 140, black)
        drawfillbox (70, 105, 75, 105, black)
        drawfillbox (75, 150, 199, 250, 4)
        drawfill (135, 170, blue, 4)
        drawline (75, 150, 75, 250, black)
        drawline (199, 150, 199, 250, black)
        drawline (75, 175, 199, 175, black)
        drawline (75, 200, 199, 200, black)
        drawline (75, 225, 199, 225, black)
        drawline (75, 250, 199, 250, black)
        drawfillbox (450, 300, 200, 150, brightred)
        drawfillbox (313, 130, 348, 150, 27)
        drawfillbox (318, 150, 343, 200, 22)
        drawfilloval (335, 165, 3, 3, black)
        drawfillbox (800, 0, 0, 105, black)
        drawfillbox (75 + i, 6, 115 + i, 26, 14)
        drawfillbox (85 + i, 26, 105 + i, 36, 41)
        drawfilloval (78 + i, 5, 6, 6, 24)
        drawfilloval (113 + i, 5, 6, 6, 24)
        drawfillbox (675 - i, 75, 715 - i, 95, 141)
        drawfillbox (685 - i, 95, 705 - i, 105, 71)
        drawfilloval (680 - i, 75, 8, 8, 24)
        drawfilloval (710 - i, 75, 8, 8, 24)
        drawfillbox (150, 55, 40, 45, yellow)
        drawfillbox (350, 55, 240, 45, yellow)
        drawfillbox (550, 55, 440, 45, yellow)
        drawfillbox (750, 55, 640, 45, yellow)
        drawline (200, 300, 325, 350, brown)
        drawfillbox (250, 240, 300, 280, 77)
        drawline (275, 240, 275, 280, black)
        drawline (250, 260, 300, 260, black)
        drawline (450, 300, 325, 350, brown)
        drawline (200, 300, 450, 300, brown)
        drawfill (250, 315, 56, brown)
        drawfillbox (350, 240, 400, 280, 77)
        drawfilloval (375, 260, 15, 15, 31)
        drawfillbox (375, 240, 370, 250, 31)
        drawfillbox (200, 300, 250, 365, 56)
        %stars
        drawfillstar (150, 600, 200, 650, yellow)
        drawfillstar (300, 400, 350, 450, yellow)
        drawfillstar (400, 600, 450, 650, yellow)
        %end stars
        %trees
        %left tree
        drawline (465, 250, 600, 250, brown)
        drawline (465, 250, 532, 350, brown)
        drawline (600, 250, 532, 350, brown)
        drawfill (500, 300, 10, brown)
        drawfillbox (520, 250, 545, 200, brown)
        %right tree
        drawline (650, 250, 775, 250, brown)
        drawline (650, 250, 712, 350, brown)
        drawline (775, 250, 712, 350, brown)
        drawfill (712, 275, 10, brown)
        drawfillbox (725, 250, 700, 200, brown)
        %end trees
        %traffic light
        if i < 200 then

            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 280, 8, 8, green)

        elsif i < 300 then
            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 280, 8, 8, 11)
            drawfilloval (625, 255, 8, 8, yellow)

        else
            drawfillbox (615, 140, 635, 300, 11)
            drawfilloval (625, 255, 8, 8, 11)
            drawfilloval (625, 230, 8, 8, red)

        end if


        %end traffic light
        %END SCENE 2
        %----------------------------------------------------------------%
        exit when keyinput = chr (10)
        delay (250)
    end for
end loop






I added in the code like you said. The program runs, but it doesn't do anything :O
<h1>Im sorry if my inexperienced self did not put it in the correct spots</h1>
Aange10




PostPosted: Sun Nov 06, 2011 1:23 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

Hmm, do not copy and paste the coding I gave you; the code is written for you to understand it, not to copy and paste it - it doesn't work because it doesn't do anything.

Try looking at the coding, one line at a time.

Turing:

if scene = 1 then
                loop % Scene one
                    counter += 1
                    % Coding
                    if counter = 200 then
                        scene := 2
                    end if
                    exit when scene not= 1
                end loop


We are saying here that if the scene variable is set to the value of 1 , then we will execute the scene. Which I made a little scene there. We also have something telling us when to exit the scene. Right now It's set to change the scene to 2 when the counter reaches 200. Then I tell the computer to exit when scene is not = to 1 . .. Meaning we are no longer on the first scene.


Make sense?
Velocity




PostPosted: Sun Nov 06, 2011 1:33 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

ooooh, okay thanks alot! that helped.
Aange10




PostPosted: Sun Nov 06, 2011 1:53 pm   Post subject: Re: RE:I need help finding out how to alter the code in the following way : Within the thread

Velocity @ 6/11/2011, 12:33 pm wrote:
ooooh, okay thanks alot! that helped.


No problem.
Sponsor
Sponsor
Sponsor
sponsor
Velocity




PostPosted: Sun Nov 06, 2011 4:58 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

okay, i got it too work thanks alot.
Velocity




PostPosted: Sun Nov 06, 2011 4:59 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

but wait, one more thing. What about the red light - stop, green light - go, thing?
Aange10




PostPosted: Sun Nov 06, 2011 5:34 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

Analyze the code step by step again.

Turing:


var red_light : boolean := false
if red_light = true then
     car_velocity := 0 % Stops moving
elsif red_light = false then
     car_velocity := 5 % Keeps going
end if


I declared a boolean named red_light. I then set the boolean red_light to false. Now I tell the computer if red_light = true then it stops the car's velocity. After that I said if red_light is false then make the car's velocity to 5.
Tony




PostPosted: Sun Nov 06, 2011 6:25 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

I don't remember, does Turing typecast boolean values into integers?
code:

car_velocity = 5 * ~red_light
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Aange10




PostPosted: Sun Nov 06, 2011 10:53 pm   Post subject: Re: RE:I need help finding out how to alter the code in the following way : Within the thread

Tony @ 6/11/2011, 5:25 pm wrote:
I don't remember, does Turing typecast boolean values into integers?
code:

car_velocity = 5 * ~red_light


considering

Turing:

var b : boolean := false
var e : int

e := 5 * ~b



Doesn't work, I'll assume not.
Tony




PostPosted: Sun Nov 06, 2011 11:03 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

aww, sad. Though apparently you can have this magic -- via boolean
code:

var speed : array boolean of int := init (5, 0)
...
car_speed = speed(red_light)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Tue Nov 08, 2011 6:51 pm   Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread

This may be more off topic than on topic, but...
Tony you work for or host the DWITE contest right? cause im going there first time this year for my school, is it worthwhile?
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  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: