User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: A program to type in, like you used to

Wed Feb 15, 2012 10:33 am

Here's a little program to type in and then maybe to modify and play with.Minimum = 1
Maximum = 12

result = dict()

for x in range(Minimum,Maximum+1):
for y in range(Minimum,Maximum+1):
total = x + y
sum = str(x) + "+" + str(y)
if total in result:
result[total] = result[total] + ", " + sum
else:
result[total] = sum

for i in range(Minimum+Minimum, Maximum+Maximum+1):
if i not in result:
print (i, ": ")
else:
print (i,": ", result)

It's Python version 3. If you have Python 2 it will work, but it will work better if you remove the parentheses from the two print lines.

It proves that Triskaidekaphobia is not all in your head

adlambert

Re: A program to type in, like you used to

Wed Feb 15, 2012 1:30 pm

Looks like a very good way for anyone used to curly-brace delimiting of code blocks to quickly learn about the Python indentation requirement!

And how even when you are curly-brace delimited, we still use indentation to aid readability.

To be done on the second Friday in April 2012....

User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4186
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: A program to type in, like you used to

Wed Feb 15, 2012 1:42 pm

rurwin said:


Here"s a little program to type in and then maybe to modify and play with.Minimum = 1
Maximum = 12

result = dict()

for x in range(Minimum,Maximum+1):
for y in range(Minimum,Maximum+1):
total = x + y
sum = str(x) + "+" + str(y)
if total in result:
result[total] = result[total] + ", " + sum
else:
result[total] = sum

for i in range(Minimum+Minimum, Maximum+Maximum+1):
if i not in result:
print (i, ": ")
else:
print (i,": ", result)

It"s Python version 3. If you have Python 2 it will work, but it will work better if you remove the parentheses from the two print lines.

It proves that Triskaidekaphobia is not all in your head


Sorry it"s too readable. where are the faded letters and poor alignment of the lines?

Minimum = 1 Maximum = 12 result = dict() for x in range(Minimum,Maximum+1): for y in range(Minimum,Maximum+1): total = x + y sum = str(x) + "+" + str(y) if total in result: result[total] = result[total] + ", " + sum else: result[total] = sum for i in range(Minimum+Minimum, Maximum+Maximum+1): if i not in result: print (i, ": ") else: print (i,": ", result

That"s better although still cut & pastable

[edit: and ugh trying to be a clever wotsit really mucks up formatting too ]

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: A program to type in, like you used to

Wed Feb 15, 2012 2:42 pm

Sorry. here you go.


User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4186
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: A program to type in, like you used to

Wed Feb 15, 2012 2:52 pm

much better. although it would have been nice if you'd used thermal paper and a ZX printer


User avatar
grumpyoldgit
Posts: 1452
Joined: Thu Jan 05, 2012 12:20 pm

Re: A program to type in, like you used to

Wed Feb 15, 2012 2:55 pm

You forgot the section of code that has been inserted into the middle of another program completely and you don't discover why they don't work until you read the apology in next month's magazine.

I remember one ZX81 program I spent a whole weekend typing up, wobbly rampack willing! I could fly this helicopter across the screen but then, for some reason I never managed to work out, it came back across the screen upside down.

itsonlyme
Posts: 129
Joined: Sun Feb 12, 2012 12:43 pm

Re: A program to type in, like you used to

Wed Feb 15, 2012 4:12 pm

You were not the only one with an upside down helicopter, also had a pacman type thing which when you killed it, it remained on the screen but was not killable again. Hard work when you are getting to the end and trying to workout which ones are still alive.

Malcolm

(another grumpyoldget, moaning about Asda at the moment

User avatar
Chromatix
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki

Re: A program to type in, like you used to

Wed Feb 15, 2012 5:21 pm

ukscone said:


much better. although it would have been nice if you'd used thermal paper and a ZX printer




I'm pretty sure I've got a PCW with a daisy-wheel printer that might still work.
The key to knowledge is not to rely on people to teach you it.

TonyHoyle
Posts: 25
Joined: Thu Nov 24, 2011 3:34 pm

Re: A program to type in, like you used to

Wed Feb 15, 2012 7:37 pm

I hope we see much, much more of this kind of stuff.

When I was just starting out, it was being able to type programs in, see results, then fiddle with them to make them do other things, that taught me programming.

I was having so much fun I didn't realize I was learning..

User avatar
Gert van Loo
Posts: 2486
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: A program to type in, like you used to

Wed Feb 15, 2012 8:53 pm

Sorry there is no English translation of "De robot van de Rommelmarkt". The story of a boy who buys an old robot to do his calculations and reading for him. But it is old, he has to program all the multiplication tables in it and teach it how to read. I probably don't have to tell the end of the story but I liked the sentence:

He asked the robot: 'How much is seven times eight?' 'Fifty six' said the robot. 'Right' said the boy. He had the strange feeling that something weird was happening but he could not put his finger on it.

TheEponymousBob
Posts: 205
Joined: Mon Jan 02, 2012 5:05 am
Contact: Website

Re: A program to type in, like you used to

Wed Feb 15, 2012 9:28 pm

I should probably have trademarked the phrase "stealth education".

Lynbarn
Posts: 464
Joined: Wed Jan 04, 2012 11:03 pm
Contact: Website

Re: A program to type in, like you used to

Wed Feb 15, 2012 11:21 pm

Gert said:


Sorry there is no English translation of "De robot van de Rommelmarkt".



Google translates this to "The robot of the Flea Market", which I think fits in quite well with your synopsys.

"Rommel" also translates as "clutter", which suits the English term  "flea market".

User avatar
Robert_M
Posts: 211
Joined: Fri Nov 25, 2011 12:50 am

Re: A program to type in, like you used to

Thu Feb 16, 2012 12:53 am

Gert said:


Sorry there is no English translation of "De robot van de Rommelmarkt". The story of a boy who buys an old robot to do his calculations and reading for him. But it is old, he has to program all the multiplication tables in it and teach it how to read. I probably don't have to tell the end of the story but I liked the sentence:

He asked the robot: 'How much is seven times eight?' 'Fifty six' said the robot. 'Right' said the boy. He had the strange feeling that something weird was happening but he could not put his finger on it.



I remember a TV show in the US in the late 60s, early 70s, that used this plotline. A boy programmed a computer to do his homework for him and at first the adults said, "no way" but then it became clear he had to develop the smarts to program the machine, first, so then it was okay. I want to say it was an episode of "The Brady Bunch" or maybe "The Courtship of Eddie's Father" but can't be 100% sure. Something from that era.
I sometimes ride my Pi to the Forum.

User avatar
Jongoleur
Posts: 1179
Joined: Thu Aug 11, 2011 12:47 pm
Location: O'erlooking the sea, and all those effin windfarms...

Re: A program to type in, like you used to

Thu Feb 16, 2012 8:36 am

ukscone said:


much better. although it would have been nice if you'd used thermal paper and a ZX printer





Over the weekend I'll have a look in the attic and see if I can find the ZX81, a cassette deck and the plain-paper thermal printer.  And one of my collection of saved programs that I typed in in the early 80s.

If it all works, I'll scan the printout in at 72dpi/low contrast/skewed and post it for you to work out what it does.....

Can't say fairer than that!



(Sadly, I don't have a ZX metallic foil thermal printer, so you'll have to make do with the Alphacom...)
I'm just a bouncer, splatterers do it with more force.....

User avatar
Luny
Posts: 113
Joined: Tue Nov 29, 2011 12:29 pm
Location: Ewell, Surrey
Contact: Website

Re: A program to type in, like you used to

Thu Feb 16, 2012 9:00 am

You guys are bringing up feelings I haven't had since…

Typing in a zx81 program and it actually working was an amazing thing. Then, as mentioned, fiddling with it (the game that is) breaking it, changing it. I was doubting my need for a Pi this morning but you guys ahve convinced me. Its a good cause anyway, only $35 and even if I only use it for a short time…

I've been saving up for an LED tv, as I still had a CRT, and would have gone on comparing and hesitating what to buy. However the thought of getting a PI convinced me to get one last week. So now I have a shiny new TV ready for a Pi Of course if I don't get the one of the 1st lot (unlikely) I can watch TV on it via NetFlix

I also started to put together a simple adventure in Python, ready to list and maybe put a tutorial together on how to write one.

10 + 2 = 12 (base 3)
Luny

adlambert

Re: A program to type in, like you used to

Thu Feb 16, 2012 10:19 am

If anyone wants some ZX81 nostalgia, then using a browser with Java enabled, clickety-click on this link: Simon Holdsworth ZX81 Emulator

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: A program to type in, like you used to

Thu Feb 16, 2012 10:42 am

Plenty of people here saying they love typing in programs, but I haven't seen anyone say they've tried this program yet

I've another on the way that I first wrote in the 1970's. It's a fun story.

Back in 1979 I was doing my A-level in Computer Science, and this was one of the programs I submitted. I wrote it on a 110baud teletype talking to a time-shared computer somewhere in the Birmingham Council Treasury department. As I left school, they took possession of a new Research Machines 380Z that the PTA had bought them for around £10,000. But, with only a longing glance over my shoulder, I got my A-level and proceeded to Manchester University. That's relevant because that is where the JMB exam board was based, which came in very handy when on registering for our courses we found that we did not have the right paperwork and had to queue up outside the JMB office to get it.

So I registered on the course and started lectures, and was introduced to the computer centre's computer. As part of that I was looking around to see what was there and how it was used and stuff. Imagine my surprise, when I found the program I had written, and sent to the JMB office just around the corner, was already on the computer!

After a few enquiries, it turned out that, in the intervening time between June and October, an enterprising pupil at my old school had converted the program to run on the 380Z and submitted it to a magazine. A staff member in the computer centre had seen it and reconverted it to run on the rather more impressive computer there.

I've not got the original listing unfortunately, so I'm re-writing it in Python. Bate your breath...

User avatar
Jongoleur
Posts: 1179
Joined: Thu Aug 11, 2011 12:47 pm
Location: O'erlooking the sea, and all those effin windfarms...

Re: A program to type in, like you used to

Thu Feb 16, 2012 7:47 pm

adlambert said:


If anyone wants some ZX81 nostalgia, then using a browser with Java enabled, clickety-click on this link: Simon Holdsworth ZX81 Emulator


Arghhhh!!!  Its all very well but there's two keyboard related problems.

1 You don't get the correct dead-finger feeling when typing on your PC keyboard

2. You need to google for the ZX81 keyboard layout, or you'll never remember that double quotes are shifted P.  I lucked out with print, goto and run!

Oh, and the program doesn't disappear when you move the keyboard and the 16K RAM Pack falls off…… 

Apart from that, most satisfying!!!
I'm just a bouncer, splatterers do it with more force.....

Lynbarn
Posts: 464
Joined: Wed Jan 04, 2012 11:03 pm
Contact: Website

Re: A program to type in, like you used to

Thu Feb 16, 2012 8:25 pm

Jongoleur said:


adlambert said:


If anyone wants some ZX81 nostalgia, then using a browser with Java enabled, clickety-click on this link: Simon Holdsworth ZX81 Emulator


Arghhhh!!!  Its all very well but there's two keyboard related problems.

1 You don't get the correct dead-finger feeling when typing on your PC keyboard

2. You need to google for the ZX81 keyboard layout, or you'll never remember that double quotes are shifted P.  I lucked out with print, goto and run!

Oh, and the program doesn't disappear when you move the keyboard and the 16K RAM Pack falls off…… 

Apart from that, most satisfying!!!



... and you don't get that smell of the stylus burning into the printer paper! Ah yes, I remember it well!

User avatar
Cannon Fodder
Posts: 14
Joined: Thu Feb 16, 2012 8:05 pm

Re: A program to type in, like you used to

Thu Feb 16, 2012 9:43 pm

Lynbarn said:


Jongoleur said:


adlambert said:


If anyone wants some ZX81 nostalgia, then using a browser with Java enabled, clickety-click on this link: Simon Holdsworth ZX81 Emulator


Arghhhh!!!  Its all very well but there's two keyboard related problems.

1 You don't get the correct dead-finger feeling when typing on your PC keyboard

2. You need to google for the ZX81 keyboard layout, or you'll never remember that double quotes are shifted P.  I lucked out with print, goto and run!

Oh, and the program doesn't disappear when you move the keyboard and the 16K RAM Pack falls off…… 

Apart from that, most satisfying!!!


... and you don't get that smell of the stylus burning into the printer paper! Ah yes, I remember it well!


Or the carton of milk falling off

JonB
Posts: 220
Joined: Tue Nov 29, 2011 9:26 pm

Re: A program to type in, like you used to

Fri Feb 17, 2012 1:05 pm

Microsoft 8k BASIC Adventure game.


1 REM *** Discovered circa 1980 on a Commodore PET
3 REM ***   at Hereford Technical College
4 REM *** Resurrected & bugfixed By Jon Bradbury / JonB
5 REM ***   from a yellowing 31 year old dot matrix printout
6 REM *** http://forum.6502.org
7 REM *** For UK101 8k BASIC, 71 character lines but should work on all.
10 PRINT"Wait till the coast is clear...":PRINT
100 DIM R$(3,3,3),RZ(6),T$(3),MZ(5),M$(5),F$(7),G$(7)
112 DIM C$(7),B$(3),BZ(3),Z$(20),S$(3),W$(3)
120 DATA "W0rough","01carved","02stone","$3square"
130 DATA "\1decorated","03child's"," 1misty","L0lamp-lit"
140 DATA "\1decorated","00mossy","&3pink","L1grey"
150 DATA "X3poster","02dark","81gloomy","(2round"
160 DATA "E1armoured","P0icy","53peacock","$0octagonal"
170 DATA "X2crystal","&3tumble-down","L0slimy","H1magnificent"
180 DATA "T3tilted",",0treacly","Y1humped","$2whispering"
190 DATA "J0echoing","X1medical"," 2lace","H3glass"
200 DATA "T2vast","%2vast","D0hermit's","D1boulder-strewn"
210 DATA "H2vast","H0sloping","L1narrow","L2silken"
220 DATA "T0littered","01vaulted",":2smoky","(3frog"
230 DATA "Y1musty","02rich","03glittering"," 0bone-strewn"
240 DATA "P3tattered","40jewelled","00jewelled"," 2torture"
250 DATA "E0silver","X1splendid","02doctor's","$3waiting"
260 DATA "\1flickering","02music","03bear",",0eerie"
270 DATA "X2bird"," 3tiny","P0foul-smelling","(1mouldy"
280 FOR L=0 TO 3:FOR J=0 TO 3:FOR K=0 TO 3:READ R$(J,K,L)
282 NEXT K:NEXT J:NEXT L
290 DATA "cave","hall","chamber","room"
300 FOR J=0 TO 3:READ T$(J):NEXT J
310 DATA -16,16,4,-4,1,-1
320 DATA "up","down","north","south","east","west"
330 FOR X=0 TO 5:READ MZ(X):NEXT X:FOR X=0 TO 5:READ M$(X):NEXT X
340 DATA "/01mean","dwarf","#41nasty little","gnome"
350 DATA "942blood sucking","vampire","244fearsome","ogre"
352 DATA "G00huge and smelly","wumpus"
360 DATA "M13gibbering","orc","_25deadly","manticore"
362 DATA "Q40fiery","dragon"
370 FOR X=0 TO 7:READ F$(X):READ G$(X):NEXT X
380 DATA "#1silver coins","+1doubloons","32dollars",">2sovereigns"
390 DATA "N3pieces of eight","G4byzantine coins","R6gold pieces"
392 DATA "^9treasure coins"
400 FOR X=0 TO 7:READ C$(X):NEXT X
401 DATA " Daylight filters down from above.."
402 DATA ",There are travel posters all over the walls."
403 DATA "0Rusted suits of armour line the walls."
404 DATA "'Water drips down from above..."
405 DATA "5The stairs are broken and dangerous."
406 DATA "9The going gets sticky..."
407 DATA "EBroken stairs hang out of reach above."
408 DATA "<Something belches... belches... belches..."
409 DATA "1Rubble chokes a downward tunnel.","1It's cold..."
410 DATA "6..watch your step!"
411 DATA "JSign - 'Folding stairs / One way only'"
412 DATA "ZAn empty bear cage is bolted to the wall"
413 DATA "OSome bones look recent..","Q** NO SMOKING **"
414 DATA "RA large treasure chest stands open."
415 DATA "\Exotic birds flit overhead."
416 DATA "SIncome tax forms are strewn about."
417 DATA "SGhostly screams are heard..","DA clogged tunnel lies below."
418 DATA "KI hear croaking... ribbit... ribbit..."
419 FOR J=0 TO 20:READ Z$(J):NEXT J
420 DATA "%doll","=bottle of ointment","Fring","[sword"
422 FOR X=0 TO 3:READ B$(X):NEXT X
430 DATA ",A poster says 'Travel",";A voice says 'Sleep"
440 DATA "BA scrawled note says 'Battle","VA diploma reads 'Healing"
450 X=RND(10):FOR X=0 TO 3:READ S$(X):W$(X)="X"
460 FOR J=1 TO X+2:Z$=CHR$(RND(1)*15+65):W$(X)=W$(X)+Z$:NEXT J,X
470 V=20
480 IF V<15 THEN V=15:PRINT "Vitality restored to 15."
490 J=0:K=0:L=-1:D$=">":R$="You are above ground over a cave.":GOTO 520
500 D$=LEFT$(R$,1):T=VAL(MID$(R$,2,1)):H$=T$(T)
510 RR$=MID$(R$,3):R$="You are in a":LR=ASC(LEFT$(RR$,1))
512 IF LR=97 OR LR=101 OR LR=105 OR LR=111 OR LR=117 THEN RG$="n"
514 R$=R$+RG$+" "+RR$+" "+H$+"."
520 PRINT R$:A=J*4+K+L*16
530 R=-1:D=ASC(D$):D1=1:FOR X=0 TO 5:IF (D AND D1)>0 THEN GOSUB 1320
540 D1=D1*2:NEXT X:A1=A+32
542 IF (R=0) AND (RZ(0)+M2=0) THEN PRINT "== DEAD END =="
545 FOR X=0 TO 20:IF ASC(Z$(X))=A1 THEN PRINT MID$(Z$(X),2)
546 NEXT X
550 FOR X=0 TO 3:IF ASC(S$(X))=A1 THEN 570
560 NEXT X:GOTO 580
570 IF (X<>3) OR (BZ(1)=1) THEN 572
571 GOTO 580
572 PRINT MID$(S$(X),2);" spell word is ";W$(X);"'."
580 B1=0:FOR X=0 TO 3:IF ASC(B$(X))=A1 THEN 600
590 NEXT X:GOTO 620
600 B$=MID$(B$(X),2):B1=1:B2=X
610 PRINT "There is a ";B$;" here."
620 C1=0:FOR X=0 TO 7
622 IF C$(X)="" THEN C$(X)=" ":GOTO 630
624 IF ASC(C$(X))=A1 THEN 640
630 NEXT X:GOTO 660
640 C1=VAL(MID$(C$(X),2,1))*100:C$=MID$(C$(X),3)
642 PRINT "There are ";C1;C$;" here."
650 C2=X
660 G$="":FOR X=0 TO 7
662 IF F$(X)="" THEN F$(X)=" ":GOTO 670
664 IF ASC(F$(X))=A1 THEN 680
670 NEXT X:GOTO 710
680 G$=G$(X):PRINT "A ";MID$(F$(X),4);" ";G$;" bars your way!"
690 G1=VAL(MID$(F$(X),2,1)):G2=VAL(MID$(F$(X),3,1))*100
692 IF G2=0 THEN G2=1E9
700 G3=INT(X+1)*INT(X/3+1):G5=X
710 REM INPUT MOVE
720 INPUT "Move :";Y$:Z$=LEFT$(Y$,1)
730 J1=0:K1=0:L1=0
740 IF Z$="D" OR Z$="d" THEN L1=1
750 IF Z$="U" OR Z$="u" THEN L1=-1
760 IF Z$="N" OR Z$="n" THEN J1=1
770 IF Z$="S" OR Z$="s" THEN J1=-1
780 IF Z$="E" OR Z$="e" THEN K1=1
790 IF Z$="W" OR Z$="w" THEN K1=-1
795 IF (Z$="L" OR Z$="l") AND L=-1 THEN 490
796 IF (Z$="L" OR Z$="l") THEN 870
797 IF Z$="Q" OR Z$="q" THEN 1440
800 M1=K1+4*J1+16*L1:IF M1=0 THEN 880
810 FOR X=0 TO R:IF M1=RZ(X) THEN 830
820 NEXT X:PRINT "You can't go that way.":GOTO 720
830 IF (G$<>"") AND (M1+M2<>0) THEN 834
832 GOTO 840
834 PRINT "The ";G$;" won't let you pass!":GOTO 720
840 M9=M9+1:M2=M1:J=J+J1:K=K+K1:L=L+L1
850 IF (L=-1) AND (J+K=0) THEN 480
860 IF L=-1 THEN 1440
870 R$=R$(J,K,L):GOTO 500
880 IF (Z$="F") OR (Z$="B") OR Z$="f" OR Z$="b" THEN 1120
890 IF Z$="T" OR Z$="t" THEN 1030
900 IF Z$="X" OR Z$="x" THEN 930
910 ?:?"North South East West Up Down Fight Bargain Take":?
920 GOTO 720
930 FOR X=0 TO 3:IF Y$=W$(X) THEN 960
940 NEXT X
950 PRINT "?? Nothing happens ??":GOTO 720
960 IF (L=3) AND (X=2) THEN 950
970 IF X=0 THEN J=3:K=3:M2=3:GOTO 850
980 IF (X>0) AND (X<3) AND (G$="") THEN 950
990 S$(X)="":W$(X)=""
1000 IF X=1 THEN PRINT "The ";G$;" falls asleep.":G$="":GOTO 720
1010 IF X=2 THEN PRINT "The ";G$;" vanishes!":G$="":F$(G5)="a":GOTO 720
1020 V=20:PRINT "Vitality restored to 20":GOTO 720
1030 IF B1+C1=0 THEN PRINT "?? Nothing here ??":GOTO 720
1040 IF G$<>"" THEN PRINT "The ";G$;" won't let you have it!":GOTO 720
1050 IF B1=0 THEN GOTO 1110
1060 BZ(B2)=1:B1=0:B$(B2)="a"+MID$(B$(B2),2)
1070 PRINT "You now have:";:Z=C$(L*2)=C$(L*2+1)
1072 FOR X=0 TO 3:IF BZ(X)=0 THEN 1090
1080 PRINT:PRINT ".. A ";MID$(B$(X),2);"."
1090 NEXT X:IF Z THEN PRINT:PRINT "** All treasure in level ";L+1;
1100 PRINT:PRINT ".. ";V1;"coins.":GOTO 720
1110 E=E+1:V1=V1+C1:C1=0:C$(C2)="a":T9=T9+1:GOTO 1070
1120 IF G$="" THEN PRINT "?? Nobody here ??":GOTO 720
1130 IF Z$="B" OR Z$="b" THEN 1210
1140 PRINT "The ";G$;" ";:G4=5:IF G3<=5 THEN G4=G3:GOTO 1170
1150 PRINT "is wounded!";
1160 GOTO 1180
1170 PRINT "is dead!";:G$="":F$(G5)="a":E=E+1
1180 V=V-INT(G4*10/(10+E+8*BZ(2)))
1182 IF V<=0 THEN PRINT " - BUT YOU'VE BEEN KILLED TOO!":GOTO 1480
1190 PRINT:PRINT "Your vitality is reduced to ";V
1192 IF V<5 THEN PRINT "I think you need magical assistance.."
1200 G3=G3-G4:GOTO 720
1210 IF G2>V1 THEN 1240
1220 PRINT "The greedy swine of a ";G$;" wants ";G2;"coins - OK?";
1222 INPUT Z$:IF LEFT$(Z$,1)="N" OR LEFT$(Z$,1)="n" THEN 1240
1230 V1=V1-G2:GOTO 1290
1240 IF G1>3 THEN 1310
1250 IF BZ(G1)=0 THEN 1310
1260 PRINT "The ";G$;" will take the ";MID$(B$(G1),2);" - OK?";
1270 INPUT Z$:IF LEFT$(Z$,1)="N" OR LEFT$(Z$,1)="n" THEN 1310
1280 BZ(G1)=0
1290 PRINT"It's a deal! The ";G$;" is gone."
1300 E=E+1:G$="":F$(G5)="a":GOTO 1070
1310 PRINT "No deal - looks like a smackdown is in order..":GOTO 720
1320 R=R+1:M=MZ(X):RZ(R)=M:M$=M$(X)
1330 X$="You may go":IF L<0 THEN 1430
1340 A1=A+M:IF A1<0 THEN 1430
1350 L1=INT(A1/16):A1=A1-L1*16:J1=INT(A1/4):K1=A1-J1*4
1360 T1=VAL(MID$(R$(J1,K1,L1),2,1))
1370 IF T=1 THEN X$="The "+H$+" continues":GOTO 1430
1380 IF (T<>3) AND (T1<>3) THEN 1410
1390 X$="A doorway opens":IF ABS(M)>15 THEN X$="A stairway leads"
1400 GOTO 1430
1410 IF (T=0) OR (T=1) THEN X$="A tunnel goes":GOTO 1430
1420 X$="A passage leads"
1430 PRINT X$;" ";M$;".":RETURN
1440 PRINT "You have left the cave area with ";V1;"coins."
1460 FOR X=0 TO 7
1462 IF LEFT$(C$(X),1)<>"a" THEN PRINT "You missed the ";MID$(C$(X),3)
1470 NEXT X
1480 PRINT:PRINT "Your score is ";
1490 IF M9=0 THEN PRINT V*2:END
1495 PRINT INT(V1*24/M9+V*2)
1497 END


JonB
Posts: 220
Joined: Tue Nov 29, 2011 9:26 pm

Re: A program to type in, like you used to

Fri Feb 17, 2012 1:06 pm

By the way, i have scans of the original listing, but it contains many errors which I have since fixed - the above listing is the working (nearly, sort of, etc) version.

Watch out for the manticore!

NAB
Posts: 32
Joined: Wed Sep 14, 2011 6:52 pm

Re: A program to type in, like you used to

Fri Feb 17, 2012 1:28 pm

rurwin said:


Plenty of people here saying they love typing in programs, but I haven't seen anyone say they've tried this program yet


Sorry. I have tried it, but only by cut and paste!

Never having touched Python before, I worked out what it did although I did at first think that the curly braces must have got lost in the forum formatting before realising that they weren't needed.

Not sure I like code without curly braces!

Nicholas.

User avatar
Jongoleur
Posts: 1179
Joined: Thu Aug 11, 2011 12:47 pm
Location: O'erlooking the sea, and all those effin windfarms...

Re: A program to type in, like you used to

Fri Feb 17, 2012 4:40 pm

NAB said:

Not sure I like code without curly braces!


Python does look rather naked without the syntactical sugar.....

@ JonB :  I'll have to try running that on my Amstrad NC200 - its got BBC Basic!
I'm just a bouncer, splatterers do it with more force.....

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: A program to type in, like you used to

Fri Feb 17, 2012 5:51 pm

NAB said:


Not sure I like code without curly braces!


It takes a while to get used to. Then it's another bug that never happens.

C Bug


if (something)

do something

do something else


Another one that never bites you is the dangling else:

Another C bug


if (something)

if (another)

do something

else

do something else


Of course the simple solution to both of those is to use curly braces without fail.

Return to “General discussion”