Edit: I may add other campaigns later, but 1960 is the only one for now.

]]>Disp B

instead of all those

if B=1

Disp "1

?

This looks like it will just kill time and memory, unless some part of the program demands that this is that specific way

]]>Here is a conversion into TI-83+ code.

=

` ``rand(B+1→L₂ seq(X,X,A,B→L₁ SortA(L₂,L₁ DelVar L₂`

So Question 1 is

But I dont get why If not(Ans is the same as If Ans=1?

Maybe I am just a bit stupid. Can you explain this, because I think that If not(Ans is true when Ans is 0 and If Ans=1 is true when Ans is 1 ]]>

There is SO much wrong with that…

- I know that
`seq(B,B,0,14→L6`does not do the right list, but I am doing this so we can save two bytes later… - …with
`If not(Ans`instead of`If Ans=1`, and so on with all of the questions. It's called "optimization", look it up! - Your revision with the previous statement is wrong.
`If Ans:Disp "1`will display 1 regardless of the question number. - Are you thinking of randInt( needing at least two arguments? Because rand only takes 1 argument, if at all (which creates a random list with elements between 0 and 1). I mean, did you even read the rand article you linked to?

` ``seq(B,B,0,14→L6`

This is not the same as

` ``{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15→L6`

The start is 1 and not 0 and the end is 15

` ``seq(B,B,1,15→L6`

Also this is not correct:

` ``If not(Ans Disp "1 If Ans=1 Disp "2`

It has to be:

` ``If Ans Disp "1 If Ans=2 Disp "2`

This is also not correct:

` ``rand(15->L5`

rand( needs at least 2 arguments.

For the random list, RandIntNoRep( would be a good command ]]>

As far as the `Output(`:

Well, the code *would* be a lot smaller, but at that point it gets kind of confusing to maintain, so I only do that right before a release. Otherwise, I end up spending *forever* trying to tell what I was doing after taking a break.

Also, wouldn't you have to use either 2 vars or a list for that? Though I suppose you could reuse `L5`…

` ``DelVar ADelVar BrandInt(1,15,150→L5 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15→L6 SortA(L5,L6 For(A,1,15 L6(A→B If B=1 Disp "1 If B=2 Disp "2 etc...`

This could be:

` ``DelVar Arand(15->L5 seq(B,B,0,14→L6 DelVar BSortA(L5,L6 For(A,1,15 L6(A If not(Ans Disp "1 If Ans=1 Disp "2 etc...`

Of course, when the questions are finished, all of the If statements could simply be condensed in a single Output( and sub( line. But let's save that for when the questions are actually finished. ]]>

Now, a more in-depth walkthrough:

Each //# refers to the numbered list below the code.

` ``ClrHome DelVar ADelVar BrandInt(1,15,150->L5 //1 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15->L6 //2 SortA(L5,L6 //3 For(A,1,15 //4 L6(A->B //5 If B=1 Disp "1 //6 If B=2 Disp "2 If B=3 Disp "3 If B=4 Disp "4 If B=5 Disp "5 If B=6 Disp "6 If B=7 Disp "7 If B=8 Disp "8 If B=9 Disp "9 If B=10 Disp "10 If B=11 Disp "11 If B=12 Disp "12 If B=13 Disp "13 If B=14 Disp "14 If B=15 Disp "15 End //4`

- This line is a bit confusing, because it's actually three separate lines:
`DelVar A`- This line deletes the data in
`A`, effectively setting it to zero.

- This line deletes the data in
`DelVar B`- This does the same thing as the first part, but for
`B`. - The reason it's on the same line is because of a quirk that
`DelVar`has; it assumes that after the first character, the line has ended, so anything after that is considered a new line. It's explained better here.

- This does the same thing as the first part, but for
`randInt(1,150,15`- Again, I'm exploiting the
`DelVar`quirk to save on space, because newlines take up memory. - The reason that I changed the maximum value of the random number generated is because
- it's actually kind of irrelevant in this case, and
- there is a bug in
`SortA`'s algorithm that makes it slower when two or more values are the same in the first list. See here for more info.

- Again, I'm exploiting the

`L6`contains one of each number, so when we randomize their location, we get a random sequence of 15 unique numbers.`SortA`sorts both lists based off`L5`, effectively randomizing`L6`. As an example:- Let's say we get
`{34,97,132,18,42,55,76,112,110,83,9,14,59,148,72}`when we generate`L5`. - When we run
`SortA(L5,L6`,`Sort A`sorts`L5`from lowest to highest, giving us`{9,14,18,34,42,55,59,72,76,83,97,110,112,132,148}`. - It also sorts
`L6`, but it sorts it so that all the elements still line up:`{11,12,4,1,5,6,13,7,15,10,2,9,8,3,14}` - So now we have a list of fifteen unique numbers representing the order of the questions to be asked.

- Let's say we get
- Next, I used a
`For(`loop to repeatedly go through the series of`If`conditions, because it is faster and less confusing than`Goto`and`Lbl`.- The
`For(`loop increases the value of`A`each time it's run, and it ends when`A=15`, so you don't need to check for that yourself. - It's also smaller and more efficient than using
`Goto`and`Lbl`, so there are performance benefits, too. - And it's easier to understand and maintain, because you know that the end of a loop is always after it starts, whereas a
`Goto`can lead literally anywhere in the code.

- The
- The first thing we do inside the
`For(`loop is get the value of element`A`in`L6`and store it to`B`.- Because
`A`is increased by one each iteration, the loop uses a different value from`L6`each time.

- Because
- Finally, we check to see which question should be asked with a series of
`If`statements.- I removed all the
`Goto`statements you had had, and moved all the questions up into the loop to save on space and processor time.

- I removed all the

I hope this helps.

]]>2. I have NO clue. ]]>

Oh, and I forgot to say that that's prgmZQGEN.

]]>If it's because it generates the same number multiple times, you can use SortA:

` ``//L5 will be a list of random numbers //Increasing the max value may increase speed slightly because of a quirk in SortA's algorithm randInt(1,150,15->L5 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15->L6 //This randomizes L6 while guaranteeing that there is no more than one of each number SortA(L5,L6 ... L6(A->B`

If you use DelVar instead of 0->, you can skip the newline and save 1 byte per variable

` ``//This will save 2 bytes DelVar ADelVar BrandInt(1,15,150->L5`

You can move all those questions up to where the Gotos are now. If they are multi-line questions, you can wrap them with Then or use a comma

Also, you should use a For( loop instead of Goto:

` ``//This is the whole program, optimized as best as I know how ClrHome DelVar ADelVar BrandInt(1,15,150->L5 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15->L6 SortA(L5,L6 For(A,1,15 L6(A->B If B=1 Disp "1 If B=2 Disp "2 If B=3 Disp "3 If B=4 Disp "4 If B=5 Disp "5 If B=6 Disp "6 If B=7 Disp "7 If B=8 Disp "8 If B=9 Disp "9 If B=10 Disp "10 If B=11 Disp "11 If B=12 Disp "12 If B=13 Disp "13 If B=14 Disp "14 If B=15 Disp "15 End`

` ``// INITIALIZATION //K: Used to retrieve keypress //C: Determines selected item //D: Temporary copy of C Output(2,4,"Welcome to Output(3,3,"Election Output(4,1,"---- Output(5,1,"[ Play ] Output(6,3,"How to Play Output(7,6,"Quit 5→C // MAIN LOOP While 1 // MENU LOOP Repeat K=105 getKey→K C→D //Temporary copy of C C-1(K=25)(C>5)+1(K=34)(C<7→C If C≠D Then Output(D,1," " //Remove old brackets Output(D,16," " Output(C,1,"[ Output(C,16,"] End // IDEA: Use numbers for selection If (K≥92)(K≤94 Then C-87→C //92 (1) will return 5, 93 (2) will return 6,... 105→K //Simulate enter press End End // QUIT If C=7 Return // YOU WILL ONLY NEED RETURN // PLAY PART If C=5 Then // CODE FOR PLAY End //You can use Else as part of optimization later //MANUAL PART If C=6 Then //CODE FOR MANUAL End End`

This should work, I didn't test it but this should really fix it.

@spencerc425

Using Lbls and Gotos is a bad habit. You really should try to avoid them as they make a program not only hard to read but also slow it down and thus they should only be used for special purposes.

Output(2,4,"Welcome to

Output(3,3,"Election

Output(4,1,"----

Output(5,6,"Play

Output(6,3,"How to Play

Output(7,6,"Quit

5->C

Output(C,1,"[

Output(C,16,"]

Lbl A

Output(C,1,"

Output(C,2,"

While 1

getKey->K

While K=0

getKey->K

End

If K=25:C-1->C

If K=34:C+1->C

If C=4:7->C

If C=8:5->C

Output(C,1,"[

Output(C,16,"]

If K=105:Goto C

Goto A

Lbl C

If C=5:Goto 1

If C=6:Goto 2

If C=7:Goto 3

By doing this, you get rid of the pesky loop. I know for a fact this works. If it doesnt… I don't know what to do. ]]>

Use this program

While 1

getKey->K

While K=0

getKey->K

End

Disp K

Just run it, and when u press a button, it gives u the keycode. To exit, press on to break the loop. If the keycodes for the up and down are the same as 25 and 34…. Post back on here.

]]>EDIT:

except for the last line

Output(1,1,"Objective:

Output(3,1,"Win the 1960

Output(4,1,"Presidential

Output(5,1,"Election.

Pause

ClrHome

Output(1,1,"How to play:

Output(3,1,"Choose your

Output(4,1,"candidate and

Output(5,1,"Running mate.

Output(6,1,"Then choose a

Output(7,1,"response for

Output(8,1,"each question.

A couple spaces inbetween will take a way a lot of space. Just by using that, you can shorten it a lot.

]]>http://tibasicdev.wikidot.com/custom-menu-single-page ]]>

I definitely recommend high scores. Maybe make it by the most votes won by, then add it to the 1st menu. A way to improve it is to add custom menus. I have a simple one that is basically like the original (with lbls and stuff, but looks a bit better). Heres the code:

Output(2,4,"Welcome to

Output(3,3,"Election

Output(4,1,"---- (16 Hyphens)

Output(5,6,"Play

Output(6,3,"How to Play

Output(7,6,"Quit

5->C

Output(C,1,"[

Output(C,16,"]

Repeat K=105

Output(C,1,"

Output(C,2,"

getKey->K

While K=0

getKey->K

End

If K=25:C-1->C

If K=34:C+1->C

If C=4:7->C

If C=8:5->C

Output(C,1,"[

Output(C,16,"]

End

If C=5:Goto 1 <—- Set labels here

If C=6:Goto 2

If C=7:Goto 3

I can't help much other than that, but it looks good.

Spencerc425

]]>Main Program (prgmELECTION):

ClrHome

prgmANIMXMPL

Lbl Θ

Output(2,4,"Welcome to

Output(3,3,"Election

Output(4,2,"----

Output(5,7,"Play

Output(6,7,"Help

Output(7,7,"Quit

5->C

Output(C,1,"[

Output(C,16,"]

Lbl A

Output(C,1,"

Output(C,2,"

While 1

getKey->K

While 0

getKey->K

End

If K=25:C-1->C

If K=34:C+1->C

If C=4:7->C

If C=8:5->C

Output(C,5,"[

Output(C,12,"]

Output(C+1,5,"

Output(C+1,12,"

If C>5:Output(C-1,5,"

If C>5:Output(C-1,12,"

If C=5:Output(C+2,5,"

If C=5:Output(C+2,12,"

If C=7:Output(C-2,5,"

If C=7:Output(C-2,12,"

If K=105:Goto C

Goto A

Lbl C

If C=5:Goto 1

If C=6:Goto 2

If C=7:Goto 3

Lbl 3

Output(1,1,"()()()()()()()()

Output(8,1,"----

Output(4,5,"GOODBYE!

Pause

Stop

End

Lbl 2

Output(1,1,"Objective:

Output(3,1,"Win the 1960 Presidential Election.

Pause

ClrHome

Output(1,1,"How to play:

Output(3,1,"Choose your candidate and Running mate. Then choose a response for each question.

Pause

ClrHome

Goto Θ

Lbl 1

Unarchive [A]

Output(4,5,"choose a

Output(5,4,"candidate:

Pause

ClrHome

Menu(" Candidates ","Kennedy",D,"Nixon",R)

Lbl D

1->D

([A](21,3)+10)->[A](21,3)

Menu(" Running mate ","L. Johnson",J,"H. Humphrey",H,"A. Gore, Sr.",G)

Lbl J

1->V

Goto 4

Lbl H

2->V

Goto 4

Lbl G

3->V

Goto 4

End

Lbl R

1->R

([A](5,3)-10)->[A](5,3)

Menu(" Running mate ","H. Lodge",L,"N. Rockefeller",N,"G. Ford",F)

ClrHome

Lbl L

1->V

Goto 5

Lbl N

2->V

Goto 5

Lbl F

3->V

Goto 5

End

Lbl 4

If V=1:([A](43,3)+5)->[A](43,3)

If V=2:([A](23,3)+5)->[A](23,3)

If V=3:([A](42,3)+5)->[A](42,3)

Goto 6

Lbl 5

If V=1:([A](21,3)+5)->[A](21,3)

If V=2:([A](32,3)+5)->[A](32,3)

If V=3:([A](22,3)+5)->[A](22,3)

Goto 6

Lbl 6

UnArchive prgmZQGEN

prgmZQGEN

Archive prgmZQGEN

End

This is the main program so far. In it you choose your candidate and running mate. For your choice, you get a bonus in the person's home state (10% for the pres. candidate, 5% for the running mate). It then goes to a subprogram, prgm ZQGEN, where the questions you answer are generated in a random order, then given to you.

This is the opening animation (prgmANIMXMPL):

ClrDraw

AxesOff

Coordff

GridOff

LabelOff

ExprOff

RectGC

ZStandard

Unarchive Pic1

Recall Pic1

For(A,1,21

Text(A,40,"1960

End

Recall Pic1

For(A,1,21

Text(28,A+9," Elec

Text(28,69-A,"Tion

End

Recall Pic1

For(A,50,35,-1

Text(A,40,"Game

Text(A+6,40," "

End

Recall Pic1

Archive Pic1

ClrDraw

This program executes an opening animation, which is the text show. Pic1 is an outline of the continental U.S.

This is the current version of the question order generator (prgmZQGEN):

ClrHome

0->A

0->B

Lbl Θ

A+1->A

If A>10

Goto ΘΘ

If A=1

randIntNoRep(1,10->LQST

Lbl ΘΘ

11->LQST(11)

Currently, there are no questions inserted (I have a friend making up the questions for me, and they will be in strings). There are going to be 11 questions, with the first 10 in random order. The last question will always be the same.

Here is the electoral vote calculator, and matrix reset for when the game ends (prgmZELECTOR):

ClrHome

UnArchive [A]

0->P

0->G

0->A

Output(7,1,"Kennedy:

Output(8,1,"Nixon:

Goto 1

Lbl 1

A+1->A

If A>50

Goto 2

[A](A,3)->B

If B>50

(P+[A](A,2))->P

If B<50

(G+[A](A,2))->G

Goto 1

End

Lbl 2

Pause

UnArchive [B]

(([A]-[A])+[B])->[A]

Archive [A]

Archive [B]

Stop

Currently, this program is just about complete. It may need optimization, but the values are stored for P and G. The main program will display the ending and winning/losing messages.

So, if anyone has any ideas on how to improve the program, e.g. add high scores, achievements, or other stuff, please don't hesitate.

cmac__17