Page 1 of 13

Z-ZEE (Awfully Similar to Yahtzee)

Posted: Mon Jul 25, 2022 4:12 am
by sanello
So, I thought I'd introduce myself to the forum with some of my own sloppy all BASIC code for the Z81. "Z-ZEE" requires the 16k expansion. Call it a beta test...or not. Good day!
z-zee.T81
ZX81. 16k expansion needed
(10.21 KiB) Downloaded 241 times
Edit: So that the currently considered "final" code is at the top of the thread, I will put them inline below as it progresses.

XavSnap Deserves the bulk of credit for making my concept of a program into a playable game.

Note: Keeper choices- now ALL choice 6 means keep all, SWAP choice 9 means swap all (toggle choice), and NONE choice 0 means keep none.
ZZEE_FinalRelease.P
(8.78 KiB) Downloaded 233 times
ZZEE_FinalRelease.zip
(138.67 KiB) Downloaded 247 times
Z-ZEE UDG.zip
(5.06 KiB) Downloaded 327 times

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Mon Jul 25, 2022 2:03 pm
by Moggy
Not really a games player but do like puzzle type programs so once I worked out what I should be doing I found it very addictive so well done sir and welcome to the forum. :D

There is a welcome area at the top of the home page where you can introduce yourself and perhaps tell us something about yourself should you wish, so welcome again please join in with the various topics.

I have attached the game in P file format so those of us with ZXpands can use it as well as those who use emulators other than Eighty One.

Tried this on real ZX81 with the Big Bang X2 BASIC ROM as speeding up BASIC is what the ROM is for and the increase in speed is excellent especially the dice roll routine and the only slow parts are the key detect and the score printing, otherwise most excellent especially when used with the double speed ROM. It also looks quite nice when used in inverse screen mode.

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Mon Jul 25, 2022 8:01 pm
by sanello
I probably should have mentioned that it is way more playable if you crank it up to 8x on an emulator. Wouldn't you know it, though. I found an error on calculating a small straight. The fix is attached here though. I am going to work on making stuff faster. There is plenty of room to streamline things.
z-zee.T81
(10.35 KiB) Downloaded 241 times

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Tue Jul 26, 2022 4:52 am
by XavSnap
Hi,

Shold be optimised;

Code: Select all

  1070 LET A$=INKEY$
  1080 IF A$=CHR$ 118 THEN GOTO 1200
  1090 IF A$="1" AND K(1)=0 THEN LET K(1)=1
  1110 IF A$="2" AND K(2)=0 THEN LET K(2)=1
  1130 IF A$="3" AND K(3)=0 THEN LET K(3)=1
  1150 IF A$="4" AND K(4)=0 THEN LET K(4)=1
  1170 IF A$="5" AND K(5)=0 THEN LET K(5)=1
  1190 GOSUB 8000
equal

Code: Select all

  1070 LET A$=INKEY$
  1080 IF A$=CHR$ 118 THEN GOTO 1200
  1090 LET A=CODE A$-28
  1100 IF VAL A$=A THEN LET K(A)=NOT K(A)
  1190 GOSUB 8000
and

Code: Select all

 
  5000 IF N=1 THEN LET P=1
  5010 IF N=2 THEN LET P=7
  5020 IF N=3 THEN LET P=13
  5030 IF N=4 THEN LET P=19
  5040 IF N=5 THEN LET P=25
  5050 RETURN
equal

Code: Select all

5000 LET P=1+(N-1)*6
5050 RETURN

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Tue Jul 26, 2022 7:13 am
by XavSnap
Or save memory...

Code: Select all

1314 LET P1=6
  1316 LET P2=9
  1320 IF INKEY$="" THEN GOTO 1320
  1330 LET A$=INKEY$
  1340 IF A$="5" OR A$="6" OR A$="7" OR A$="8" OR A$=CHR$ 118 THEN GOTO 1347
  1345 GOTO 1320
  1347 IF A$=CHR$ 118 THEN GOTO 1460
  1349 LET A=VAL A$
  1350 IF A=7 AND P1=6 THEN GOTO 1320
  1370 IF A=6 AND P1=12 THEN GOTO 1320
  1385 IF A=5 AND P2=9 THEN GOTO 1320
  1390 IF A=8 AND P2=28 THEN GOTO 1320
  1395 LET A=VAL A$
  1400 IF A=7 THEN LET P1=P1-1
  1410 IF A=6 THEN LET P1=P1+1
  1412 IF A=5 THEN LET P2=9
  1414 IF A=8 THEN LET P2=28
  1420 PRINT AT P1,P2;"Š"
  1430 IF A=6 THEN PRINT AT P1-1,P2;":"
  1440 IF A=7 THEN PRINT AT P1+1,P2;":"
  1442 IF A=5 AND P2=9 THEN PRINT AT P1,28;":"
  1444 IF A=5 AND P2=28 THEN PRINT AT P1,9;":"
  1446 IF A=8 AND P2=9 THEN PRINT AT P1,28;":"
  1448 IF A=8 AND P2=28 THEN PRINT AT P1,9;":"
  1450 GOTO 1320
  1460 LET Q=0
equal

Code: Select all

  1314 LET P1=0
  1316 LET P2=0
  1320 IF INKEY$="" THEN GOTO 1320
  1330 LET A$=INKEY$
  1340 IF (A$>"4" AND A$<"9") THEN GOTO 1349
  1342 IF A$=CHR$ 118 THEN GOTO 1450
  1345 GOTO 1320
  1349 LET A=VAL A$
  1350 PRINT AT 6+P1,9+(19 AND P2);":"
  1360 LET P1=P1-(1*(A$="7") AND P1>0)+(1*(A$="6") AND P1<6)
  1370 LET P2=P2-(1*(A$="5") AND P2>0)+(1*(A$="8") AND P2<1)
  1380 PRINT AT 6+P1,9+(19 AND P2);"Š"
  1390 GOTO 1320
   1450 LET P1=P1+6
  1455 LET P2=9+(19 AND P2)
  1460 LET Q=0
Optimized codes: [edit] updated.

Have fun.

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Tue Jul 26, 2022 2:36 pm
by Moggy
Most excellent work Xavier :ugeek:

Plus points.

1) Dice selection now much faster.
2) The choose all dice key is a nice touch.
3) Dice that are held no longer flash so again it does it faster.
4) With the double speed ROM this is almost like M/C.

Now if you could only speed up the score routine it would be perfect. :lol:


An excellent version of Yahtzee by Sanello and great improvement by XavSnap well done both of you.

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Tue Jul 26, 2022 9:20 pm
by Moggy
Adding RAND for a better random first throw as every time I first start the game certain sequences came up if I decided to let the dice roll for a second spin without holding any. 16655 being quit common on the second throw if non held first time around, shuffling the lines 989/ 990 up 1 then adding RAND stops this.

Code: Select all

989  RAND
990  FOR G = 1 TO 3
991 FOR J = 1 TO 3        ETC

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Tue Jul 26, 2022 11:12 pm
by XavSnap
RAND added...
SUM added.

[edit] updated in next messages.

PS: a loop FOR-NEXT isn't need to erase D(), just add a DIM D(5) to reset the array. (Memory saved!)
S value (score type ID) don't get cursor position to select a score type.

It's a good game, but the BASIC is too exotic for a Zx81...
But it's cool.
:geek:

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Wed Jul 27, 2022 6:20 am
by sanello
Wow XavSnap, I didn't expect anyone to delve in to that degree. Nice! I made some changes like making use of the fast mode for scoring and drawing the selection. I also changed some of the math choices. I didn't think about using CODE at all, so learned something there for sure. I am embarrassed that I didn't think of 5000 LET P=1+(N-1)*6 though. I'll put what I did here for now, but I will definitely incorporate your suggestions. I wrote this all as I went. I should think about putting some of it on paper first or something. I get too many weird GOSUBs in weird places and stuff.

Moggy, the flashing dice were a choice. Perhaps a bad one. Too exotic was a good choice of words. My new code just rolls the unchosen dice, though. I intended to add that RAND command at some point too.
z-zee.T81
(10.46 KiB) Downloaded 191 times

Re: Z-ZEE (Awfully Similar to Yahtzee)

Posted: Wed Jul 27, 2022 3:21 pm
by Moggy
@XavSnap

I think there is a bug in your latest code Xavier as when I get three of a kind and press for three of a kind the figure 0 appears next to four of a kind and on further testing other scores aren't working correctly too (chance being just one other).
Also different numbers keep being printed at the top left of screen :?


@sanello

The fast mode for the scoring is ok but not needed for choosing which dice to be held as that routine is very smooth and fast enough already using XavSnaps version and is a bit annoying to be honest with the screen flicker involved.