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

Username:   Password: 
 RegisterRegister   
 The WTF paradox
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Geostigma




PostPosted: Mon Jan 14, 2008 9:10 am   Post subject: The WTF paradox

I have a question that baffled alot of people.. Makes no sense, but its clearly something I did.

Look at this line, at 85 ish

[/syntax]
Turing:


if triangle (pos) > 0 then
        put "Can't place that there, pick a new position"
        result player
    else
        triangle (pos) := player
        result 0

    end if


Change it to

[/syntax]
Turing:
if triangle (pos) > 0 then
        put "Can't place that there, pick a new position"
        result player
    else
        triangle (pos) := -player
        result 0

    end if


Change it to

[/syntax]
Turing:
if triangle (pos) < 0 then
        put "Can't place that there, pick a new position"
        result player
    else
        triangle (pos) := player
        result 0

    end if


Only the last two works, however don't run my program. This first example is the line of code that should work. I can't figure anything out so i have placed my code on this post and maybe you guys can figure it out.


[syntax]
Turing:
var x : array 1 .. 8 of int
var y : array 1 .. 8 of int
var triangle : array 1 .. 36 of int
var counter : int := 0
var defult, getx, gety, player : int := 1
var score1, score2 : int


type box : % New type, functionbox

    record
        width1, width2 : int %""
        height1, height2 : int %""
        player : int
    end record

var pictri : array 1 .. 36 of box

for a : 1 .. 36
    pictri (a).width1 := 0
    pictri (a).width2 := 0
    pictri (a).height1 := 0
    pictri (a).height2 := 0
    triangle (a) := 0
end for
%Base design structure of graphics
/*for i : 0 .. 7
 for j : 0 .. (7 - i)
 counter += 1
 triangle (counter) := 0
 end for
 end for*/


procedure graphics
    for i : 1 .. 36
        if triangle (i) > 0 then
            drawfillbox (pictri (i).width1, pictri (i).height1, pictri (i).width2, pictri (i).height2, pictri (i).player)
        end if
    end for
end graphics

function blockchecker (player, x, y : int) : int             %Function checks the placement of the block (primary func of prog)

    var temp : int := 0             %temp storage
    var pos : int := 0             %position return variable
    var n : int := 0             % N number of blocks
    temp := y - 2             % The temp var is the called row - 2

    /* ************************CALCULATION***************************/

    if y > 1 then             %ONLY if y is greater then 1 will this loop run
        for a : 0 .. temp             %for the amount of rows(min is once)
            n := 8 - a             %less one row(add 8 for first, 7,6,5..ect
            pos := pos + n             %add it to the position return variable(for x number of runs)
        end for
        pos := pos + x             %Then add the X placement

        pictri (pos).width1 := x * 10
        pictri (pos).height1 := y * 10
        pictri (pos).height2 := y * 10 + 10
        pictri (pos).width2 := x * 10 + 10
        pictri (pos).player := player
    else
        pos := x             %if y is less then or equal to one add only X

        pictri (pos).width1 := x * 10
        pictri (pos).height1 := y * 10
        pictri (pos).height2 := y * 10 + 10
        pictri (pos).width2 := x * 10 + 10
        pictri (pos).player := player
    end if

    /**************POSITION TAKEN************************/

    if triangle (pos) > 0 then
        put "Can't place that there, pick a new position"
        result player
    else
        triangle (pos) := player
        result 0

    end if
end blockchecker


loop                    %Main program loop
    if blockchecker (player, getx, gety) > 0 then             %If error is found and block cannot be placed
        player := blockchecker (player, getx, gety)             %player is set to the return, reselect your position
        put "Player", (player), " what row are you placing a block in?"
        get gety                                            %Get your Y value (row #)
        put "Player", (player), " what position are you placing it in?"
        get getx                                            %get your X Value (row pos)
        loop
            if getx > 8 - (gety - 1) then                   %if you choose an unexising space
                put "That position doesn't exsist for that row, try again"
                get getx             %loop getx until proper place is located
            else
                exit
            end if
        end loop
        put blockchecker (player, getx, gety)
        for v : 1 .. 36             %Temp loop to draw the the triangle
            put triangle (v) ..

        end for
        put ""
    elsif blockchecker (player, getx, gety) = 0 then
        for p : 1 .. 2             % if everything runs smoothly , normal loop run program
            player := p
            put "Player", (p), " what row are you placing a block in?"
            get gety
            put "Player", (p), " what position are you placing it in?"
            get getx
            loop
                if getx > 8 - (gety - 1) then
                    put "That position doesn't exsist for that row, try again"
                    get getx
                else
                    exit
                end if
            end loop
            put blockchecker (player, getx, gety)

            for v : 1 .. 36
                put triangle (v) ..
            end for
            put ""
            cls
            graphics
        end for
    end if
    cls
    graphics
end loop
Sponsor
Sponsor
Sponsor
sponsor
Geostigma




PostPosted: Mon Jan 14, 2008 9:17 am   Post subject: RE:The WTF paradox

Okay nevermind, I shouldn't of used a function, my program is checking the function over and over again until some value is true
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  [ 2 Posts ]
Jump to:   


Style:  
Search: