### Author Topic: Shutdown (a clone of Lights Out Deluxe)  (Read 2310 times)

0 Members and 1 Guest are viewing this topic.

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Shutdown (a clone of Lights Out Deluxe)
« on: November 11, 2013, 12:35:52 pm »
This is a less-than-a-kilobyte clone of Lights Out.
CONTROLS
First, you will go to the main menu. Press up and down to go between menu options, and Enter to select. Press left and right to switch between modes.
In-game, press the arrow keys to move along the Lights Out grid, and Enter to turn that and all adjacent lights off. You keep going until the lights are all turned off, or you can press CLEAR at any time to quit. Either way, you will be sent back to the main menu.
MODES
The first mode is Normal mode, where all the lights are turned on.
The second mode is Random mode, where it selects a random configuration of lights.
The third mode is custom. It brings you to a screen with the grid you can customize. The controls are the same as in-game, except no special rules for switching lights apply. CLEAR goes to the game with the pattern.
CODE
Code: [Select]
Lbl SClrHome"----Ans+Ans+Ans+AnsDisp "    SHUTDOWN",Ans," PLAY",Ans," MODE:",Ans," EXIT3→X1→YRepeat K=105Output(5,8,sub("NORMALRANDOMCUSTOM",6Y-5,6Output(X,1,">getKey→KIf AnsThenOutput(X,1," X+2(Ans=34 and X≠7)-2(Ans=25 and X≠3→XY+(K=26)-(K=24Ans-3(Ans=4)+3not(Ans→YEndEnd36→dim(L₁If X=7Goto EIf Y=3ThenClrHomeDelVar A1→BDisp "For X,1,6Disp " OOOOOOEndFill(0,L₁Repeat K=45 and sum(L₁Output(A+2,B+1," rand(8Output(A+2,B+1,sub("O*",1+L₁(6A+B),1getKey→KA+(Ans=34 and A≠5)-(Ans=25 and A→AB+(K=26 and B≠6)-(K=24 and B≠1→B6A+AnsIf K=105not(L₁(Ans→L₁(AnsEndEndIf Y=2ThenRepeat sum(Ansint(2rand(36→L₁EndEndIf Y=1Fill(1,L₁ClrHome"         Output(1,10,"! SHUT "+Ans+"! DOWN "+Ans+"+------"+Ans+"!MODE: "+Ans+"!      "+Ans+"+------"+Ans+"LIGHT:"+Ans+"!Output(5,11,sub("NORMALRANDOMCUSTOM",6Y-5,6For(X,0,5For(Y,1,6Output(2+X,1+Y,sub("O*",1+L₁(6X+Y),1EndEndDelVar X1→YRepeat K=45 or not(sum(L₁Output(8,12," Output(8,11,sum(L₁Output(X+2,Y+1," rand(8Output(X+2,Y+1,sub"O*",1+L₁(6X+Y),1getKey→KX-(Ans=25 and X)+(Ans=34 and X≠5→XY-(K=24 and Y≠1)+(K=26 and Y≠6→YIf K=105ThenFor(A,1,56X+Y{(Ans-6)not(not(X)),(Ans-1)(Y≠1),Ans,(Ans+1)(Y≠6),(Ans+6)(X≠5Ans(AIf Ansnot(L₁(Ans→L₁(AnsEndFor(A,X-not(not(X)),X+(X≠5For(B,Y-(Y≠1),Y+(Y≠6Output(A+2,B+1,sub("O*",1+L₁(6A+B),1EndEndEndEndIf K=45Goto SOutput(8,11,0Pause "YOU WIN!Goto SLbl EDelVar L₁DelVar ADelVar BDelVar KDelVar XDelVar YClrHome
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Streetwalrus

• LV12 Extreme Poster (Next: 5000)
• Posts: 3821
• Rating: +80/-8
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #1 on: November 11, 2013, 12:42:09 pm »
* Streetwalker sees a label in BASIC and faints
* Streetwalker runs
Anyway sounds cool.
« Last Edit: November 11, 2013, 12:42:23 pm by Streetwalker »

#### Sorunome

• Fox Fox Fox Fox Fox Fox Fox!
• Support Staff
• LV13 Extreme Addict (Next: 9001)
• Posts: 7920
• Rating: +374/-13
• Derpy Hooves
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #2 on: November 11, 2013, 12:43:56 pm »
You should try working without labels, that'll make your program better, you can like put a long while loop around it with
Code: [Select]
While K=45[...]EndSeeing that you have K=45 as a condition to start again.
Just an idea, though
 THE GAMEAlso, check out my websiteIf OmnomIRC is screwed up, blame me!Click here to give me an internet!

#### harold

• Posts: 226
• Rating: +41/-3
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #3 on: November 11, 2013, 12:45:02 pm »
How do you ensure that the random instances are solvable?
Check the haroldbot thread for the supported commands and syntax.
You can use haroldbot from this website.

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #4 on: November 11, 2013, 12:46:30 pm »
You can like put a long while loop around it with
Code: [Select]
While K=45[...]EndSeeing that you have K=45 as a condition to start again.
Just an idea, though

I don't see how that would work. I know that labels are discouraged in BASIC, but sometimes they are the optimal solution. This may be one of those times.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Sorunome

• Fox Fox Fox Fox Fox Fox Fox!
• Support Staff
• LV13 Extreme Addict (Next: 9001)
• Posts: 7920
• Rating: +374/-13
• Derpy Hooves
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #5 on: November 11, 2013, 12:51:56 pm »
I build my basic progs usually somehow like this:

Variables as following: for a menu, A the position, C the Keypress
Code: [Select]
Repeat A=3 and C=21  //A=3 is then the bottom-most menu item, exit<draw menu>Repeat C=21<menu routineEndIf A=0Then<stuff for first menu point>0->A //put cursor at the top again and prevent exitingEndIf A=1Then<stuff for second menu point>0->A //put cursor at the top again and prevent exitingEndIf A=2Then<stuff for third menu point>0->A //put cursor at the top again and prevent exitingEndEnd
 THE GAMEAlso, check out my websiteIf OmnomIRC is screwed up, blame me!Click here to give me an internet!

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #6 on: November 11, 2013, 12:55:31 pm »
I build my basic progs usually somehow like this:
(blah blah blah code)

Now I see how it works! We just need to optimally substitute it into the program somehow. You can see how the program works, right?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4667
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #7 on: November 11, 2013, 12:56:18 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution

Anyways, to answer harold, there are no unsolvable starting conditions. (Think of it like a scrambled Rubiks cube, or a scrambled knot in a string whose ends are tied together). When I made one, I wasn't sure if there were unsolvable solutions, so I just simulated n steps and presented the board.

EDIT: Oops, it seems there are some unsolvable boards for some sizes.
« Last Edit: November 11, 2013, 12:59:47 pm by Xeda112358 »

#### Sorunome

• Fox Fox Fox Fox Fox Fox Fox!
• Support Staff
• LV13 Extreme Addict (Next: 9001)
• Posts: 7920
• Rating: +374/-13
• Derpy Hooves
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #8 on: November 11, 2013, 12:59:36 pm »
I build my basic progs usually somehow like this:
(blah blah blah code)

Now I see how it works! We just need to optimally substitute it into the program somehow. You can see how the program works, right?
I didn't really look at your code yet but I like that you use Ans a lot
I like labels in BASIC because they can often be an excellent solution and often the best solution
[...]
When's that They also have that memory bug
 THE GAMEAlso, check out my websiteIf OmnomIRC is screwed up, blame me!Click here to give me an internet!

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #9 on: November 11, 2013, 01:00:23 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution

I agree with Xeda. I used labels because I thought it was the best solution.

Anyways, to answer harold, there are no unsolvable starting conditions. (Think of it like a scrambled Rubiks cube, or a scrambled knot in a string whose ends are tied together). When I made one, I wasn't sure if there were unsolvable solutions, so I just simulated n steps and presented the board.

That must have been slow, Xeda.
Harold, I did my research first, and at least for 6 by 6 grids, there are no unsolvable starting conditions. So, int(2rand(36 was sufficient.

So, was the game good?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #10 on: November 11, 2013, 01:02:28 pm »
When's that They also have that memory bug

Note, he said OFTEN, not ALWAYS. That memory bug only happens if you escape out of a loop with a Lbl, and I always try to prevent that.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Streetwalrus

• LV12 Extreme Poster (Next: 5000)
• Posts: 3821
• Rating: +80/-8
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #11 on: November 11, 2013, 01:03:32 pm »
Hmm, try to avoid double posting please. You have an edit and a delete button at the top of your post.

#### JWinslow23

• Coder Of Tomorrow
• LV7 Elite (Next: 700)
• Posts: 556
• Rating: +43/-6
• I make quality calculator games...when I have time
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #12 on: November 11, 2013, 01:04:15 pm »
Hmm, try to avoid double posting please. You have an edit and a delete button at the top of your post.
Sorry. I failed to notice the EDIT button.

EDIT: Maybe because it was labelled MODIFY.
« Last Edit: November 11, 2013, 01:04:34 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
= ?

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4667
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #13 on: November 11, 2013, 01:15:16 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution
[...]
When's that They also have that memory bug
That memory 'bug' isn't a bug, actually, it is just misuse of Goto and Lbl inside While, Repeat, and For loops.

Examples are when you use the Menu() command, the options need to jump to labels, then if you want to jump back to the menu, you either need to use a non-optimal Repeat loop, or the more optimal Goto. For example:
Code: [Select]
Lbl 0Menu("HEADER","ITEM 1",01,"ITEM 2",10,"EXIT",1Lbl 01Pause "HI!Goto 0Lbl 10Pause "HAHAHAHAHAGoto 0Lbl 1
In reality, While loops and Repeat loops use memory (so large nestings of these can consume lots of RAM) whereas Lbl and Goto use no memory. In RPGs, using labels is usually the best option, and for games where you want to use subroutines without using subprograms, you can take advantage of mixing labels and while loops. I made heavy use of this in an RPG a while ago.

To be more technical, the OS needs to push information onto an operator stack whenever it executes a loop. When it reaches an End, it uses that information and it doesn't remove it until the loop is finished. If you had 9 nested while loops, then , it pushes the data for each loop onto this stack, and when it reaches an End, the information is popped off in reverse order. If you use a Goto to jump out of a loop, the data never gets popped off the stack unless you place an unused end somewhere (but then only one item is popped off).

#### Sorunome

• Fox Fox Fox Fox Fox Fox Fox!
• Support Staff
• LV13 Extreme Addict (Next: 9001)
• Posts: 7920
• Rating: +374/-13
• Derpy Hooves
##### Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #14 on: November 11, 2013, 01:24:17 pm »
Oh, now the memory error makes sence to me But isn't it the same then for multi-line if conditions?
Anyways, I prefer using loops.....
 THE GAMEAlso, check out my websiteIf OmnomIRC is screwed up, blame me!Click here to give me an internet!