Hello
As a greeting, I show what I found during the cleaning up of junk.
I wrote it a damn long time ago and it was a great help when playing Risk board game as a simulator of a battle involving large numbers of units.
If the Risk players are still alive, I can certify that my HP48G with code below was a great help in the games
Code:
%%HP: T(3)A(D)F(.);
@ (HP48G) DICE THROW SIMULATOR
@
@ N - NUMBER OF DICE TO CAST
@
\<< \-> N
\<< 1 N
FOR I RAND \-> X
\<<
15 .1 BEEP
'1*(6*X<1)
+2*((6*X\>=1)*(6*X<2))
+3*((6*X\>=2)*(6*X<3))
+4*((6*X\>=3)*(6*X<4))
+5*((6*X\>=4)*(6*X<5))
+6*(6*X\>=5)'
\->NUM
\>>
NEXT
N
\>>
\->LIST
\>>
Code:
%%HP: T(3)A(D)F(.);
@ RISK - BOARD GAME - BATTLE SIMULATOR
@
@ REQUIRE DICE (DICE THROW SIMULATOR)
@
@ INPUTS FROM STACK
@ A - NUMBER OF AGGRESSOR'S UNITS
@ D - NUMBER OF DEFENDER'S UNITS
@ S - STOP LOSS (0 NOT SET - DO OR DIE)
@ T - (TARGET) DEFENDER UNITS TO KILL (0 NOT SET - ALL)
@
@ COURSE OF THE BATTLE SAVED INTO HIST VARIABLE
\<< \-> A D S T
\<< A D 2 \->LIST
'HIST' STO
S 0 \<=
\<< 999 'S' STO \>>
IFT T 0 \<=
\<< 999 'T' STO \>>
IFT
WHILE
'(A>1)*(D>0)*(S>0)*(T>0)'
REPEAT
'((A-1)*(A\<=3)+3*(A>3))*(T>1)+1*(T\<=1)' \->NUM
DICE SORT REVLIST
'D*(D\<=2)+2*(D>2)' \->NUM
DICE SORT REVLIST
\-> DA DF
\<<
1
DA SIZE DF SIZE MIN
FOR C
DF C GET
DA C GET
\>=
\<< 'A' DECR 'S' DECR\>>
\<< 'D' DECR 'T' DECR\>>
IFTE
NEXT
'HIST'RCL
DA DF A D 4 \->LIST
+ 'HIST' STO
DA DF 2 \->LIST
3 DISP
A D 2 \->LIST
4 DISP
0.1 WAIT
\>>
END
"AGGRESSORS: " A
"
DEFENDERS: " D
+ + +
MSGBOX
CLEAR
A D
\>>
\>>