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

Username:   Password: 
 RegisterRegister   
 Turing Connect Four Stacking Problem
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2, 3, 4  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Michael3176




PostPosted: Fri Jan 04, 2013 9:45 pm   Post subject: RE:Turing Connect Four Stacking Problem

Ok I'll try it out and hopefully it will help me, thanks ill get back to you
Sponsor
Sponsor
Sponsor
sponsor
Michael3176




PostPosted: Sat Jan 05, 2013 3:11 pm   Post subject: RE:Turing Connect Four Stacking Problem

ok so do i make a function called searchColoumn,that includes the for loop you gave me, and then use that in every if statement in processing
Michael3176




PostPosted: Sat Jan 05, 2013 3:13 pm   Post subject: RE:Turing Connect Four Stacking Problem

this would be my function,
Turing:

function searchColoumn (y : int) : int
    for decreasing i : 6 .. 0
        if i = 0 then
            board (coloumn, 1) := player
            validMove := true
            exit
        elsif board (coloumn, i) not= 0 then
            if i = 6 then
                validMove := false
                exit
            else
                board (coloumn, i + 1) := player
                validMove := true
                exit
            end if
        end if
    end for
end searchColoumn


Mod Edit:

Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code:

[syntax="turing"] ... code ... [/syntax]

[code] ... code ... [/code ]
Michael3176




PostPosted: Sat Jan 05, 2013 3:15 pm   Post subject: Re: Turing Connect Four Stacking Problem

and this is a bit of proccessing but its not working

Turing:

proc processing
    setup
    y := searchColoumn
    if coloumn = 1 then
        if player = 1 then
            drawfilloval (65, 35, 20, 20, red)
            board (1, y) := 1
        else
            drawfilloval (65, 35, 20, 20, blue)
            board (1, y) := 2
        end if
    elsif coloumn = 2 then
GuCCIP




PostPosted: Sat Jan 05, 2013 3:42 pm   Post subject: Re: Turing Connect Four Stacking Problem

Michael3176




PostPosted: Sat Jan 05, 2013 4:39 pm   Post subject: RE:Turing Connect Four Stacking Problem

I made a procedure like this

proc searchColoumn
setup
for decreasing i : 6 .. 0
if i = 0 then
board (coloumn, 1) := player
validMove := true
exit
elsif board (coloumn, i) not= 0 then
if i = 6 then
validMove := false
exit
else
board (coloumn, i + 1) := player
validMove := true
exit
end if
end if
end for
end searchColoumn

and in processing did this

proc processing
if coloumn = 1 then
if player = 1 then
searchColoumn
drawfilloval (65, 35, 20, 20, red)

but how would i make an oval be drawn ontop now? I tried doing if coloumn = 1 then
if player = 1 then
searchColoumn
display, and in display i wrote if board (1,1) then drawoval but it did not work. it said if must be boolean type
Raknarg




PostPosted: Sat Jan 05, 2013 6:19 pm   Post subject: RE:Turing Connect Four Stacking Problem

You need to draw your ovals differently. You're doing it the hard way atm. Think about it, you already have a map that tells you where everything is. just make it bigger, then draw it on the screen.

for instance, look at this program.

Turing:

var map : array 0 .. 5, 0 .. 5 of int

for i : 0 .. 5
    for j : 0 .. 5
        map (i, j) := Rand.Int (0, 255)
        Draw.FillBox (i * 25, j * 25, i * 25 + 25, j * 25 + 25, map (i, j))
    end for
end for


This is the thing you want to do. But instead of map (i, j), you want to draw it red or black according to the player who placed it. Do you get what I'm saying?
Michael3176




PostPosted: Sat Jan 05, 2013 8:02 pm   Post subject: Re: Turing Connect Four Stacking Problem

ok if i drew it like this
for i : 1 .. 7
for j : 1 .. 6
Draw.Oval (i * 50, j * 50, 20, 20, 1)
end for
end for

it would draw all the ovals at once? so how would the game work
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sat Jan 05, 2013 8:07 pm   Post subject: RE:Turing Connect Four Stacking Problem

Only draw the ones you need. Look in each spot in your array, and if there's a chip in that spot, draw it.
Michael3176




PostPosted: Sat Jan 05, 2013 9:18 pm   Post subject: RE:Turing Connect Four Stacking Problem

ok i got something like this now

proc searchColoumn
setup
for i : 6 .. 0
if i = 0 then
board (coloumn, 1) := player
validMove := true
exit
elsif board (coloumn, i) not= 0 then
if i = 6 then
validMove := false
exit
else
board (coloumn, i + 1) := player
validMove := true
exit
end if
end if
Draw.FillOval ((coloumn) * 50, i * 50, 20, 20, red)
end for
end searchColoumn

the stacking problem is still there, and what ever coloumn i enter, the whole row is filled up
Raknarg




PostPosted: Sat Jan 05, 2013 9:43 pm   Post subject: RE:Turing Connect Four Stacking Problem

Except you dont need to draw it there either. Like you can, it's just better orgranized if all the drawing is done together and at once
Michael3176




PostPosted: Sat Jan 05, 2013 9:46 pm   Post subject: RE:Turing Connect Four Stacking Problem

so how and where would i draw it? and do i use both variables "i" and "column" when drawing ?
Raknarg




PostPosted: Sat Jan 05, 2013 9:48 pm   Post subject: RE:Turing Connect Four Stacking Problem

in a sense. You can have a procedure for drawing if you want. It's basically just what I put in that program before, with some minor differences
Michael3176




PostPosted: Sat Jan 05, 2013 9:52 pm   Post subject: RE:Turing Connect Four Stacking Problem

ok but i dont understand why its not drawing where i put it to, because its giving the coloumn, and you said the for statement "for i : 6 .. 0
if i = 0 then
board (coloumn, 1) := player
validMove := true
exit
elsif board (coloumn, i) not= 0 then
if i = 6 then
validMove := false
exit
else
board (coloumn, i + 1) := player
validMove := true
exit
end if
end if
end for"
would make the height stack, correct? but maybe that for statement is wrong?
jr5000pwp




PostPosted: Sat Jan 05, 2013 9:52 pm   Post subject: Re: Turing Connect Four Stacking Problem

Can you please, please, please use the
code:
[syntax="turing"][/syntax]
formatiing tags? It would make it a lot easier for us to read and help you with.

As for your filling problem, think about what your doing with your searchColumn function, why do you have it, what is it's purpose, and most of all, what line doesn't belong? Hint: You aren't actually filling the column atm.
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 2 of 4  [ 51 Posts ]
Goto page Previous  1, 2, 3, 4  Next
Jump to:   


Style:  
Search: