Computer Science Canada

CONNECT FOUR GAME

Author:  Deeps of Hell [ Thu Jun 05, 2003 10:01 am ]
Post subject:  CONNECT FOUR GAME

code:
setscreen ("graphics:vga")
var brd : array 1 .. 8, 1 .. 8 of string (25)
var name : array 1 .. 2 of string (15)
var matt : array 1 .. 2 of string (5)
var n : array 1 .. 8 of int
var pl, r, c, ct, mc, d1, d2, ht, k, blah : int
var p : array 1 .. 8 of int
var gameover, ok : boolean

procedure setup
    for j : 1 .. 8
        for k : 1 .. 8
            brd (j, k) := "     "
        end for
    end for
    for j : 1 .. 8
        n (j) := 8
    end for
    pl := 1
    color (red)
    matt (1) := "  X  "
    color (black)
    matt (2) := "  O  "
end setup
procedure intro
    for j : 1 .. 2
        put "please input name ", j
        get name (j)
    end for
end intro
procedure display
    cls
    for j : 1 .. 8
        for k : 1 .. 8
            if k < 8 then
                put brd (j, k), "|" ..
            else
                put brd (j, k)
            end if
        end for
        if j < 8 then
            put "-----------------------------------------------"
        end if
    end for
end display
procedure switch
    if pl = 1 then
        pl := 2
    else
        pl := 1
    end if
end switch
procedure check
    ok := true
    if c > 8 or c < 1 then
        ok := false
        put name (pl), "please input numbers between 1->8 ONLY"
    end if
    if ok and n (c) > 0 then
        brd (n (c), c) := matt (pl)
        n (c) := n (c) - 1
    else
        ok := false
        put "pick a column that has room"
    end if
end check
procedure gamedone
    for j : 1 .. 8
        ht := 0
        for k : 1 .. 8
            if brd (j, k) = matt (pl) then
                ht := ht + 1
                if ht = 4 then
                    gameover := true
                end if
            else
                ht := 0
            end if
        end for
    end for
    for j : 1 .. 8
        ht := 0
        for k : 1 .. 8
            if brd (k, j) = matt (pl) then
                ht := ht + 1
                if ht = 4 then
                    gameover := true
                end if
            else
                ht := 0
            end if
        end for
    end for
    ct := 0
    ht := 0
    for d : 1 .. 5
        ct := ct + 1
        k := 0
        for j : ct .. 8
            k := k + 1
            if brd (j, k) = matt (pl) then
                ht := ht + 1
                if ht = 4 then
                    gameover := true
                end if
            else
                ht := 0
            end if
        end for
    end for
    ht := 0
    ct := 9
    for d : 1 .. 5
        ct := ct - 1
        k := 9
        for decreasing j : ct .. 1
            k := k - 1
            if brd (j, k) = matt (pl) then
                ht := ht + 1
                if ht = 4 then
                    gameover := true
                end if
            else
                ht := 0
            end if
        end for
    end for
    ct := 0
    ht := 0
    for d : 1 .. 5
        ct := ct + 1
        k := 9
        for j : ct .. 8
            k := k - 1
            if brd (k, j) = matt (pl) then
                ht := ht + 1
                if ht = 4 then
                    gameover := true
                end if
            else
                ht := 0
            end if
        end for
    end for
    ht := 0
    ct := 9
    for d : 1 .. 5
        ct := ct - 1
        k := 0
        for decreasing j : ct .. 1
            k := k + 1
            if brd (j, k) = matt (pl) then
                ht := ht + 1
                if ht = 4 then
                    gameover := true
                end if
            else
                ht := 0
            end if
        end for
    end for
end gamedone
gameover := false
setup
intro
display
loop
    loop
        put "  1     2     3     4     5     6     7     8"
        put name (pl), " input a col number"
        get c
        check
        exit when ok
    end loop
    display
    gamedone
    exit when gameover
    switch
end loop

Author:  Prince [ Thu Jun 05, 2003 10:16 am ]
Post subject: 

pretty cool game... not bein a mod i dont hav unlimited bits to give away but if i could i would giv u 10 bits

Author:  Tony [ Thu Jun 05, 2003 1:04 pm ]
Post subject: 

simple, but works Very Happy

Next step would be to use some graphics and move away from typing controls... Have players use mouse instead. Then perhaps even an animation of falling piece 8)

Ether way +10 Bits

Author:  PaddyLong [ Thu Jun 05, 2003 3:26 pm ]
Post subject: 

mine's posted in <a href="http://www.compsci.ca/bbs/viewtopic.php?t=1179">this thread</a> Very Happy with AI and stuff it was my final project for grade 11 computer science

Author:  The Stuff [ Mon Jan 12, 2004 10:28 pm ]
Post subject: 

what does the n in the proram do?

Author:  Thuged_Out_G [ Tue Jan 13, 2004 3:13 pm ]
Post subject: 

whats the point of having a submissions and a source code forum...if people are just going to post their source code in the submissions forum Confused Rolling Eyes

Author:  Cervantes [ Tue Jan 13, 2004 4:18 pm ]
Post subject: 

submissions can be for either... source code = pure code

GJ i like it..
btw tony, those graphics own Very Happy

Author:  shorthair [ Tue Jan 13, 2004 7:02 pm ]
Post subject: 

What does taht guy mean he cant give 10 bits HE HAS 400 , give him some bits dude ,

+ bits for an awsome program

Author:  the_short1 [ Tue Jan 20, 2004 8:35 pm ]
Post subject: 

Great job.... play it when my teacher is talking endlessly about stuff i already know... +1 Bit.. i saving for title glow... so icant give more...

Author:  kalin [ Wed Jan 21, 2004 4:06 pm ]
Post subject: 

Cool. Its cool. And question, what is the point of bits anyway??? I"m lost on that..

Author:  shorthair [ Wed Jan 21, 2004 4:12 pm ]
Post subject: 

Its in the FAQ , but a brief overview would be , you get them for good programs , 2 for posting a message ,and 1 for a thread , you can use them to buy name effects ( colors ) and you can buy tech stuff aswell , i bought an email at compsci , also you can give the m to people for good programs , the more you give the more you recieve ( its true ive seen it in action)

Author:  kalin [ Wed Jan 21, 2004 4:14 pm ]
Post subject: 

Well, alright.....I kinda get what you're saying....I think the FaQ will cover it better...well more...umm, I'll shut up

Author:  romper [ Tue Jun 15, 2004 11:49 pm ]
Post subject: 

myn is here
http://www.compsci.ca/v2/viewtopic.php?p=51823#51823

Author:  the_short1 [ Wed Jun 16, 2004 9:57 pm ]
Post subject: 

for one ... u brought up a realy old post..... once its past the first 2 pages.... read and download the progs... but norm us compsciers dont like seing it come back up..

second... please
dont 'plug' your programs is other's threads...

i used to get bitched at for that... *when i was new to compsci...
.so i thought i would pass on that before the others (Asian s, Mazer, otherS) get mad....



Thanks

Author:  king_boby [ Mon Jun 21, 2004 3:11 pm ]
Post subject: 

it has an error as soon as i run it........

Author:  the_short1 [ Mon Jun 21, 2004 7:38 pm ]
Post subject: 

posting the error message is good so we can know how to fix..
.

probable cause: u didn;ed copy the whpole code..


: