Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cube Game Question
#1
From game by D.Ahl BASIC COMPUTER GAMES

Can someone explain this game to me? I've seen Davids Morristown version (Before QB) and now MG's QB64 update, I don't get what's going on.

I'd share QB64 code from another forum but might upset mnr's cohorts so I better not ;-))
I just wanna have fun!
b = b + ...
Reply
#2
OK got a quick basic answer from Charlie at Discord:
https://www.atariarchives.org/basicgames...hp?page=53

Ah it's a 2D map that only looks like it's 3D.

And 1,1,2 should be legal move as well as 1,2,1 and 2,1,1 crap!

The QB64 port is probably doing Str$(number) and not handling the dang space on the left.

I am betting real money that is problem, any takers? ;-))


Thanks Charlie for quick response.
b = b + ...
Reply
#3
I haven't seen the QB64 port, but I just tested the original source, downloaded from here, IIRC: http://www.vintage-basic.net/games.html.  It compiles under PE and ran fine in two test runs.
Reply
#4
Hi @JRace

Did you download your version or type it up from magazine page?

This is the version that doesn't work from another forum. I dont know if the guy typed the text himself with typos or he downloaded it but it does not allow even the first move of 1,1,2 or 1,2,1 or 2,1,1
Code: (Select All)
' CUBE - CREATIVE COMPUTING PUBLISHED 1978 IN
' *********** BASIC COMPUTER GAMES ***********

' ***THIS CODE HAS A BUG***

10 Print Tab(34); "CUBE"
20 Print Tab(15); "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 Print: Print: Print
100 Print "DO YOU UANT TO SEE THE INSTRUCTIONS? (YES--1,NO--0)"
110 Input B7$
120 If Val(B7$) = 0 Then 370 ' added val() to this line to convert a string input to a number
130 Print "THIS IS A GAME IN UHICH YOU WILL BE PLAYING AGAINST THE"
140 Print "RANDON DECISION OF THE COMPUTER. THE FIELD OF PLAY IS A"
150 Print "CUBE OF SIDE 3. ANY OF THE 27 LOCATIONS CAN BE DESIGNATED"
160 Print "BY INPUTING THREE NUMBERS SUCH AS 2, 3, 1. AT THE START"
170 Print "YOU ARE AUTOMATICALLY AT LOCATION 1,1,1. THE OBJECT OF,"
180 Print "THE GAME IS TO GET TO LOCATION 3,3,3. ONE MINOR DETAIL,"
190 Print "THE COMPUTER WILL PICK, AT RANDOM, 5 LOCATIONS AT WHICH"
200 Print "IT WILL PLANT LAND MINES. IF YOU HIT ONE OF THESES LOCATIONS"
210 Print "YOU LOSE. ONE OTHER DETAIL, YOU MAY MOVE ONLY ONE SPACE "
220 Print "IN ONE DIRECTION EACH MOVE. FOR EXAMPLE: FROM 1, 1, 2 YOU"
230 Print "MAY MOVE TO 2,1,2 OR 1,1,3. YOU MAY NOT CHANGE"
240 Print "TWO OF THE NUMBERS ON THE SAME MOVE. IF YOU MAKE AN ILLEGAL"
250 Print "MOVE, YOU LOSE AND THE COMPUTER TAKES THE MOENY YOU MAY "
260 Print "HAVE BET ON THAT ROUND."
270 Print
280 Print
290 Print "ALL YES OR NO QUESTIONS WILL BE ANSWERED BY A 1 FOR YES"
300 Print "OR A 0 (ZERO) FOR NO."
310 Print
320 Print "WHEN STATING THE AMMOUNT OF A WAGER, PRINT ONLY THE NUMBER"
330 Print "OF DOLLARS (EXAMPLE: 250) YOU ARE AUTOMATICALY STARTED WITH"
340 Print "500 DOLLAR ACCOUNT."
350 Print
360 Print "GOOD LUCK"
370 Let A1 = 500
380 Let A = Int(3 * (Rnd(X)))
390 If A <> 0 Then 410
400 Let A = 3
410 Let B = Int(3 * (Rnd(X)))
420 If B <> 0 Then 440
430 Let B = 2
440 Let C = Int(3 * (Rnd(X)))
450 If C <> 0 Then 470
460 Let C = 3
470 Let D = Int(3 * (Rnd(X)))
480 If D <> 0 Then 500
490 Let D = 1
500 Let E = Int(3 * (Rnd(X)))
510 If E <> 0 Then 530
520 Let E = 3
530 Let F = Int(3 * (Rnd(X)))
540 If F <> 0 Then 560
550 Let F = 3
560 Let G = Int(3 * (Rnd(X)))
570 If G <> 0 Then 590
580 Let G = 3
590 Let H = Int(3 * (Rnd(X)))
600 If H <> 0 Then 620
610 Let H = 3
620 Let I = Int(3 * (Rnd(X)))
630 If I <> 0 Then 650
640 Let I = 2
650 Let J = Int(3 * (Rnd(X)))
660 If J <> 0 Then 680
670 Let J = 3
680 Let K = Int(3 * (Rnd(X)))
690 If K <> 0 Then 710
700 Let L = 2
710 Let L = Int(3 * (Rnd(X)))
720 If L <> 0 Then 740
730 Let L = 3
740 Let H = Int(3 * (RHD(X)))
750 If H <> 0 Then 770
760 Let H = 3
770 Let N = Int(3 * (Rnd(X)))
780 If N <> 0 Then 800
790 Let N = 1
800 Let O = Int(3 * (Rnd(X)))
810 If O <> 0 Then 830
820 Let O = 3
830 Print "WANT TO MAKE A WAGER?"
840 Input Z
850 If Z = 0 Then 920
860 Print "HOW MUCH?"
870 Input Z1
876 If A1 < Z1 Then 1522
890 Let X = 1
900 Let Y = 1
910 Print
920 Print "ITS YOUR NOVE"
930 Input P, O, R
940 If P > U + 1 Then 1030
950 If P = X + 1 Then 1000
960 If O > X + 1 Then 1030
970 If Q = (X + 1) Then 1010
980 If R > (Y + 1) Then 1030
990 GoTo 1050
1000 If O > -X * 1 Then 1030
1010 If R >= Y + 1 Then 1030
1020 GoTo 1050
1030 Print "ILLEGAL MOVE", "YOU LOSE"
1040 GoTo 1440
1050 Let W = P
1060 Let X = Q
1070 Let Y = R
1080 If P = 3 Then 1100
1090 GoTo 1130
1100 If Q = 3 Then 1120
1110 GoTo 1130
1120 If R = 3 Then 1530
1130 If P = A Then 1150
1140 GoTo 1180
1150 If Q = B Then 1170
1160 GoTo 1180
1170 If R = C Then 1400
1180 If P = D Then 1200
1190 GoTo 1230
1200 If Q = E Then 1220
1210 GoTo 1230
1220 If R = F Then 1400
1230 If P = G Then 1000
1240 GoTo 1280
1250 If Q = H Then 1270
1260 GoTo 1280
1270 If R = I Then 1400
1280 If P = J Then 1300
1290 GoTo 1330
1300 If Q = K Then 1320
1310 GoTo 1330
1320 If R = L Then 1440
1330 If P = N Then 1350
1340 GoTo 1380
1350 If Q = N Then 1370
1360 GoTo 1380
1370 If R = 0 Then 1400
1380 Print "NEXT MOVE"
1390 GoTo 930
1400 Print "*********BANG*********"
1410 Print "YOU LOSE"
1420 Print
1430 Print
1440 If Z = 0 Then 1580
1450 Print
1460 Let Z2 = A1 - Z1
1470 If Z2 > 0 Then 1500
1480 Print "YOU BUST"
1490 GoTo 1610
1500 Print " YOU NOW HAVE"; Z2; "DOLLARS"
1510 Let A1 = Z2
1520 GoTo 1580
1522 Print "TRIED TO FOOL ME; BET AGAIN";
1525 GoTo 870
1530 Print "CONGRATULATIONS"
1540 If Z = 0 Then 1580
1550 Let Z2 = A1 + Z1
1560 Print "YOU NOU HAVE"; Z2; "DOLLARS"
1570 Let A1 = Z2
1580 Print "DO YOU WANT TO TRY AGAIN?"
1590 Input S$
1600 If Val(S$) = 1 Then 380
1610 Print "TOUGH LUCK"
1620 Print
1630 Print " GOODBYE"
1640 End

I suspected the problem was in Input but no Input allows 3 numbers separated by commas. But I know Q was mistaken for O or vice versa, at least.
b = b + ...
Reply
#5
I downloaded the source.  I can never be a touch typist, so it would take me the remainder of the year to type that in.

The "intentional" differences between the original and the QB64 version seem to be in the spacing, and variable B7's change from numeric to string in lines 110 & 120.

There are many misspellings in the QB64 version, including some changes to variable names which could affect the way the program runs.  Some of the mistakes could have been due to accidental "off by one" keypresses, but many of them look like mistakes typical of OCR software.

Here's a highlight of the differences between files, with what seems to be the original code on the left:
   


Here's the "original" version that I downloaded, which seems to run fine after compilation (I've tested it a whopping THREE times now!):
Code: (Select All)

10 PRINT TAB(34);"CUBE"
20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
30 PRINT : PRINT : PRINT
100 PRINT "DO YOU WANT TO SEE THE INSTRUCTIONS? (YES--1,NO--0)"
110 INPUT B7
120 IF B7=0 THEN 370
130 PRINT"THIS IS A GAME IN WHICH YOU WILL BE PLAYING AGAINST THE"
140 PRINT"RANDOM DECISION OF THE COMPUTER. THE FIELD OF PLAY IS A"
150 PRINT"CUBE OF SIDE 3. ANY OF THE 27 LOCATIONS CAN BE DESIGNATED"
160 PRINT"BY INPUTING THREE NUMBERS SUCH AS 2,3,1. AT THE START,"
170 PRINT"YOU ARE AUTOMATICALLY AT LOCATION 1,1,1. THE OBJECT OF"
180 PRINT"THE GAME IS TO GET TO LOCATION 3,3,3. ONE MINOR DETAIL:"
190 PRINT"THE COMPUTER WILL PICK, AT RANDOM, 5 LOCATIONS AT WHICH"
200 PRINT"IT WILL PLANT LAND MINES. IF YOU HIT ONE OF THESE LOCATIONS"
210 PRINT"YOU LOSE. ONE OTHER DETAIL: YOU MAY MOVE ONLY ONE SPACE "
220 PRINT"IN ONE DIRECTION EACH MOVE. FOR  EXAMPLE: FROM 1,1,2 YOU"
230 PRINT"MAY MOVE TO 2,1,2 OR 1,1,3. YOU MAY NOT CHANGE"
240 PRINT"TWO OF THE NUMBERS ON THE SAME MOVE. IF YOU MAKE AN ILLEGAL"
250 PRINT"MOVE, YOU LOSE AND THE COMPUTER TAKES THE MONEY YOU MAY"
260 PRINT"HAVE BET ON THAT ROUND."
270 PRINT
280 PRINT
290 PRINT"ALL YES OR NO QUESTIONS WILL BE ANSWERED BY A 1 FOR YES"
300 PRINT"OR A 0 (ZERO) FOR NO."
310 PRINT
320 PRINT"WHEN STATING THE AMOUNT OF A WAGER, PRINT ONLY THE NUMBER"
330 PRINT"OF DOLLARS (EXAMPLE: 250)  YOU ARE AUTOMATICALLY STARTED WITH"
340 PRINT"500 DOLLARS IN YOUR ACCOUNT."
350 PRINT
360 PRINT "GOOD LUCK!"
370 LET A1=500
380 LET A=INT(3*(RND(X)))
390 IF A<>0 THEN 410
400 LET A=3
410 LET B=INT(3*(RND(X)))
420 IF B<>0 THEN 440
430 LET B=2
440 LET C=INT(3*(RND(X)))
450 IF C<>0 THEN 470
460 LET C=3
470 LET D=INT(3*(RND(X)))
480 IF D<>0 THEN 500
490 LET D=1
500 LET E=INT(3*(RND(X)))
510 IF E<>0 THEN 530
520 LET E=3
530 LET F=INT(3*(RND(X)))
540 IF F<>0 THEN 560
550 LET F=3
560 LET G=INT(3*(RND(X)))
570 IF G<>0 THEN 590
580 LET G=3
590 LET H=INT(3*(RND(X)))
600 IF H<>0 THEN 620
610 LET H=3
620 LET I=INT(3*(RND(X)))
630 IF I<>0 THEN 650
640 LET I=2
650 LET J=INT(3*(RND(X)))
660 IF J<>0 THEN 680
670 LET J=3
680 LET K=INT(3*(RND(X)))
690 IF K<>0 THEN 710
700 LET K=2
710 LET L=INT(3*(RND(X)))
720 IF L<>0 THEN 740
730 LET L=3
740 LET M=INT(3*(RND(X)))
750 IF M<>0 THEN 770
760 LET M=3
770 LET N=INT(3*(RND(X)))
780 IF N<>0 THEN 800
790 LET N=1
800 LET O=INT (3*(RND(X)))
810 IF O <>0 THEN 830
820 LET O=3
830 PRINT "WANT TO MAKE A WAGER?"
840 INPUT Z
850 IF Z=0 THEN 920
860 PRINT "HOW MUCH ";
870 INPUT Z1
876 IF A1<Z1 THEN 1522
880 LET W=1
890 LET X=1
900 LET Y=1
910 PRINT
920 PRINT "IT'S YOUR MOVE:  ";
930 INPUT P,Q,R
940 IF P>W+1 THEN 1030
950 IF P=W+1 THEN 1000
960 IF Q>X+1 THEN 1030
970 IF Q=(X+1) THEN 1010
980 IF R >(Y+1)  THEN 1030
990 GOTO 1050
1000 IF Q>= X+1 THEN 1030
1010 IF R>=Y+1 THEN 1030
1020 GOTO 1050
1030 PRINTTongueRINT "ILLEGAL MOVE. YOU LOSE."
1040 GOTO 1440
1050 LET W=P
1060 LET X=Q
1070 LET Y=R
1080 IF P=3 THEN 1100
1090 GOTO 1130
1100 IF  Q=3 THEN 1120
1110 GOTO 1130
1120 IF R=3 THEN 1530
1130 IF P=A THEN 1150
1140 GOTO 1180
1150 IF Q=B THEN 1170
1160 GOTO 1180
1170 IF R=C THEN 1400
1180 IF P=D THEN 1200
1190 GOTO 1230
1200 IF Q=E THEN 1220
1210 GOTO 1230
1220 IF  R=F THEN 1400
1230 IF P=G THEN 1250
1240 GOTO 1280
1250 IF Q=H THEN 1270
1260 GOTO 1280
1270 IF R=I THEN 1400
1280 IF P=J THEN 1300
1290 GOTO 1330
1300 IF Q=K THEN 1320
1310 GOTO 1330
1320 IF R=L THEN 1440
1330 IF P=M THEN 1350
1340 GOTO 1380
1350 IF Q=N THEN 1370
1360 GOTO 1380
1370 IF R=O THEN 1400
1380 PRINT "NEXT MOVE: ";
1390 GOTO 930
1400 PRINT"******BANG******"
1410 PRINT "YOU LOSE!"
1420 PRINT
1430 PRINT
1440 IF  Z=0 THEN 1580
1450 PRINT
1460 LET Z2=A1-Z1
1470 IF Z2>0 THEN 1500
1480 PRINT "YOU BUST."
1490 GOTO 1610
1500 PRINT " YOU NOW HAVE"; Z2; "DOLLARS."
1510 LET A1=Z2
1520 GOTO 1580
1522 PRINT"TRIED TO FOOL ME; BET AGAIN";
1525 GOTO 870
1530 PRINT"CONGRATULATIONS!"
1540 IF Z=0 THEN 1580
1550 LET Z2=A1+Z1
1560 PRINT "YOU NOW HAVE"; Z2;"DOLLARS."
1570 LET A1=Z2
1580 PRINT"DO YOU WANT TO TRY AGAIN ";
1590 INPUT S
1600 IF S=1 THEN 380
1610 PRINT "TOUGH LUCK!"
1620 PRINT
1630 PRINT "GOODBYE."
1640 END
Reply
#6
Line 1000 probably makes a world of difference

If Q >= X + 1

Vs

If Q > -X + 1

.....  I'd imagine it's always bigger than a negative X!
Reply
#7
Some of this old style code is just brain damaging.  Examples of poor coding back in the day:

380 LET A=INT(3*(RND(X)))
390 IF A<>0 THEN 410
400 LET A=3

Let's fix that in one line:

LET A = INT(3 * (RND(X))) + 1

Or even change line 390 to:

IF A = 0 THEN LET A = 3
Reply
#8
Here's a version cleaned up and modernized fairly decently:

Code: (Select All)

Print Tab(34); "CUBE"
Print Tab(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
Print: Print: Print
Print "DO YOU WANT TO SEE THE INSTRUCTIONS? (Y)es or (N)o."
Do
    instructions$ = UCase$(Input$(1))
Loop Until instructions$ = "Y" Or instructions$ = "N"
If instructions$ = "Y" Then
    Print "THIS IS A GAME IN WHICH YOU WILL BE PLAYING AGAINST THE"
    Print "RANDOM DECISION OF THE COMPUTER. THE FIELD OF PLAY IS A"
    Print "CUBE OF SIDE 3. ANY OF THE 27 LOCATIONS CAN BE DESIGNATED"
    Print "BY INPUTING THREE NUMBERS SUCH AS 2,3,1. AT THE START,"
    Print "YOU ARE AUTOMATICALLY AT LOCATION 1,1,1. THE OBJECT OF"
    Print "THE GAME IS TO GET TO LOCATION 3,3,3. ONE MINOR DETAIL:"
    Print "THE COMPUTER WILL PICK, AT RANDOM, 5 LOCATIONS AT WHICH"
    Print "IT WILL PLANT LAND MINES. IF YOU HIT ONE OF THESE LOCATIONS"
    Print "YOU LOSE. ONE OTHER DETAIL: YOU MAY MOVE ONLY ONE SPACE "
    Print "IN ONE DIRECTION EACH MOVE. FOR  EXAMPLE: FROM 1,1,2 YOU"
    Print "MAY MOVE TO 2,1,2 OR 1,1,3. YOU MAY NOT CHANGE"
    Print "TWO OF THE NUMBERS ON THE SAME MOVE. IF YOU MAKE AN ILLEGAL"
    Print "MOVE, YOU LOSE AND THE COMPUTER TAKES THE MONEY YOU MAY"
    Print "HAVE BET ON THAT ROUND."
    Print
    Print
    Print "ALL YES OR NO QUESTIONS WILL BE ANSWERED BY A 1 FOR YES"
    Print "OR A 0 (ZERO) FOR NO."
    Print
    Print "WHEN STATING THE AMOUNT OF A WAGER, PRINT ONLY THE NUMBER"
    Print "OF DOLLARS (EXAMPLE: 250)  YOU ARE AUTOMATICALLY STARTED WITH"
    Print "500 DOLLARS IN YOUR ACCOUNT."
    Print
    Print "GOOD LUCK!"
End If
Money = 500
start_game:
A = Int(3 * (Rnd(X))) + 1 '1, 2, 3
B = Int(3 * (Rnd(X))): If B = 0 Then B = 2
C = Int(3 * (Rnd(X))) + 1 '1, 2, 3
D = Int(3 * (Rnd(X))): If D = 0 Then D = 1
E = Int(3 * (Rnd(X))) + 1 '1, 2, 3
F = Int(3 * (Rnd(X))) + 1
G = Int(3 * (Rnd(X))) + 1
H = Int(3 * (Rnd(X))) + 1
i = Int(3 * (Rnd(X))): If i = 0 Then i = 2
J = Int(3 * (Rnd(X))) + 1
K = Int(3 * (Rnd(X))): If K = 0 Then K = 2
L = Int(3 * (Rnd(X))) + 1
M = Int(3 * (Rnd(X))) + 1
N = Int(3 * (Rnd(X))): If N = 0 Then N = 1
O = Int(3 * (Rnd(X))) + 1
Print "WANT TO MAKE A WAGER?"
Input Z
If Z <> 0 Then
    Do
        Print "HOW MUCH ";
        Input Bet
        If Money < Bet Then Print "TRIED TO FOOL ME; BET AGAIN!"
    Loop Until Money >= Bet
    Let W = 1
    Let X = 1
    Let Y = 1
    Print
End If

Print "IT'S YOUR MOVE:  ";
your_move:
Input P, Q, R
lose = 0
If P > W + 1 Then lose = -1
If P = W + 1 And Q >= X + 1 Then lose = -1
If Q > X + 1 Then lose = -1
If Q = (X + 1) And R >= Y + 1 Then lose = -1
If R > (Y + 1) Then lose = -1
If lose Then Print "ILLEGAL MOVE. YOU LOSE.": GoTo you_lose
W = P
X = Q
Y = R
If P = 3 And Q = 3 And R = 3 Then
    Print "CONGRATULATIONS!"
    If Z <> 0 Then
        Money = Money + Bet
        Print "YOU NOW HAVE"; Money; "DOLLARS."
    End If
Else
    If P = A And Q = B And R = C GoTo you_lose
    If P = D And Q = E And R = F GoTo you_lose
    If P = G And Q = H And R = i GoTo you_lose
    If P = J And Q = K And R = L GoTo you_lose
    If P = M And Q = N And R = O GoTo you_lose
    Print "NEXT MOVE: ";
    GoTo your_move
    you_lose:
    Print "******BANG******"
    Print "YOU LOSE!"
    Print
    Print
    If Z <> 0 Then
        Print
        Money = Money - Bet
        If Money = 0 Then
            Print "YOU BUST."
            GoTo quit
        End If
        Print " YOU NOW HAVE"; Money; "DOLLARS."
    End If
End If
Print "DO YOU WANT TO TRY AGAIN ";
Input S
If S = 1 Then GoTo start_game
quit:
Print "TOUGH LUCK!"
Print
Print "GOODBYE."
End
Reply
#9
(10-17-2023, 02:28 AM)SMcNeill Wrote: Here's a version cleaned up and modernized fairly decently:
....

MUCH more manageable... and readable!

Programs like that original version are why Basic has such a bad rep.  There is some serious leapfrogging going on there.
Reply
#10
It's still got some jumps in it, but I tried to give those distinctive labels for readability.  Smile
Reply




Users browsing this thread: 4 Guest(s)