• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# TI-83 Daleks Code

tikevin83 Apr 30th, 2019 (edited) 190 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. AxesOff
2. 84→Xmin
3. 72→Ymax
4. ZInteger                //golfed initialization of the graph screen to square coordinates
5. 1→C                       //starting Dalek count
6. Repeat C>9              //Levels 1-9 will run with 2-10 Daleks
7. binomcdf(C,0→L₃             //Fill a C+1 long list of 1s for whether each Dalek is alive.  On OS 1.02, binomcdf appears to work differently and 0 needs to be 1.
8. C+1→C                 //Increment the number of Daleks each level, placing it here to avoid C-1 in the previous function
9. 1+3int(31rand(Ans→L₁        //coordinate placement for Dalek enemies.  rand(c sets a list of C random numbers, then the list is transformed into 3 pixel wide coordinates for the graph screen
10. 1+3int(21rand(C→L₂
11. Repeat not(sum(X=L₁ and Ans=L₂      //place the doctor on the grid using A and B for X and Y coordinates, and make sure he doesn't start on a Dalek
12. 1+3int(31rand→X
13. 1+3int(21rand→B
14. End
15. 1→S                       //S is 1 until the Sonic Screwdriver is used
16. While sum(L₃          //repeat the loop within the level while some Daleks are still alive
17. Pt-On(X,B,3             //draw the doctor's sprite
18. For(D,1,C
19. Pt-On(L₁(D),L₂(D),2     //draw the dalek sprites
20. End
21. Repeat Ans              //look for a keypress until one has happened.  Repeat loops go once before checking conditions, so Ans always has a chance to become the value of getKey
22. rand                    //spurious rand call to aid RNG manip in TAS
23. getKey→G              //store the last key code to G
24. End
25. Pt-Off(X,B,3            //delete the doctor's current sprite using pt mode 3 to draw a +
26. If S(Ans=81             //Use the sonic screwdriver if it hasn't been used yet and the Ln key was pressed (above store)
27. DelVar SL₃not(4>abs(L₁-X) and 4>abs(L₂-B→L₃       //Note the use of the screwdriver and kill Daleks that are directly adjacent to the doctor.  DeMorgan's laws can flip how this is done, haven't tested which way is faster yet, not( allows for implicit multiplication
28. If G=91                 //if the store key is pressed, use the Tardis (moves somewhere on the grid randomly, including dangerous places)
29. Then
30. 1+3int(31rand→X
31. 1+3int(21rand→B
32. End
33. min(91,max(1,X+3(max(G={74,84,94})-max(G={72,82,92→X  //golfed movement code for the Doctor using the numpad
34. min(61,max(1,B+3(max(G={72,73,74})-max(G={92,93,94→B
35. For(D,1,C)              //loop through the Daleks to clear their current sprites
36. If L₃(D                   //If the dalek is alive
37. Pt-Off(L₁(D),L₂(D),2    //Clear the current sprite using pt-off mode 2 to delete a square
38. End
39. L₁+L₃3((L₁<X)-(L₁>X→L₁      //Move all daleks toward the doctor.  This code can be 10 bytes shorter using a trick with tanh(E9X to pull the sign of X, but it runs slower.
40. L₂+L₃3((L₂<B)-(L₂>B→L₂
41. If sum(X=L₁ and B=Ans     //if the character's coordinates are equal to both of any of the Dalek's locations
42. Then
43. Text(28,32,"YOU DIED    //Stop the game and tell the player they died
44. Stop
45. End
46. For(D,1,C)              //We have to do 2 separate loops so that all daleks move before locations are checked for dalek collision
47. L₃(D)=sum(L₁=L₁(D) and L₂=L₂(D→L₃(D           //Mark daleks as dead if there are multiple in the same place, keeping them dead if they already are
48. If not(Ans              //If the current dalek is dead
49. Pt-On(L₁(D),L₂(D        //Mark its death by filling in the dalek's sprite
50. End
51. End
52. V+C→V                 //update the score for winning the round
53. ClrDraw
54. Text(28,40,"SCORE:",Ans //Draw the score between rounds
55. Pause
56. ClrDraw
57. End
58. Text(28,32,"YOU WON
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top