LOGO-L> Re: MSWLogo-UCBLogo 
Author Message
 LOGO-L> Re: MSWLogo-UCBLogo

MSWLogo does not support a single index color (it's RGB).
Many of your other programs used SETPC as MSWLogo requires?
I modified the program with some ugly colors, I'll let you
choose them. Also note SETCURSOR is ignored and is not really
needed in this example.

I don't know what the procedure SEQUENCE does, you must have
it in your UCBLogo library.

TO 3STICKS
PU SETPENSIZE [27 27]
SETY -150 SETX -400 PD SETX 400
SETPENSIZE [4 4]
SETX 260  FD 360 BK 360 SETX 0 FD 360 BK 360
SETX -260 FD 360 BK 360 PU
SETXY -70 240 PD LABEL [THE TOWERS OF HANOI] PU
SETXY -285 -205 PD LABEL [START] PU
SETXY -35 -205 PD LABEL [SPARE] PU
SETXY 250 -205 PD LABEL [GOAL]PU
SETXY -260 -150
END

TO ADD :STICK
MOVETO :STICK
FD 30
PENPAINT
DISQ :THIS
MAKE :STICK SE :THIS :DSK
END

TO COLOR :N
OP ITEM :N [[7 0 0] [6 0 0] [3 0 0] [5 0 0] [4 0 0] [12 0 0] [2 0 0]
     [1 0 0] [29 0 0] [10 0 0] [11 0 0] [13 0 0] [7 0 0] [14 0 0] [15 0
0]]
END

TO DESCRIP
CT TS
SETCURSOR [30 2] PR [THE TOWER OF HANOI]
SETCURSOR [25 5] PR [The puzzle begins with a "tower "]
SETCURSOR [25 6] PR [of discs arranged in order of size]
SETCURSOR [25 7] PR [with the largest at the bottom and]
SETCURSOR [25 10] PR [The task is to move them one by one]
SETCURSOR [25 11] PR [from the Start pole to the Goal one]
SETCURSOR [25 12] PR [without placing a larger disc on a]
SETCURSOR [25 13] PR [a smaller one]
SETCURSOR [25 18] PR [Number of disks ? :]
SETCURSOR [25 19] Pr [ ( 10 maximum )]
SETCURSOR [55 18] make "num rw
SETCURSOR [25 20] pr [input delay factor ? :]
SETCURSOR [25 21] pr [ ( 1 , 2 , 3 , 30..)]
SETCURSOR [55 20] make "delay rw pr :delay
END

TO DISKS :SMALL :BIG
IF :SMALL > :BIG [SETY -150 STOP]
IF :BIG = :NUM [FD 20] FD 10
PENPAINT
DISQ :BIG
DISKS :SMALL :BIG - 1
END

TO DISQ :SIZE
SETPC COLOR :SIZE
MAKE "SIZE :SIZE * :FACT
SETPENSIZe [27 27]
LT 90
FD :SIZE
BK :SIZE * 2
FD :SIZE  
RT 90
SETPENSIZE [4 4]
FD 20
MAKE "CC FIRST BUTFIRST PEN
IF :CC = "ERASE [SETPC [3 0 0] PENPAINT BK 28]
PU
END

TO ELIM :STICK
MOVETO :STICK
MAKE "THIS FIRST :DSK
PENERASE
DISQ :THIS
MAKE :STICK BF :DSK
END

TO GO
CT CS SETPC [3 0 0]
DESCRIP
MAKE "FACT 122/ :NUM
CS FS
3STICKS
DISKS 1 :NUM
MAKE "CO 0
MAKE "S2 []
MAKE "S3 []
MAKE "S1 SEQUENCE :NUM
HT
HANOI :NUM "S1 "S2 "S3
CT
PR (SE [IT TOOK] :CO [MOVES FOR] :NUM "DISCS)
WAIT 30
PR [Press a key to play , or esc to quit]
MAKE "DUMMY RC
IF :DUMMY = CHAR 27 [CS HT CT STOP]
GO
END

TO HANOI :NUM :START :SPARE :GOAL
IF :NUM = 0 [STOP]
HANOI :NUM - 1 :START :GOAL :SPARE
WAIT :DELAY
MOVE.ONE :START :GOAL
if keyp [throw "toplevel]
WAIT :DELAY
HANOI :NUM - 1 :SPARE :START :GOAL
END

TO MOVE.ONE :FROM :TO
MAKE "CO :CO + 1
ELIM :FROM
ADD :TO
END

TO MOVETO :STICK
SETX (BF :STICK) * 260 - 520
MAKE "DSK THING :STICK
SETY 30 * (COUNT :DSK) - 150
END

Quote:

> ;Hello George Mills
> ;Hello Brian Harvey
> ;Hello Yehuda Katz
> ;Hello Olga Tuzova
> ;Hello everybody
> ;Some time last year I have adapted the classical program of the TOWERS of
> ;HANOI from an IBMLogo demo to UCBLogo with some variation.
> ;The Port was not difficult. Now since MSWLogo as stated is a derivative
> ;port from UCBLogo this program should need only minor changes to run
> ;under MSWLogo. But alas whatever I tried it refused to run under it.
> ;Is this because I am new to MSWLogo ? or is it due to any other reason?.
> ;Your openion will be much appreciated.
> ;Here is the code for UCBLogo.
> ;Best Regards.
> ;Mhelhefni
> ;---------------------------------------------------------------------

> TO 3STICKS
> PU SETPENSIZE [27 27]
> SETY -150 SETX -400 PD SETX 400
> SETPENSIZE [4 4]
> SETX 260  FD 360 BK 360 SETX 0 FD 360 BK 360
> SETX -260 FD 360 BK 360 PU
> SETXY -70 240 PD LABEL [THE TOWERS OF HANOI] PU
> SETXY -285 -205 PD LABEL [START] PU
> SETXY -35 -205 PD LABEL [SPARE] PU
> SETXY 250 -205 PD LABEL [GOAL]PU
> SETXY -260 -150
> END

> TO ADD :STICK
> MOVETO :STICK
> FD 30
> PENPAINT
> DISQ :THIS
> MAKE :STICK SE :THIS :DSK
> END

> TO COLOR :N
> OP ITEM :N [7 6 3 5 4 12 2 1 29 10 11 13 7 14 15]
> END

> TO DESCRIP
> CT TS
> SETCURSOR [30 2] PR [THE TOWER OF HANOI]
> SETCURSOR [25 5] PR [The puzzle begins with a "tower "]
> SETCURSOR [25 6] PR [of discs arranged in order of size]
> SETCURSOR [25 7] PR [with the largest at the bottom and]
> SETCURSOR [25 10] PR [The task is to move them one by one]
> SETCURSOR [25 11] PR [from the Start pole to the Goal one]
> SETCURSOR [25 12] PR [without placing a larger disc on a]
> SETCURSOR [25 13] PR [a smaller one]
> SETCURSOR [25 18] PR [Number of disks ? :]
> SETCURSOR [25 19] Pr [ ( 10 maximum )]
> SETCURSOR [55 18] make "num rw
> SETCURSOR [25 20] pr [input delay factor ? :]
> SETCURSOR [25 21] pr [ ( 1 , 2 , 3 , 30..)]
> SETCURSOR [55 20] make "delay rw pr :delay
> END

> TO DISKS :SMALL :BIG
> IF :SMALL > :BIG [SETY -150 STOP]
> IF :BIG = :NUM [FD 20] FD 10
> PENPAINT
> DISQ :BIG
> DISKS :SMALL :BIG - 1
> END

> TO DISQ :SIZE
> SETPC COLOR :SIZE
> MAKE "SIZE :SIZE * :FACT
> SETPENSIZe [27 27]
> LT 90
> FD :SIZE
> BK :SIZE * 2
> FD :SIZE
> RT 90
> SETPENSIZE [4 4]
> FD 20
> MAKE "CC FIRST BUTFIRST PEN
> IF :CC = "ERASE [SETPC 3 PENPAINT BK 28]
> PU
> END

> TO ELIM :STICK
> MOVETO :STICK
> MAKE "THIS FIRST :DSK
> PENERASE
> DISQ :THIS
> MAKE :STICK BF :DSK
> END

> TO GO
> CT CS SETPC 3
> DESCRIP
> MAKE "FACT 122/ :NUM
> CS FS
> 3STICKS
> DISKS 1 :NUM
> MAKE "CO 0
> MAKE "S2 []
> MAKE "S3 []
> MAKE "S1 SEQUENCE :NUM
> HT
> HANOI :NUM "S1 "S2 "S3
> CT
> PR (SE [IT TOOK] :CO [MOVES FOR] :NUM "DISCS)
> WAIT 30
> PR [Press a key to play , or esc to quit]
> MAKE "DUMMY RC
> IF :DUMMY = CHAR 27 [CS HT CT STOP]
> GO
> END

> TO HANOI :NUM :START :SPARE :GOAL
> IF :NUM = 0 [STOP]
> HANOI :NUM - 1 :START :GOAL :SPARE
> WAIT :DELAY
> MOVE.ONE :START :GOAL
> if keyp [throw "toplevel]
> WAIT :DELAY
> HANOI :NUM - 1 :SPARE :START :GOAL
> END

> TO MOVE.ONE :FROM :TO
> MAKE "CO :CO + 1
> ELIM :FROM
> ADD :TO
> END

> TO MOVETO :STICK
> SETX (BF :STICK) * 260 - 520
> MAKE "DSK THING :STICK
> SETY 30 * (COUNT :DSK) - 150
> END
> ;------------------------------------------------------------

--
===============================================================

http://www.*-*-*.com/
The www page contains some very powerful educational software.
Our single most important investment is our kids.
---------------------------------------------------------------





Tue, 14 Mar 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. LOGO-L> TYPE in MSWLogo vs UCBLogo

2. LOGO-L> PC-LOGO syntax in MSWLogo

3. LOGO-L> GUI for UCBLogo

4. LOGO-L> About UCBlogo

5. LOGO-L> pure glass shapes in UCBLogo

6. LOGO-L> About UCBlogo

7. LOGO-L> 3d extensions to UCBLogo

8. LOGO-L> setxyz and screw in UCBLogo

9. LOGO-L> ellipsoid and paraboloid in UCBLogo

10. LOGO-L> 3d isometric code in UCBLogo

11. LOGO-L> the snail in UCBLogo

12. LOGO-L> Shuttle in UCBLogo

 

 
Powered by phpBB® Forum Software