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

Username:   Password: 
 RegisterRegister   
 help wit turing project
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vsharma88




PostPosted: Sat Jan 22, 2005 2:31 pm   Post subject: help wit turing project

plz help me if u can. thx in advance. here is my problem:

code:
var btoken, wtoken: array 1..5 of int
var  bmove, wmove, temp, x:int

function bremaindertoken(btoken:int):int
    result btoken rem 3
end bremaindertoken

function bmovetoken(btoken:int):int
    result btoken div 3
end bmovetoken

function wremaindertoken(wtoken:int):int
    result wtoken rem 3
end wremaindertoken

function wmovetoken(wtoken:int):int
    result wtoken div 3
end wmovetoken

btoken(1):=1004
btoken(2):=13
btoken(3):=5
btoken(4):=0
btoken(5):=0

wtoken(1):=100
wtoken(2):=10
wtoken(3):=8
wtoken(4):=0
wtoken(5):=0

x:=0

put "                ", btoken(3):5, wtoken(3):5, wtoken(2):5,"         ",wtoken(1):5,btoken(1):8
loop
    x:=x+1
    for counter1:1..5
        bmove:= bmovetoken(btoken(counter1))
        temp:=bremaindertoken(btoken(counter1))
       
        if btoken(counter1) > wtoken(counter1) then
            bmove:= abs(bmove-wtoken(counter1))
        end if
       
        btoken(counter1):=temp
           
   
    put "                ", btoken(3):5, wtoken(3):5, wtoken(2):5,"         ",wtoken(1):5,btoken(1):8
   
    end for
   

   
    exit when x=3
end loop




plz tell me if im on the right track and any problems i have
Sponsor
Sponsor
Sponsor
sponsor
vsharma88




PostPosted: Sat Jan 22, 2005 5:58 pm   Post subject: (No subject)

common can some1 plzzz help me.
basketball4ever




PostPosted: Sat Jan 22, 2005 6:07 pm   Post subject: (No subject)

Compsci isnt a place where you just tell us to do it for you... and we'll do it for you. Its a place where we can give suggestions. and help you out if you have something that you think can be done, but dont know how in code.
vsharma88




PostPosted: Sat Jan 22, 2005 6:55 pm   Post subject: (No subject)

im asking if im on the rite track
Cervantes




PostPosted: Sat Jan 22, 2005 7:04 pm   Post subject: (No subject)

vsharma88 wrote:
plz tell me if im on the right track and any problems i have

Sounds like you're asking us to do steps 1 - 4 for you. Why don't you do them, then get back to us? Wink
Dan




PostPosted: Sat Jan 22, 2005 7:42 pm   Post subject: (No subject)

Also thats looks alot like an ISU asgment there (the big ones that are worth 10%~15%) i don't think your teacher whould be very happy about you scaning it and posting it for peoleop to help u with. There are alot of eftical and moral issues with helping you on this one.......
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Tony




PostPosted: Sat Jan 22, 2005 9:43 pm   Post subject: (No subject)

so how did those archeologists figured out the rules for such an ancient game? Thinking

and you should really start by writing out pseudocode and/or a flowchart. Lets see you finish one of those and we'll give you pointers on putting that into working code.
vsharma88




PostPosted: Sat Jan 22, 2005 9:55 pm   Post subject: (No subject)

1. There are a certain number of tokens on board with 10 spot. On the first pace there is 1004 black tokens on the second one 100 white tokens, there is none on the third, on the fourth pace there are 13 black tokens, on the fifth pace 10 white tokens, on the sixth pace 8 white tokens, on the seventh pace 7 black tokens. The object of the games is to use the tokens to get the least amount of tokens on the tenth pace by following the rules.

2. 1.Start at a position 2. Divide # of tokens by 3 and put that amount in the next spot. 4. If there is white token there for each black cancel each white. 5. Stop when the least amount of tokens have been placed on the 10th spot.

3. Start at a position Divide number of tokens and find reminder. Place the number of tokens of that colour from the divided number to the left and leave the remainder in the box. If the opposite coloured token is on that spot then for each token remove the opposite coloured and the original coloured token. Repeat until the minimum number of tokens has end up on the spot.
Sponsor
Sponsor
Sponsor
sponsor
Leftover




PostPosted: Sun Jan 23, 2005 1:41 am   Post subject: (No subject)

Also might want to add, most CS teachers are members / browse these forums regularly, I know mine does, and many others from local schools. If your teacher saw this, I'd imagine it would be treated the same way as plagiarism (a mark of 0).

I, too, am working on my final for programming, and I work my arse off, and merely post my code, what is wrong with it, what I think can be done but I don't know how to do it, and people give suggestions how I can fix / improve it (not the exact code I need), and I play with and impliment it from there.

Rather then posting the assignment sheet, use the code button at the top of posting window, and post what you have and what your problem is.
vsharma88




PostPosted: Sun Jan 23, 2005 11:01 am   Post subject: (No subject)

ok i posted what i have sooo far and have taken away the paper
vsharma88




PostPosted: Sun Jan 23, 2005 3:48 pm   Post subject: (No subject)

i have been working on trying to solve it and here is my new code:

code:
var btoken, wtoken : array 1 .. 5, 1 .. 2 of int
var bmove, wmove, btemp, wtemp, x : int

function remaindertoken (token : int) : int
    result token rem 3
end remaindertoken

function movetoken (token : int) : int
    result token div 3
end movetoken


btoken (1, 1) := 1004
btoken (2, 1) := 13
btoken (3, 1) := 5
btoken (4, 1) := 0
btoken (5, 1) := 0
btoken (1, 2) := 1004
btoken (2, 2) := 13
btoken (3, 2) := 5
btoken (4, 2) := 0
btoken (5, 2) := 0


wtoken (1, 1) := 100
wtoken (2, 1) := 10
wtoken (3, 1) := 8
wtoken (4, 1) := 0
wtoken (5, 1) := 0
wtoken (1, 2) := 100
wtoken (2, 2) := 10
wtoken (3, 2) := 8
wtoken (4, 2) := 0
wtoken (5, 2) := 0



x := 0

put "                ", btoken (3, 1) : 5, wtoken (3, 1) : 5, wtoken (2, 1) : 5, "         ", wtoken (1, 1) : 5, btoken (1, 1) : 8
loop
    x := x + 1
    for counter1 : 1 .. 5
        for counter2 : 1 .. 2
            bmove := movetoken (btoken (counter1, counter2))
            btemp := remaindertoken (btoken (counter1, counter2))

            if btoken (counter1, counter2) > wtoken (counter1, counter2) then
                bmove := abs (bmove - wtoken (counter1, counter2))
            elsif wtoken (counter1, counter2) > btoken (counter1, counter2) then
                wmove := abs (wmove - btoken (counter1, counter2))
            end if

            wmove := movetoken (wtoken (counter1, counter2))
            wtemp := remaindertoken (btoken (counter1, counter2))
            wtoken (counter1, counter2) := wtemp
            btoken (counter1, counter2) := btemp

            put "                ", btoken (3, 1) : 5, wtoken (3, 1) : 5, wtoken (2, 1) : 5, "         ", wtoken (1, 1) : 5, btoken (1, 1) : 8

            % put "                ", btoken (counter1, counter2) : 5, wtoken (counter1, counter2) : 5, wtoken (counter1, counter2) : 5, "         ", wtoken (counter1, counter2) : 5, btoken (counter1, counter2) : 8
        end for
    end for



    exit when x = 3
end loop


i do not know how to show the pieces moving to the left. plz help
vsharma88




PostPosted: Sun Jan 23, 2005 10:20 pm   Post subject: (No subject)

ok forget about the program is there a way to make a table in turing wit out have to draw it? i tried the turing reference buh there was nothing there
Leftover




PostPosted: Sun Jan 23, 2005 10:49 pm   Post subject: (No subject)

You mean drawing a table in Turing as you would in word or html? I.E. A Draw.Table command?

If so, then no. Just do Draw.Box and copy it, just change the co-ordinates to make it look like a table. Draw.Box will give you a frame in the shape of a box, Draw.FillBox has the same paramaters but fills the box in with whatever color you pick.
vsharma88




PostPosted: Sun Jan 23, 2005 10:53 pm   Post subject: (No subject)

ok thx... btw i think i got it buh it styll needs some working on
vsharma88




PostPosted: Sun Jan 23, 2005 11:51 pm   Post subject: (No subject)

hey all i need some more help, srry. i have a logic error and don't knoe how to fix it.

the end of my program should look like the last lind of the this pic:

Posted Image, might have been reduced in size. Click Image to view fullscreen.

buh what i have is this:

Posted Image, might have been reduced in size. Click Image to view fullscreen.

here is my code:

code:
var btoken, wtoken : array 1 .. 10 of int
var bmove, wmove, btemp, wtemp, x : int
var way : boolean

function remaindertoken (token : int) : int
    result token rem 3
end remaindertoken

function movetoken (token : int) : int
    result token div 3
end movetoken

btoken (1) := 1004
btoken (2) := 0
btoken (3) := 0
btoken (4) := 13
btoken (5) := 0
btoken (6) := 0
btoken (7) := 5
btoken (8) := 0
btoken (9) := 0
btoken (10) := 0


wtoken (1) := 0
wtoken (2) := 100
wtoken (3) := 0
wtoken (4) := 0
wtoken (5) := 10
wtoken (6) := 8
wtoken (7) := 0
wtoken (8) := 0
wtoken (9) := 0
wtoken (10) := 0

x := 0
way := true

put "BLACK" : 7 ..
for decreasing c3 : 10 .. 1
    put btoken (c3) : 7 ..
end for
put ""

put "WHITE" : 7 ..
for decreasing c3 : 10 .. 1
    put wtoken (c3) : 7 ..
end for



loop
    x := x + 1
    for c1 : 1 .. 9
        for c2 : 2 .. 10

            %  if way = true then
            bmove := movetoken (btoken (c1))
            btemp := remaindertoken (btoken (c1))

            % else
            wmove := movetoken (wtoken (c2))
            wtemp := remaindertoken (wtoken (c2))

            % end if


            if bmove >= wtoken (c2) then

                bmove := abs (bmove - wtoken (c2))
                btoken (c2) := bmove
                wtoken (c2) := wtoken (c2) - wtoken (c2)
                %  way := true
            elsif wtoken (c2) >= btoken (c1) then
                wmove := abs (wmove - btoken (c2 + 1))
                wtoken (c2) := wmove
                % way := false
            elsif (bmove >= btoken (c2)) or (bmove < btoken (c2)) then
                btoken (c2) := bmove + btoken (c2)
                %  way := true
            elsif (wmove >= wtoken (c2)) or (wmove < btoken (c2)) then
                wtoken (c2) := wmove + wtoken (c2)
                %   way := false
            elsif btoken (c2) = 0 then
                btoken (c2) := bmove
                %    way := true
            else
                wtoken (c2) := wmove
                %     way := false
            end if
            btoken (c1) := btemp
            wtoken (c2) := wtemp

            put ""
            put ""
            put "BLACK" : 7 ..
            for decreasing c3 : 10 .. 1
                put btoken (c3) : 7 ..
                delay (150)
            end for
            put ""

            put "WHITE" : 7 ..
            for decreasing c3 : 10 .. 1
                put wtoken (c3) : 7 ..
                delay (150)
            end for
        end for
    end for

    exit when x = 10
end loop
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  [ 15 Posts ]
Jump to:   


Style:  
Search: