I have some friends who play RISK regularly enough that they decided to write a C# program that speeds up the game for dice rolling. Just enter the number attacking and the number defending, and the laptop tells you who won. Great idea! So, I thought it would be great to write the same kind of app for a TI-84. That way, the calculator can be passed around to each player, and they can manage the dice.

I wrote this on the TI-84 Plus Silver edition, but it should work on the TI 83. I copied the code over to my computer through the USB link. I spent a few hours writing it, and I didn’t want my son to delete it as he is programming the same device — so I backed it up to my computer and I thought that other people may derive some pleasure from it. So here is the binary version. And following is the text version:

:

:ClrHome

:1→Z

:0→I

:0→G

:0→W

:

:Lbl D

:”SHOW DICE:OFF”→Str1

:I+1→I

:If I>2:1→I

:If I=1:”SHOW DICE:ON”→Str1

:If G>1:Goto M

:

:Lbl P

:”PROMPTING:ON”→Str2

:1+Z→Z

:If Z>2:1→Z

:If Z=2:”PROMPTING:OFF”→Str2

:

:

:Lbl M

:2→G

:Menu(“RISK DICE”,Str2,P,Str1,D,”INSTRUCTIONS”,I,”RUN PROGRAM”,T)

:Lbl I

:

:Disp ” RISK DICE”

:Disp “SPECIFY:THE”

:Disp “NUMBER OF”

:Disp “ARMIES FOR THE”

:Disp “ATTACKING AND”

:Disp “DEFENDING SIDES”

:Disp “AND LET ME DO”

:Disp “THE ROLLING”

:Pause

:ClrHome

:Goto M

:

:Lbl T

:ClrHome

:Z→Y

:Input “ATTACKING? “,A

:Input “DEFENDING? “,D

:int(A)→A

:int(D)→D

:0→W

:

:Lbl L

:If I=1 and W≠0:Pause

:1→W

:ClrHome

:

:Disp “”

:Disp “”

:Disp “”

:Disp “”

:Disp “”

:

:Output(1,1,”ATTACKERS: “)

:Output(1,12,A)

:Output(2,1,”DEFENDERS: “)

:Output(2,12,D)

:

:If A≤1:Goto E

:If D≤0:Goto E

:If Y=2:Goto A

:

:Output(3,1,”0=STOP BATTLE”)

:Output(4,1,”1=ROLL AGAIN”)

:Output(5,1,”2=FIGHT TO END”)

:

:Input “0,1 OR 2? “,Y

:Output(3,1,” “)

:Output(4,1,” “)

:Output(5,1,” “)

:Output(6,1,” “)

:If Y=0:Goto E

:

:Lbl A

:

:

:min(A-1,3)→K

:min(D,2)→H

:min(K,H)→R

:

/* let me interrupt this program to say that I am using the LIST feature */

/* The next line is a list of three random numbers — the ATtackers dice */

/* If the attacked is only allowed to use one or two dice, I will get those */

/* through a call to dim() below which will re-dimension the list and make */

/* it shorter — and cut off unused dice. Bu putting the dice in a list, I */

/* also get the free sort utilities of the Ti-83/Ti-84 which match highest */

/* dice for me */

:{randInt(1,6),randInt(1,6),randInt(1,6)}→AT

:

:{randInt(1,6),randInt(1,6)}→DF

:

:K→dim(∟AT)

:H→dim(∟DF)

:

:SortD ∟AT)

:SortD ∟DF)

:

:If I≠1:Goto NX

:Output(3,3,”ATT VS. DEF”)

:Output(4,5,∟AT(1))

:Output(4,13,∟DF(1))

:If K>1:Output(5,5,∟AT(2))

:If H>1:Output(5,13,∟DF(2))

:If K>2:Output(6,5,∟AT(3))

:

:Output(8,1,”PRESS ENTER”)

:

:

:Lbl NX

:If ∟AT(1)>∟DF(1):Then

:¦ If I=1:Output(4,8,”<-")

:¦ D-1→D

:¦ Else

:¦ If I=1:Output(4,8,"->“)

:¦ A-1→A

:End

:If R=1:Goto L

:

:If ∟AT(2)>∟DF(2):Then

:¦ If I=1:Output(5,8,”<-")

:¦ D-1→D

:¦ Else

:¦ If I=1:Output(5,8,"->“)

:¦ A-1→A

:End

:

:Goto L

:

:Lbl E

:

:Output(7,1,”BATTLE OVER”)

:Output(8,1,”PRESS ENTER”)

:

:Pause

:Goto T

:

I got this text version by passing the binary RISK.8xp to a site that converts it to text.

If you do a lot with the TI-83 or TI-84, I suggest you download the TI-84 SDK.

Of course, you need the TI drivers and connectivity tools as well.

Steve Rives