QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: SMcNeill on September 16, 2018, 04:53:23 pm

Title: 30 Line Game Challenge
Post by: SMcNeill on September 16, 2018, 04:53:23 pm
Code: QB64: [Select]
  1. 1 SCREEN _NEWIMAGE(1280, 720, 32)
  2. 2
  3. 3 FOR j = 0 TO 1
  4.    4 CLS
  5.    5 PRINT "Bite MY Lucky Seven"
  6.    6 PRINT "Most games want you to guess from 1 to 100, but I'm smarter than them."
  7.    7 PRINT "Choose any whole number from 0 to 127, and give me 7 guesses."
  8.    8 PRINT "I bet after that time, I can tell you what the number is."
  9.    9 PRINT CHR$(13); "Choose your number and press any key to begin"
  10.    10 junk$ = INPUT$(1)
  11.    11 guess = 64
  12.    12 CLS
  13.    13 FOR i = 5 TO 0 STEP -1
  14.        14 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i + 1)
  15.        15 PRINT "For Guess #"; (6 - i); ", my guess is"; guess
  16.        16 PRINT CHR$(13); "Am I:  (0) Correct   (1) High   (2) Low"; CHR$(13)
  17.        17 PRINT "PRESS 0, 1, or 2 please for your answer =>";
  18.        18 a = VAL(INPUT$(1))
  19.        19 PRINT a; CHR$(13); CHR$(13)
  20.        20 i = i - ((a - 1) AND 2) / 2 * i 'answer 0, and we win
  21.    21 NEXT
  22.    22 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i +1)
  23.    23 PRINT "Your number is "; guess
  24.    24 PRINT
  25.    25 PRINT "Would you like to:     (1) Try again"
  26.    26 PRINT "                       (2) Run away crying, unable to stop my awesome power"
  27.    27 a = VAL(INPUT$(1))
  28.    28 j = 1 - (1 AND a)
  29. 29 NEXT
  30. 30 END

Digging around one of my old drives, and I found this old gem, which was something I came up with for a 30 line game challenge...

If you look close, you'll be able to see what made this program a real challenge to write:  It has no conditional statements in it, at all!  No IF.  No SELECT CASE.... No WHILE-WEND cheatery...

The challenge was:

30 Lines maximum, without cheating with :
No use of standard conditional operators.
It has to be a playable "game" of some approximation.
And a time limit of some sort which it had to be finished by...

Anyone else want to give it a go?  You have to get creative to follow the rules and make something work, and I'd love to see what other folks come up with to meet the challenge.  It definitely made my brain think out of the box, and out of my usual comfort zone.  ;)
Title: Re: 30 Line Game Challenge
Post by: Pete on September 16, 2018, 04:59:35 pm
Well right off the bat I'm wondering why you just didn't make your print statements one line, as you can add line break characters using the plus sign?

Pete
Title: Re: 30 Line Game Challenge
Post by: SMcNeill on September 16, 2018, 05:11:03 pm
Well right off the bat I'm wondering why you just didn't make your print statements one line, as you can add line break characters using the plus sign?

Pete

Just so I could "pad" the program to 30 lines.   (Same reason for the END statement.). ;)
Title: Re: 30 Line Game Challenge
Post by: Pete on September 16, 2018, 05:16:58 pm
Ah, you were under 30. My mind went to 30 or less, less being better. Most of these types of challenges I got involved in at N54 involved the least amount of code to accomplish something; you know, like make a list of all of the valuable accomplishments made by Democrats. The winner is the one who just leaves the IDE blank... which really upset the guy who coded CLS, and thought he had it in the bag.

Pete
Title: Re: 30 Line Game Challenge
Post by: TempodiBasic on September 16, 2018, 06:16:02 pm
Hi
So Steve , TOSHIBA, but I must do these two questions for a better understanding the challenge rules
1.
 is void line good for this 30 o less Line Game Challenge?
for example your line of code 2

2.
is good the game also if it is not effective ?

3.
Are REM or ' lines  not valid for counting lines of the game?

4.
are tricky '$include:'filename' forbidden?

again TOSHIBA I have made a wrong computation of the number of questions.

Thanks

PS
 it seems clear to me that NO standard conditional operators(>=,<=,==), if-then-else, select case end select, while-wend  and I suppose no do-until
Title: Re: 30 Line Game Challenge
Post by: Pete on September 16, 2018, 07:31:53 pm
OK, I had to add some padding crap at the end like Steve did to get it to 30-lines, and I used variables when I could have cut them out and used VAL() but again, the challenge was 30-lines, not less.

This is a boring little guess higher or lower card game that keeps track of your score. It randomizes a deck of 52 cards and displays them in, you guessed it, SCREEN 0, the only screen mode anyone needs. Anyway, try not to fall asleep while trying it out; however, It might be fun for some to explore, because it really uses the hell out of one of my favorite QB keywords, INSTR.

Pete

Code: QB64: [Select]
  1.     a$ = LTRIM$(STR$(INT(RND * 13 + 2))) + "." + LTRIM$(STR$(INT(RND * 4 + 1)))
  2.     IF INT(VAL(a$)) > 10 THEN b$ = MID$("JQKA", VAL(a$) - 10, 1) + MID$(CHR$(3) + CHR$(4) + CHR$(5) + CHR$(6), VAL(MID$(a$, INSTR(a$, ".") + 1)), 1) ELSE b$ = LTRIM$(STR$(INT(VAL(a$)))) + MID$(CHR$(3) + CHR$(4) + CHR$(5) + CHR$(6), VAL(MID$(a$, INSTR(a$, ".") + 1)), 1)
  3.     IF INSTR(mystring$, b$) = 0 THEN mystring$ = b$ + "=" + MID$(a$, 1, INSTR(a$, ".") - 1) + "|" + mystring$
  4. LOOP WHILE LEN(mystring$) < 284
  5.     msg$ = MID$(mystring$, 1, INSTR(mystring$, "=") - 1) + " "
  6.     x = VAL(MID$(mystring$, INSTR(mystring$, "=") + 1))
  7.     DO
  8.         IF LEN(msg$) < 5 THEN PRINT msg$;
  9.         LINE INPUT "Will the next card be [h]igher or [l]ower? "; hl$
  10.         mystring$ = MID$(mystring$, INSTR(mystring$, "|") + 1)
  11.         y = VAL(MID$(mystring$, INSTR(mystring$, "=") + 1))
  12.         IF UCASE$(hl$) = "H" THEN IF y > x THEN msg$ = "1|correct!" ELSE IF y = x THEN msg$ = "0|It's a push, try again!" ELSE msg$ = "-1|Wrong dirt farmer!!!"
  13.         IF UCASE$(hl$) = "L" THEN IF y < x THEN msg$ = "1|correct!" ELSE IF y = x THEN msg$ = "0|It's a push, try again!" ELSE msg$ = "-1|Wrong dirt farmer!!!"
  14.     LOOP WHILE LEN(msg$) < 5
  15.     score = score + VAL(msg$)
  16.     PRINT " ... "; MID$(msg$, INSTR(msg$, "|") + 1) + " Score = "; LTRIM$(STR$(score)); CHR$(13)
  17.     IF mystring$ = "" THEN EXIT DO
  18. PRINT "Thanks for playing. Your final score is: " + LTRIM$(STR$(score))
  19. PRINT "Press Esc to end or any key to play again!"
  20.     _LIMIT 30
  21.     b$ = INKEY$
  22.     IF LEN(b$) THEN IF b$ = CHR$(27) THEN SYSTEM ELSE EXIT DO
Title: Re: 30 Line Game Challenge
Post by: OldMoses on September 16, 2018, 07:45:55 pm
Well beyond my skills (I only write multi-thousand line train wrecks), but I found a bit of a bug in "Bite My Lucky Seven". When I choose the number 1 it came up with 1.5, twice. Still, that is pretty innovative coding.

I put an INT around the argument in line 22 and it seemed to work.

P.S. I shouldn't muck about with things I know nothing about. The INT fragged it for catching higher numbers. Fascinating work.
Title: Re: 30 Line Game Challenge
Post by: SMcNeill on September 16, 2018, 07:50:01 pm
BZZZZZZT!! 

Pete's been hanging around with the democrats in his state so long, he's forgotten to follow the main challenge of the rules:   No use of IF, SELECT CASE, and other common conditional keywords. 

You're fired!  :P

************************

Quote
Hi
So Steve , TOSHIBA, but I must do these two questions for a better understanding the challenge rules
1.
 is void line good for this 30 o less Line Game Challenge?
for example your line of code 2

2.
is good the game also if it is not effective ?

3.
Are REM or ' lines  not valid for counting lines of the game?

4.
are tricky '$include:'filename' forbidden?


Users are limited to 30 lines, so a blank line is perfectly fine.  Count it -- don't count it -- you'd still come in under that 30 line limit.  Same way with a line of solid comment with REM or '.  Just don't use OVER 30 lines -- and use of $INCLUDE would be a violation of the rules just as a colon would be. 

X = 2: Y = 3 <-- this would count as 2 lines, so why wouldn't $INCLUDE:'XYset.bas'??

As for it being "effective", that's entirely subjective.  The main challenge was to write a program/game WITHOUT using IF, SELECT, and such, which requires some outside the box thinking.   ;)
Title: Re: 30 Line Game Challenge
Post by: SMcNeill on September 16, 2018, 07:56:10 pm
Well beyond my skills (I only write multi-thousand line train wrecks), but I found a bit of a bug in "Bite My Lucky Seven". When I choose the number 1 it came up with 1.5, twice. Still, that is pretty innovative coding.

I put an INT around the argument in line 22 and it seemed to work.

Now how the BEEP did it do that??  It should move along in powers of 2...   64, 32, 16, 8, 4, 2, 1...

I'm gonna have to dig around and see if it's my math that's wrong, or just some quirk of single precision routines that's off, or what the heck is happening.  All answers should be integer values, which change by the power of 2.
Title: Re: 30 Line Game Challenge
Post by: OldMoses on September 16, 2018, 08:06:59 pm
Now how the BEEP did it do that??  It should move along in powers of 2...   64, 32, 16, 8, 4, 2, 1...

I'm gonna have to dig around and see if it's my math that's wrong, or just some quirk of single precision routines that's off, or what the heck is happening.  All answers should be integer values, which change by the power of 2.

It was doing that until I tried to fix it. It really didn't like that. I should have known it wouldn't be that easy...
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 16, 2018, 08:37:00 pm
Yeah. I chose 21, it proudly declared my answer was 21.5! I played around 10 times and it got it right on the nose 8 out of the 10, and was 0.5 off the other 2. Not bad. 4 in 5 is better than I could have done! Lol
Title: Re: 30 Line Game Challenge
Post by: Pete on September 16, 2018, 08:42:20 pm
Oh, you assumed I read the instructions. I didn't, just the 30-lines and make a game. It's a 30-line game. :D

Writing a program without conditional statements would be like having sex without a partner.

Oh well, it was so much fun, I'll just post it as a new challenge. In other words, take matters into my own hand. Oh wait, why do I suddenly feel guilty of hypocrisy?

Pete
Title: Re: 30 Line Game Challenge
Post by: SMcNeill on September 16, 2018, 08:57:20 pm
Yeah. I chose 21, it proudly declared my answer was 21.5! I played around 10 times and it got it right on the nose 8 out of the 10, and was 0.5 off the other 2. Not bad. 4 in 5 is better than I could have done! Lol

And somehow, this just totally astounds me...

guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i + 1)

guess starts at 64.   a starts at 0.  i starts at 5....   

First guess:  64 + (2 AND 0... which is 0) - (1 AND 0... Which is 0).... Gives 64 in the end.

Second guess: guess starts at 64.  a would be 1 (guessed high).  i is now 4.

64 +  0 - 1 * 2 ^ 5....   64-32 = 32

Third guess: 32 + 0 - 1 * 2 ^ 4 = 16

Fourth guess: 8
Fifth guess: 4
Sixth guess: 2
Seventh guess: 1

2 + 0 - 1 * 2 ^ (-1 + 1) = 1

How can the math generate half digit values??  I'm completely baffled by the reports you guys are giving.   

We start with 64, then +/- 32, then +/- 16...  8.. 4... 2.... 1...   How do we EVER get a half point in there??

Title: Re: 30 Line Game Challenge
Post by: Pete on September 16, 2018, 09:27:21 pm
I made a simple addition program to add up some rental improvement tax crap a couple of weeks ago, and ran into the same problem. Now for my office software, I made a function to fix these screwy mistakes computers make, apparently because they count in binary instead of base 10. So I'm not sure if this is what your guessing game is encountering, but I am saying you can't trust binary counting systems to do simple math without applying correctional methods to ensure the proper outcome.

Pete

Title: Re: 30 Line Game Challenge
Post by: bplus on September 17, 2018, 07:29:16 am
Yeah. I chose 21, it proudly declared my answer was 21.5! I played around 10 times and it got it right on the nose 8 out of the 10, and was 0.5 off the other 2. Not bad. 4 in 5 is better than I could have done! Lol

And somehow, this just totally astounds me...

guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i + 1)

guess starts at 64.   a starts at 0.  i starts at 5....   

First guess:  64 + (2 AND 0... which is 0) - (1 AND 0... Which is 0).... Gives 64 in the end.

Second guess: guess starts at 64.  a would be 1 (guessed high).  i is now 4.

64 +  0 - 1 * 2 ^ 5....   64-32 = 32

Third guess: 32 + 0 - 1 * 2 ^ 4 = 16

Fourth guess: 8
Fifth guess: 4
Sixth guess: 2
Seventh guess: 1

2 + 0 - 1 * 2 ^ (-1 + 1) = 1

How can the math generate half digit values??  I'm completely baffled by the reports you guys are giving.   

We start with 64, then +/- 32, then +/- 16...  8.. 4... 2.... 1...   How do we EVER get a half point in there??

Did you try 21?
Title: Re: 30 Line Game Challenge
Post by: bplus on September 17, 2018, 07:47:53 am
    PRINT "i="; i
    22 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i)

for 21, i = -1 and 2 ^ -1 = .5

typo on line 22 to match line 14
 22 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i +1)  '  i + 1 fixes
Title: Re: 30 Line Game Challenge
Post by: Cobalt on September 17, 2018, 12:32:20 pm
here is my entry, less than 30 lines,  no IF\THEN or SELECT\CASE.

Code: QB64: [Select]
  1. 'Card Guessing Game, Kobolt 9/17/2018-12:15pm Ver 1.0, 22 lines!
  2. DIM hints(8) AS STRING
  3. FOR i% = 1 TO 8
  4.  READ hints(i%)
  5. NEXT i%
  6.  CLS
  7.  c% = INT(RND * 4) + 1
  8.  n% = INT(RND * 13) + 1
  9.  PRINT "(S)pade, (C)lubs, (H)earts, (D)iamonds, Ace-1, Jack-11, Queen-12, King-13", SPACE$(80)
  10.  PRINT "Hint - "; hints(c%), SPACE$(80)
  11.  DO
  12.   INPUT "What card is it (ex-D8=8 of Diamonds)"; a$
  13.   Try~% = Try~% + 1
  14.  LOOP UNTIL UCASE$(a$) = (hints(4 + c%) + LTRIM$(RTRIM$(STR$(n%))))
  15.  Good~% = Good~% + 1
  16.  INPUT "Try again?"; a$
  17. LOOP UNTIL LCASE$(a$) = "n"
  18. PRINT "Total trys:"; Try~%; " for "; Good~%; " Correct!"
  19. DATA "a garden tool","used when somebody is bad","gotta love with this","Ladies best friend","S","C","H","D"
  20.  
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 17, 2018, 01:12:55 pm
I don't know why the math is acting the way it is, but as a game designer, I follow the "first fix wins now, best fix wins later" principle.

Putting INT() around the final guess at least undoes the whole .5 thing and makes the guess correct:
Code: QB64: [Select]
  1.    23 PRINT "Your number is "; INT(guess)

You're right, Steve, how does binary math produce decimals? Without division, there should be no .5's in there. Do we actually have an instance of binary math producing fractional numbers?

Quote from: American Dad
You know what that'll do to society? Girls playing with trucks. Boys playing with dolls. Horses eating each other. Yes, horses eating each other! It's in the Bible, Fracine!

I tried to DIM guess as _byte, and it would guess 22 for 21, 6 for 5, 2 for 1. I tried to DIM guess, a, i, j as _byte, it brought back the .5's! I'm going to look more into this.
Title: Re: 30 Line Game Challenge
Post by: SMcNeill on September 17, 2018, 01:19:36 pm
    PRINT "i="; i
    22 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i)

for 21, i = -1 and 2 ^ -1 = .5

typo on line 22 to match line 14
 22 guess = guess + (2 AND a) * 2 ^ (i) - (1 AND a) * 2 ^ (i +1)  '  i + 1 fixes

That's what it is!  The formula is correct, which is why I couldn't sort out what the heck was wrong with it!!  ;D

Typos are hell to find.  Your brain knows what *should* be there, and it just overlooks the issue completely.  NOW, the guessing game actually guesses like it's supposed to. 

One good thing about the glitch: It probably helped everyone understand how it actually works now -- Binary search up/down in powers of 2 until it finds the solution.  :D

****************

Post corrected with the proper formula. 
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 17, 2018, 01:35:23 pm
Dang, I didn't read on to page two... B+ beat me by two posts making me both the later AND worst fix... Foot in mouth. Lol.
Title: Re: 30 Line Game Challenge
Post by: Pete on September 17, 2018, 02:42:08 pm
Have you tried putting peanut butter between your toes? I find it it helps take the edge off.

Dammit Steve, I remember when that typo crap started with me. It's just a sign of aging. Pretty soon you'll be wondering where you put your keys, and then discovering it doesn't matter, because you can't remember where you parked your car. After that, well, just hang on to that URL I posted for those "PEP" pills.

Kidding aside, thanks for posting this challenge. It got me off my duff from endless organizing, which I hate to do anyway, and got me back to doing something fun, even though I didn't read the directions. That card suit technique I came up with was new, and new stuff makes me happy. I seldom pull code from my repository, which sounds strangely akin to pulling something out of something else, but I digress. If I can code something fresh,  it's more fun but I have to admit, aging hasn't helped when it comes to the occasional goofs.

Pete

- I'm thinking of skipping my birthday this year, whenever the hell that is.

Title: Re: 30 Line Game Challenge
Post by: bplus on September 18, 2018, 10:21:58 am
Hey I got it! Here is Digit Thief Level 2:

You have only 3 digits 0, 1, 2 because you live in a world where everyone has 1 finger on the upper hand and 2 digits on their lower hand... but I guess that's a different story...  ;-))
BTW this could just as easily been 10 digits but I wanted a real threat of loosing all your digits before you are done guessing. Still there is one sure strategy to never loose, boring though... Come to think, could have a rule to prevent that but that would be more lines and IF's, anyway...  ;-))

So using only FOR loops to substitute for IF's and all other flow control mechanisms except GOTO, here is Digit Thief Level 2 at 24 lines (no colons except for line labels and no externals) plus 1 code debugger line I left in:
Code: QB64: [Select]
  1. RANDOMIZE TIMER ' Digit Thief 2 minus IF.bas for QB64 2018-09-18 B+
  2. jumpStart:
  3. gCount% = 0
  4. thief% = INT(RND * 3)
  5. digits$ = "012"
  6. loopAgain:
  7. 'PRINT "(debug thief is here:"; thief%; ")" '<<<<< I used this line to check my code
  8. INPUT "Enter Guess (0 to 2) where the digit thief is now "; guess%
  9. gCount% = gCount% + 1
  10. kstart = -1 * (guess% <> thief%)
  11. FOR k = kstart TO 0
  12.     PRINT "You caught the thief in" + STR$(gCount%) + " guesses."
  13.     GOTO jumpStart
  14. MID$(digits$, thief% + 1, 1) = " "
  15. PRINT "Digits Left Update: " + digits$
  16. thief% = ABS(INT(RND * 3) - 1 + thief%) MOD 3
  17. lstart = -1 * (digits$ <> STRING$(3, " "))
  18. FOR l = lstart TO 0
  19.     PRINT "Dang! too late! Gone in" + STR$(gCount%) + " guesses."
  20.     GOTO jumpStart
  21. GOTO loopAgain
  22.  

BTW there is no escape from Level 2. ha, ha, ha....

EDIT: one less FOR loop, one less line 23 lines plus a debugger commented out.
Title: Re: 30 Line Game Challenge
Post by: bplus on September 18, 2018, 11:10:22 am
Oh I just made 30 Line limit, Digit Thief 3 minus IF.bas now prevents digit guarding.
Code: QB64: [Select]
  1. RANDOMIZE TIMER ' Digit Thief 3 minus IF.bas for QB64 2018-09-18 B+  prevent "digit guarding"
  2. jumpStart:
  3. gCount% = 0
  4. thief% = INT(RND * 3)
  5. digits$ = "012"
  6. lastGuess% = -999
  7. loopAgain:
  8. INPUT "Enter Guess (0 to 2) where the digit thief is now "; guess%
  9. jstart = -1 * (guess% <> lastGuess%)
  10. FOR j = jstart TO 0
  11.     PRINT "Give Digit Thief a 50/50 chance! No digit guarding, make a different choice."
  12.     GOTO loopAgain
  13. gCount% = gCount% + 1
  14. lastGuess% = guess%
  15. kstart = -1 * (guess% <> thief%)
  16. FOR k = kstart TO 0
  17.     PRINT "You caught the thief in" + STR$(gCount%) + " guesses."
  18.     GOTO jumpStart
  19. MID$(digits$, thief% + 1, 1) = " "
  20. PRINT "Digits Left Update: " + digits$
  21. thief% = ABS(INT(RND * 3) - 1 + thief%) MOD 3
  22. lstart = -1 * (digits$ <> STRING$(3, " "))
  23. FOR l = lstart TO 0
  24.     PRINT "Dang! too late! Gone in" + STR$(gCount%) + " guesses."
  25.     GOTO jumpStart
  26. GOTO loopAgain
  27.  
Title: Re: 30 Line Game Challenge
Post by: Pete on September 18, 2018, 11:36:00 am
Wait jus ah dad-burn minute thar Varmint! You stole that thar name from me! Oops, sorry, err, my version was called Idgit Thief.

 - Sam
Title: Re: 30 Line Game Challenge
Post by: bplus on September 18, 2018, 12:37:57 pm
And here is: 21 minus IF.bas
Code: QB64: [Select]
  1. RANDOMIZE TIMER '21 minus IF.bas for QB64 2018-09-18 B+
  2. DIM deck%(1 TO 52)
  3. DATA 2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11
  4. FOR i% = 1 TO 52
  5.     READ deck%(i%)
  6. 'DO 'to run in loop uncomment, commented lines == Way more fun!!!
  7. 'CLS: di% = 0: playerT% = 0: dealerT% = 0
  8. FOR i% = 52 TO 2 STEP -1 'shuffle
  9.     r% = INT(RND * i%) + 1
  10.     SWAP deck%(r%), deck%(i%)
  11. FOR i% = -1 TO 0
  12.     di% = di% + 1
  13.     playerT% = playerT% + deck%(di%)
  14.     _PRINTSTRING (27, di% + 5), "Player card: " + RIGHT$(SPACE$(2) + STR$(deck%(di%)), 2) + " total is " + RIGHT$(SPACE$(2) + STR$(playerT%), 2)
  15.     i% = (playerT% < 15)
  16. istart% = -1 * (playerT% > 21)
  17. FOR i% = istart% TO 0
  18.     di% = di% + 1
  19.     dealerT% = dealerT% + deck%(di%)
  20.     _PRINTSTRING (27, di% + 7), "Dealer card: " + RIGHT$(SPACE$(2) + STR$(deck%(di%)), 2) + " total is " + RIGHT$(SPACE$(2) + STR$(dealerT%), 2)
  21.     i% = (dealerT% < playerT%)
  22. istart% = -1 * (playerT% > 21 OR (dealerT% < 22 AND dealerT% >= playerT%))
  23. FOR i% = istart% TO 0
  24.     PRINT "Hey Player, you Won!"
  25.     GOTO skip
  26. PRINT "Sorry Player, Dealer Won!"
  27. skip:
  28. '_DELAY 4
  29. 'LOOP 'this is line 34 minus 4 commented lines  = 30 !
  30.  
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 18, 2018, 07:25:16 pm
Here is my entry. Started it last night. Finished it about an 30mins ago, then played it a little.
It's a simple dice game. No IFs, WHILEs, DOs, SELECTs, and all logic is math based. Please tell me if the instructions are clear enough. It's quite a complex little game for 30 lines! Which made it kind of hard to sum up. Lol.
Code: QB64: [Select]
  1. 2 FOR a% = 0 TO 20000
  2.    3 FOR die%% = 1 TO 6
  3.        4 keep(die%%) = 0
  4.        5 tally(die%%) = 0
  5.        6 dice(die%%) = INT(RND * 6 + 1)
  6.    7 NEXT
  7.    8 kept%% = 0
  8.    9 FOR hand%% = 0 TO 6
  9.        10 FOR hold%% = 0 TO 2
  10.            11 this%% = kept%%
  11.            12 FOR die%% = kept%% + 1 TO 6
  12.                 PRINT "Welcome to DICE!"; CHR$(13); CHR$(13); "Choose your selections carefully, as after you have made decisions on all dice,"; "the game rerolls. You MUST keep at least 1 die each roll, and once you have kept"; "6 dice, you will receive your score for the round."; CHR$(13); "REMEMBER: When you do not keep a die, it is rerolled."; CHR$(13); CHR$(13); "Your goal is to reach 20000pts! Have Fun!"; CHR$(13); CHR$(13); "SCORE HELP"; CHR$(13); "----------"; CHR$(13); "1=100  2=0  3=0  4=0  5=50  6=0"; CHR$(13); "Triple 1's=1000 Triple 4's=400"; CHR$(13); "Triple 2's=200  Triple 5's=500"; CHR$(13); "Triple 3's=300  Triple 6's=600"; CHR$(13); "A straight of 1-6=2000"; STRING$(4, 13); "Current score is:"; score%; "/ 20000"; CHR$(13); "Dice rolled in this hand:       "; dice(1); dice(2); dice(3); dice(4); dice(5); dice(6); CHR$(13); "Dice you have kept this round:  "; keep(1); keep(2); keep(3); keep(4); keep(5); keep(6); CHR$(13); CHR$(13); "Keep die"; RTRIM$(STR$(die%%)); "? [It's a"; RTRIM$(STR$(dice(die%%))); "] (1=y 0=n)";
  13.                14 INPUT "", in
  14.                15 keep(kept%% + 1) = in * dice(die%%)
  15.                16 kept%% = kept%% + in
  16.                17 tally(keep(kept%%)) = tally(keep(kept%%)) + in
  17.            18 NEXT
  18.            19 hold%% = 2 * (kept%% - this%%)
  19.        20 NEXT
  20.        21 FOR die%% = 1 TO 6
  21.            22 dice(die%%) = (ABS(keep(die%%) <> 0) * 0) + (ABS(keep(die%%) = 0) * INT(RND * 6 + 1))
  22.        23 NEXT
  23.        24 hand%% = kept%%
  24.    25 NEXT
  25.     score% = score% + (tally(1) * 100) + (INT(tally(1) / 3) * 700) + (INT(tally(2) / 3) * 200) + (INT(tally(3) / 3) * 300) + (INT(tally(4) / 3) * 400) + (tally(5) * 50) + (INT(tally(5) / 3) * 350) + (INT(tally(6) / 3) * 600) + (INT(ABS((tally(1) = 1) + (tally(2) = 1) + (tally(3) = 1) + (tally(4) = 1) + (tally(5) = 1) + (tally(6) = 1)) / 6) * 2000)
  26.    27 a% = score%
  27.    28 CLS
  28. 29 NEXT
  29. 30 PRINT "Congratulations! You beat 20000pts! Your score was:"; score%

[EDIT]Fixed code in code box.
Title: Re: 30 Line Game Challenge
Post by: bplus on September 18, 2018, 07:44:56 pm
Ah nice, as I understand it, all the choices are prearranged and it is matter of choosing combination with yes = * 1 or no * 0 questions. Completely different approach from what I had done.

My tests seem to be getting stuck on choice for selecting 6th die, I keep choosing no and it keeps showing me the same number.  I don't fully understand game like how many times you are allowed to reject a die.
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 18, 2018, 09:13:13 pm
Ahh... I knew I was forgetting to explain some things. That was my bad. It should explain it better now in the above code.

In case it doesn't(Oh, I broke the challenge rules and used a CASE XD), here is a breakdown of DICE.

You roll a hand of 6 dice.

You get 6 6 4 1 1 5

You decide to take 1 1 5 and keep them.

You now have 1 1 5, and you reroll the 6 6 4 and get 1 3 2.

You decide to take the 1.

You now have 1 1 5 1, and you reroll the 3 2 and get 5 5.

You decide to take both fives.

You end this round with 1 1 5 1 5 5 and earn 1500pts. 1000 for the triple 1's and 500 for the triple 5's.

That ends that round, and then the game rerolls all 6 dice for the next round.

You roll 6 3 1 2 4 5.

You decide to keep all six dice, because you have a straight 1-2-3-4-5-6.

You end the round with 6 3 1 2 4 5 and earn 2000pts. for the straight. You now have a score of 3500pts.

You ALWAYS have to keep at least one(1) die, whether it scores points or not, and you can keep between 1-6 dice from each hand.
Title: Re: 30 Line Game Challenge
Post by: TerryRitchie on September 18, 2018, 09:26:06 pm
I needed a distraction, this challenge was perfect.

Here is my entry - Yellow GOOD ... Red BAD

Code: QB64: [Select]
  1. DIM box(50) AS STRING
  2. SCREEN _NEWIMAGE(640, 480, 32) ' *** YELLOW GOOD ... RED BAD ***
  3.     _LIMIT 30
  4.     CLS
  5.     LOCATE 1, 1
  6.     PRINT STR$(score)
  7.     WEND
  8.     m$ = RIGHT$("0" + LTRIM$(STR$(_MOUSEX)), 3) + RIGHT$("0" + LTRIM$(STR$(_MOUSEY)), 3) ' xxxyyy
  9.     LINE (VAL(LEFT$(m$, 3)) - 10, VAL(RIGHT$(m$, 3)) - 10)-(VAL(LEFT$(m$, 3)) + 10, VAL(RIGHT$(m$, 3)) + 10), _RGB32(255, 255, 255), BF ' white box
  10.     FOR x = 1 TO 50
  11.         IF box(x) = "" OR VAL(MID$(box(x), 4, 3)) > 500 THEN box(x) = RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 600) + 20)), 3) + "-40" + RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 10) + 1)), 2) + LTRIM$(STR$(INT(RND(1) * 2)))
  12.         box(x) = LEFT$(box(x), 3) + RIGHT$("0" + STR$(VAL(MID$(box(x), 4, 3)) + VAL(MID$(box(x), 7, 2))), 3) + RIGHT$(box(x), 3) ' add speed to y
  13.         LINE (VAL(LEFT$(box(x), 3)) - 20, VAL(MID$(box(x), 4, 3)) - 20)-(VAL(LEFT$(box(x), 3)) + 20, VAL(MID$(box(x), 4, 3)) + 20), _RGB32(255, VAL(RIGHT$(box(x), 1)) * 255, 0), BF
  14.         IF VAL(LEFT$(m$, 3)) - 10 <= VAL(LEFT$(box(x), 3)) + 20 AND VAL(LEFT$(m$, 3)) + 10 >= VAL(LEFT$(box(x), 3)) - 20 AND VAL(RIGHT$(m$, 3)) - 10 <= VAL(MID$(box(x), 4, 3)) + 20 AND VAL(RIGHT$(m$, 3)) - 10 >= VAL(MID$(box(x), 4, 3)) - 20 THEN
  15.             IF VAL(RIGHT$(box(x), 1)) = 1 THEN
  16.                 score = score + 1
  17.                 box(x) = ""
  18.                 SOUND 220, 1
  19.                 SOUND 440, 1
  20.             ELSE
  21.                 SOUND 220, 10
  22.                 END
  23.             END IF
  24.         END IF
  25.     NEXT x
  26.     _DISPLAY
Title: Re: 30 Line Game Challenge
Post by: bplus on September 18, 2018, 09:31:52 pm
Hi Omerta,

Ahhh, you must accept at least 1 die, got it! Thanks

Omerta: "In case it doesn't(Oh, I broke the challenge rules and used a CASE XD), here is a breakdown of DICE."
LOL that one case might be forgiven :)

Now, how many hands are there? If you have answered this question already, I apologize for my poor reading skills.

Append" OK "For hands = 0 to 6" so seven hands OK
Title: Re: 30 Line Game Challenge
Post by: bplus on September 18, 2018, 09:51:34 pm
Hi Terry,

Damn fine game! but I am seeing some IF's.

It's like those bull riding games, if you last 10 secs you did good the heck with the points!
Title: Re: 30 Line Game Challenge
Post by: Pete on September 18, 2018, 09:52:01 pm
I needed a distraction, this challenge was perfect.

Here is my entry - Yellow GOOD ... Red BAD

Code: QB64: [Select]
  1. DIM box(50) AS STRING
  2. SCREEN _NEWIMAGE(640, 480, 32) ' *** YELLOW GOOD ... RED BAD ***
  3.     _LIMIT 30
  4.     CLS
  5.     LOCATE 1, 1
  6.     PRINT STR$(score)
  7.     WEND
  8.     m$ = RIGHT$("0" + LTRIM$(STR$(_MOUSEX)), 3) + RIGHT$("0" + LTRIM$(STR$(_MOUSEY)), 3) ' xxxyyy
  9.     LINE (VAL(LEFT$(m$, 3)) - 10, VAL(RIGHT$(m$, 3)) - 10)-(VAL(LEFT$(m$, 3)) + 10, VAL(RIGHT$(m$, 3)) + 10), _RGB32(255, 255, 255), BF ' white box
  10.     FOR x = 1 TO 50
  11.         IF box(x) = "" OR VAL(MID$(box(x), 4, 3)) > 500 THEN box(x) = RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 600) + 20)), 3) + "-40" + RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 10) + 1)), 2) + LTRIM$(STR$(INT(RND(1) * 2)))
  12.         box(x) = LEFT$(box(x), 3) + RIGHT$("0" + STR$(VAL(MID$(box(x), 4, 3)) + VAL(MID$(box(x), 7, 2))), 3) + RIGHT$(box(x), 3) ' add speed to y
  13.         LINE (VAL(LEFT$(box(x), 3)) - 20, VAL(MID$(box(x), 4, 3)) - 20)-(VAL(LEFT$(box(x), 3)) + 20, VAL(MID$(box(x), 4, 3)) + 20), _RGB32(255, VAL(RIGHT$(box(x), 1)) * 255, 0), BF
  14.         IF VAL(LEFT$(m$, 3)) - 10 <= VAL(LEFT$(box(x), 3)) + 20 AND VAL(LEFT$(m$, 3)) + 10 >= VAL(LEFT$(box(x), 3)) - 20 AND VAL(RIGHT$(m$, 3)) - 10 <= VAL(MID$(box(x), 4, 3)) + 20 AND VAL(RIGHT$(m$, 3)) - 10 >= VAL(MID$(box(x), 4, 3)) - 20 THEN
  15.             IF VAL(RIGHT$(box(x), 1)) = 1 THEN
  16.                 score = score + 1
  17.                 box(x) = ""
  18.                 SOUND 220, 1
  19.                 SOUND 440, 1
  20.             ELSE
  21.                 SOUND 220, 10
  22.                 END
  23.             END IF
  24.         END IF
  25.     NEXT x
  26.     _DISPLAY

OK, me not willing to read / follow instructions is pretty much a given but a United States Marine doing the same? Oh the horror!

Hey Terry, Steve put the nix on the use of conditional statements for this challenge, so you and I are disqualified. I mean it doesn't effect me either way, because I'm fully stocked up on tissues...oh shut up Bill!, but I'm really worried this could cost you your pension.

Of course, there's always my challenge... https://www.qb64.org/forum/index.php?topic=596.0

Pete :D
Title: Re: 30 Line Game Challenge
Post by: bplus on September 18, 2018, 10:02:23 pm
I count 3 IF's in Terry's program. Each will cost 2 more lines but I see some padding eg sounds...

hmm... might be doable?

WHILE _MOUSEINPUT

that's a tough one.

I would let that pass for mouse and graphics game! :)
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 18, 2018, 10:22:09 pm
Hey, Terry. That's a pretty neat little game there. I think you're the only one that got fancy with sounds and graphics! Although, not the only one that used conditionals apparently. XD But, still probably the most addictive game here(Must be the colors and the sounds. Haha).

Hey, B+, I imagine with Digit Thief that he has me blindfolded and he's pinning my hand to a table, and making me guess which finger he'll take next. Kind of dark and sadistic! Lol. Oh, yeah, and we're in the seedy underbelly of a Hong Kong restaurant backroom. XD

Hey, Pete. Neat game, it took me a second to figure out the next card was the card that was higher or lower than the last. But, I like it. I've always liked high or low, because it's simple, clean, and with few rules.

Anyway, here's an updated smoother version of my game. Better explanation, and now you can see your score AND how many turns it took you as well!

Code: QB64: [Select]
  1. 2 FOR a% = 0 TO 20000
  2.    3 FOR die%% = 1 TO 6
  3.        4 keep(die%%) = 0
  4.        5 tally(die%%) = 0
  5.        6 dice(die%%) = INT(RND * 6 + 1)
  6.    7 NEXT
  7.    8 kept%% = 0
  8.    9 FOR hand%% = 0 TO 6
  9.        10 FOR hold%% = 0 TO 2
  10.            11 this%% = kept%%
  11.            12 FOR die%% = kept%% + 1 TO 6
  12.                13 PRINT "Welcome to DICE!"; CHR$(13); CHR$(13); "Choose your dice carefully, as after you have made all of your decisions, the game rerolls the dice you did not keep. You MUST keep at least 1 die each hand, and once you have kept 6 dice, you will receive your score for that round."; CHR$(13); CHR$(13); "Your goal is to reach 20000pts! Have Fun!"; CHR$(13); CHR$(13); CHR$(13); "SCORE HELP"; CHR$(13); "----------"; CHR$(13); "1=100  2=0  3=0  4=0  5=50  6=0"; CHR$(13); "Triple 1's=1000 Triple 4's=400"; CHR$(13); "Triple 2's=200  Triple 5's=500"; CHR$(13); "Triple 3's=300  Triple 6's=600"; CHR$(13); "A straight of 1-6=2000"; STRING$(4, 13); "Current score is:"; score%; "/ 20000"; CHR$(13); "Dice rolled in this hand:       "; dice(1); dice(2); dice(3); dice(4); dice(5); dice(6); CHR$(13); "Dice you have kept this round:  "; keep(1); keep(2); keep(3); keep(4); keep(5); keep(6); CHR$(13); CHR$(13); "Keep die"; RTRIM$(STR$(die%%)); "? [It's a"; RTRIM$(STR$(dice(die%%))); "] (1=y 0=n)";
  13.                14 INPUT "", in~%%
  14.                15 keep(kept%% + 1) = _CEIL(in~%% / 255) * dice(die%%)
  15.                16 kept%% = kept%% + _CEIL(in~%% / 255)
  16.                17 tally(keep(kept%%)) = tally(keep(kept%%)) + _CEIL(in~%% / 255)
  17.            18 NEXT
  18.            19 hold%% = 2 * (kept%% - this%%)
  19.        20 NEXT
  20.        21 FOR die%% = 1 TO 6
  21.            22 dice(die%%) = (ABS(keep(die%%) <> 0) * 0) + (ABS(keep(die%%) = 0) * INT(RND * 6 + 1))
  22.        23 NEXT
  23.        24 hand%% = kept%%
  24.    25 NEXT
  25.    26 score% = score% + (tally(1) * 100) + (INT(tally(1) / 3) * 700) + (INT(tally(2) / 3) * 200) + (INT(tally(3) / 3) * 300) + (INT(tally(4) / 3) * 400) + (tally(5) * 50) + (INT(tally(5) / 3) * 350) + (INT(tally(6) / 3) * 600) + (INT(ABS((tally(1) = 1) + (tally(2) = 1) + (tally(3) = 1) + (tally(4) = 1) + (tally(5) = 1) + (tally(6) = 1)) / 6) * 1850)
  26.    27 turn% = turn% + 1
  27.    28 a% = score%
  28. 29 NEXT
  29. 30 PRINT STRING$(22, 13); "Congratulations! You beat 20000pts! You scored"; score%; "in"; turn%; "turns!"
Title: Re: 30 Line Game Challenge
Post by: TerryRitchie on September 18, 2018, 10:33:06 pm
Yeah, I forgot about not being able to use conditionals. I read the post a week ago when it first came out. Should have read it again.

Oh well, was still a hoot to write
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 18, 2018, 11:46:24 pm
Yep. It's amazing what you can stuff into 30 lines when you put your mind to it, right?
Title: Re: 30 Line Game Challenge
Post by: FellippeHeitor on September 18, 2018, 11:54:01 pm
Are we voting yet? Terry's Atari-like little game was amazing!
Title: Re: 30 Line Game Challenge
Post by: bplus on September 19, 2018, 12:49:15 am
Are we voting yet? Terry's Atari-like little game was amazing!

Well if the Challenge was for best game 30 lines of less Terry's game is definitely a strong start but the point of this thread was to do this without IF's.

I don't know what Steve thinks of WHILE _MOUSEINPUT, it seems the only way to get mouse but it's one of those WHILE's....

Here is Terry's Game without the IF's and without sound in attempts to get line count back down to 30. I got it to 32 removing a LOCATE and replacing with _PrintString, I also deducted points when struck by red box instead of ending game.
Code: QB64: [Select]
  1. DIM box(50) AS STRING
  2. SCREEN _NEWIMAGE(640, 480, 32) ' *** YELLOW GOOD ... RED BAD ***   MOD B+ 2018-09-19 remove IF's and sound
  3.     _LIMIT 30
  4.     CLS
  5.     _PRINTSTRING (10, 10), STR$(score) 'one less line for locate
  6.     WEND
  7.     m$ = RIGHT$("0" + LTRIM$(STR$(_MOUSEX)), 3) + RIGHT$("0" + LTRIM$(STR$(_MOUSEY)), 3) ' xxxyyy
  8.     LINE (VAL(LEFT$(m$, 3)) - 10, VAL(RIGHT$(m$, 3)) - 10)-(VAL(LEFT$(m$, 3)) + 10, VAL(RIGHT$(m$, 3)) + 10), _RGB32(255, 255, 255), BF ' white box
  9.     FOR x = 1 TO 50
  10.         istart = -1 * ((box(x) <> "") AND (VAL(MID$(box(x), 4, 3)) <= 500))
  11.         FOR i = istart TO 0
  12.             box(x) = RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 600) + 20)), 3) + "-40" + RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 10) + 1)), 2) + LTRIM$(STR$(INT(RND(1) * 2)))
  13.         NEXT i
  14.         box(x) = LEFT$(box(x), 3) + RIGHT$("0" + STR$(VAL(MID$(box(x), 4, 3)) + VAL(MID$(box(x), 7, 2))), 3) + RIGHT$(box(x), 3) ' add speed to y
  15.         LINE (VAL(LEFT$(box(x), 3)) - 20, VAL(MID$(box(x), 4, 3)) - 20)-(VAL(LEFT$(box(x), 3)) + 20, VAL(MID$(box(x), 4, 3)) + 20), _RGB32(255, VAL(RIGHT$(box(x), 1)) * 255, 0), BF
  16.         istart = -1 * (VAL(LEFT$(m$, 3)) - 10 > VAL(LEFT$(box(x), 3)) + 20 OR VAL(LEFT$(m$, 3)) + 10 < VAL(LEFT$(box(x), 3)) - 20 OR VAL(RIGHT$(m$, 3)) - 10 > VAL(MID$(box(x), 4, 3)) + 20 OR VAL(RIGHT$(m$, 3)) - 10 < VAL(MID$(box(x), 4, 3)) - 20)
  17.         FOR i = istart TO 0
  18.             jstart = -1 * (VAL(RIGHT$(box(x), 1)) = 0)
  19.             box(x) = ""
  20.             FOR j = jstart TO 0
  21.                 score = score + 1
  22.                 GOTO skip
  23.             NEXT j
  24.             score = score - 2
  25.         NEXT i
  26.         skip:
  27.     NEXT x
  28.     _DISPLAY
  29.  

Maybe someone can get two more lines out? Yes, but the sound really added to game...

Or maybe someone can start a 30 lines or less challenge without the IF condition, so all of us can compete under same rules.
Title: Re: 30 Line Game Challenge
Post by: SMcNeill on September 19, 2018, 01:00:56 am
A few tricks I could see for maybe avoiding WHILE with _MOUSEINPUT :

FOR I = ABS(_MOUSEINPUT) TO 0 STEP -1
   I = - _MOUSEINPUT
NEXT

****************

Label:
ON ABS(_MOUSEINPUT) GOTO Label

****************

Neither is tested, but I'd think both should work instead of the WHILE...WEND -- which is really the whole point of these style contests:  To have fun and force one to alter their way of thinking to perform otherwise mundane tasks.  ;)
Title: Re: 30 Line Game Challenge
Post by: FellippeHeitor on September 19, 2018, 01:11:00 am
Here's my entry. Capture the letter being shown by pressing it on your keyboard to score; type a wrong key and lose a point.
Twenty points and you win.

Speed increases as you progress.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. _DEST _NEWIMAGE(300, 300, 32)
  3. COLOR , 0
  4. difficulty! = 1.5
  5.     _PRINTSTRING (0, 0), "SCORE:" + STR$(score&), 0
  6.     letter$ = CHR$(INT(RND * 26) + 65)
  7.     x = RND * (_WIDTH - 30)
  8.     y = RND * (_HEIGHT - 30)
  9.     LINE (x, y)-STEP(30, 30), _RGB32(x MOD 200 + (100 * ABS((x MOD 200) < 50)), y MOD 150 + (100 * ABS((y MOD 150) < 50)), x MOD 255 + (100 * ABS((x MOD 150) < 50))), BF
  10.     _PRINTSTRING (x + 11, y + 7), letter$
  11.     start! = TIMER
  12.     DO
  13.         k$ = UCASE$(INKEY$)
  14.         DO WHILE TIMER - start! > difficulty!
  15.             GOTO checkKey
  16.         LOOP
  17.         LINE (0, _HEIGHT - 5)-(((_WIDTH + 5) * ((TIMER - start!) / difficulty!)), _HEIGHT), _RGB32(x MOD 200 + (100 * ABS((x MOD 200) < 50)), y MOD 150 + (100 * ABS((y MOD 150) < 50)), x MOD 255 + (100 * ABS((x MOD 150) < 50))), BF
  18.         _PUTIMAGE , _DEST, _DISPLAY
  19.         _LIMIT 30
  20.     LOOP WHILE k$ < "A" OR k$ > "Z"
  21.     checkKey:
  22.     LINE (x - (300 * (k$ = letter$)), y - (300 * (k$ = letter$)))-STEP(30, 30), _RGBA32(0, 0, 0, 200), BF
  23.     LINE (x - (300 * (k$ <> letter$)), y - (300 * (k$ <> letter$)))-STEP(30, 30), _RGB32(255, 255, 0), B
  24.     score& = score& + ABS(k$ = letter$) - (ABS(k$ <> letter$) * ABS(LEN(k$) > 0))
  25.     difficulty! = difficulty! - (ABS(k$ = letter$) / 100)
  26. LOOP UNTIL score& < 0 OR score& = 21
  27. _PRINTSTRING (_WIDTH / 2 - (LEN("You " + LEFT$("lose...", 7 * ABS(score& < 0)) + LEFT$("win!", 4 * ABS(score& > 0))) * 8) / 2, _HEIGHT / 2 - 8), "You " + LEFT$("lose...", 7 * ABS(score& < 0)) + LEFT$("win!", 4 * ABS(score& > 0)), 0

Edit: changed the location of the _LIMIT line so it's more processor efficient.

 [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: 30 Line Game Challenge
Post by: bplus on September 19, 2018, 01:13:56 am
Steve: "To have fun and force one to alter their way of thinking to perform otherwise mundane tasks."  ;)

Yep! I was lost for awhile without my favorite IF but FOR does have a condition branching built-in that can be used.

Another way might be throwing an error? Like when reading data.
Title: Re: 30 Line Game Challenge
Post by: Omerta7486 on September 19, 2018, 01:18:52 am
Quote from: bplus
Or maybe someone can start a 30 lines or less challenge without the IF condition, so all of us can compete under same rules.

We all can compete under the same rules. No conditionals. Lol. It wouldn't be much of a challenge otherwise.
Title: Re: 30 Line Game Challenge
Post by: Pete on September 19, 2018, 01:29:37 am
Here's my entry. Capture the letter being shown by pressing it on your keyboard to score; type a wrong key and lose a point.
Twenty points and you win.

Fun and fast! It's just random letters, so it's different every time. Steve made one just like it once, but it kept spelling out "Steve is awesome" Now that gets old fast.

Pete :D
Title: Re: 30 Line Game Challenge
Post by: TempodiBasic on September 20, 2018, 07:42:33 pm
Hy guys
I am more asleep than how usually I am (at this time ...) :-)
 but is it  real that the challange was about NO conventional flow instructions?
No WHILE WEND, IF THEN ELSE END IF, DO WHILE LOOP, DO LOOP WHILE, DO UNTIL LOOP, DO LOOP UNTIL, >, < , >=, <=,
No trick like '$include:'Megafile.BI', or more instructions on the same linecode with :

but while I was thinking how to make an IF without an IF , I have had so many ideas but so poor productive time to code and I have forgotten the instructions ON KEY GOSUB and ON x GOSUB /facepalm a simple way to control event/variable  without IF .
In the while I've stucked into my first attempt to make an ASCII game and this is the result:
Code: QB64: [Select]
  1. _MOUSEMOVE 10, 10
  2.     mH% = mH% - 1
  3.     FOR moveHer% = mH% TO -1 STEP -1
  4.         mH% = 33000
  5.         GOSUB 2
  6.     NEXT
  7.     CLS , 1
  8.     COLOR 4, 2
  9.     _PRINTSTRING (HerY, HerX), CHR$(2)
  10.     _PRINTSTRING (1, 1), "Be Cupid! Let meet he  and she  and gain their loves ! you arrive upon her    and leftclick to meet her"
  11.     FOR fakeInput% = -1 TO _MOUSEINPUT STEP -1
  12.         FOR fakeBtn1% = -1 TO _MOUSEBUTTON(1) STEP -1
  13.             FOR match% = 0 TO (2 XOR SCREEN(_MOUSEY, _MOUSEX)) STEP -1
  14.                 _PRINTSTRING (25, 5), "    The power of love!   "
  15.                 _PRINTSTRING (15, 25), "TO PLAY AGAIN PRESS ENTER, ANY OTHER KEY TO QUIT "
  16.                 SLEEP
  17.                 FOR quit% = -1 TO _KEYDOWN(13) STEP -1
  18.                     GOTO 1
  19.                 NEXT quit%
  20.                 SYSTEM
  21.     NEXT match%, fakeBtn1%, fakeInput%
  22.     _LIMIT 200
  23. 2 HerX = INT(RND * (24 - 2)) + 2
  24. HerY = INT(RND * (80 - 2)) + 2
  25.  

Have a fun to search to catch the woman :-)
Thanks to try

PS you guys have posted very good demo
Title: Re: 30 Line Game Challenge
Post by: bplus on September 21, 2018, 08:32:03 am
Dang! TempodiBasic nice, very nice! You did the mouse without a WHILE AND no <, >, <=, >=  but I am not sure how to play game? I try to move mouse He to She but mouse does not obey.

I just suddenly realized how to bring Terry's game back down to 30 lines AND keep the sound AND I am keeping the play going after being hit by red square, just deduct points, still has While for _MOUSEINPUT and now a little mouse arrow and a little flicker on slower machine, I am not getting much flicker:

Code: QB64: [Select]
  1. DIM box(50) AS STRING
  2. SCREEN _NEWIMAGE(640, 480, 32) ' *** YELLOW GOOD ... RED BAD ***   MOD 2 B+ 2018-09-21 remove IF's  Sound is Back! 30 lines!!!
  3.     _LIMIT 30
  4.     CLS
  5.     _PRINTSTRING (10, 10), STR$(score) 'one less line for locate
  6.     WEND
  7.     m$ = RIGHT$("0" + LTRIM$(STR$(_MOUSEX)), 3) + RIGHT$("0" + LTRIM$(STR$(_MOUSEY)), 3) ' xxxyyy
  8.     LINE (VAL(LEFT$(m$, 3)) - 10, VAL(RIGHT$(m$, 3)) - 10)-(VAL(LEFT$(m$, 3)) + 10, VAL(RIGHT$(m$, 3)) + 10), _RGB32(255, 255, 255), BF ' white box
  9.     FOR x = 1 TO 50
  10.         FOR i = -1 * ((box(x) <> "") AND (VAL(MID$(box(x), 4, 3)) <= 500)) TO 0
  11.             box(x) = RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 600) + 20)), 3) + "-40" + RIGHT$("0" + LTRIM$(STR$(INT(RND(1) * 10) + 1)), 2) + LTRIM$(STR$(INT(RND(1) * 2)))
  12.         NEXT i
  13.         box(x) = LEFT$(box(x), 3) + RIGHT$("0" + STR$(VAL(MID$(box(x), 4, 3)) + VAL(MID$(box(x), 7, 2))), 3) + RIGHT$(box(x), 3) ' add speed to y
  14.         LINE (VAL(LEFT$(box(x), 3)) - 20, VAL(MID$(box(x), 4, 3)) - 20)-(VAL(LEFT$(box(x), 3)) + 20, VAL(MID$(box(x), 4, 3)) + 20), _RGB32(255, VAL(RIGHT$(box(x), 1)) * 255, 0), BF
  15.         FOR i = -1 * (VAL(LEFT$(m$, 3)) - 10 > VAL(LEFT$(box(x), 3)) + 20 OR VAL(LEFT$(m$, 3)) + 10 < VAL(LEFT$(box(x), 3)) - 20 OR VAL(RIGHT$(m$, 3)) - 10 > VAL(MID$(box(x), 4, 3)) + 20 OR VAL(RIGHT$(m$, 3)) - 10 < VAL(MID$(box(x), 4, 3)) - 20) TO 0
  16.             jstart = (-1 * (VAL(RIGHT$(box(x), 1)) = 0))
  17.             FOR j = jstart TO 0
  18.                 score = score + 1
  19.                 SOUND 440, 1
  20.                 GOTO skip
  21.             NEXT j
  22.             SOUND 220, 1
  23.             score = score - 2
  24.             skip:
  25.             box(x) = ""
  26.         NEXT i
  27.     NEXT x
  28.  
  29.  

PS for some reason the FOR statement is not allowing me to substitute jstart into the starting slot like I did do with the other FOR starters, I wonder why? too complex an expression for FOR to handle? Can't be! just look at the iStarter!

If we could make that substitution that would give us another line to bring back _DISPLAY or _MOUSEHIDE.
Title: Re: 30 Line Game Challenge
Post by: TerryRitchie on September 21, 2018, 12:06:53 pm
Great mods on the game. :)
Title: Re: 30 Line Game Challenge
Post by: TempodiBasic on September 21, 2018, 05:37:01 pm
Hi Bplus
thanks to try

the difficult to drive He is a feature coded and not a glitch!
the game is like a Mensa test... or like my IQ test posted on [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] some year ago, always in ASCII.
The user must find the way to arrive to She. (There are two ways to do this performance)
About the difficult to move He is like in a game that my children have showed me some time ago Octodad https://www.google.it/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwjN6Z-ghM3dAhVHzRoKHSKFD7gQjRx6BAgBEAU&url=https%3A%2F%2Fstore.steampowered.com%2Fapp%2F224480%2FOctodad_Dadliest_Catch%2F&psig=AOvVaw3Ei8raW8ItVh_arct6j3cG&ust=1537651468324172 (https://www.google.it/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwjN6Z-ghM3dAhVHzRoKHSKFD7gQjRx6BAgBEAU&url=https%3A%2F%2Fstore.steampowered.com%2Fapp%2F224480%2FOctodad_Dadliest_Catch%2F&psig=AOvVaw3Ei8raW8ItVh_arct6j3cG&ust=1537651468324172)  here website https://en.wikipedia.org/wiki/Octodad:_Dadliest_Catch (https://en.wikipedia.org/wiki/Octodad:_Dadliest_Catch).

Sorry I'm not able to catch a screenshot of the program when you catch She using Print key and pasting in MsPaint. I get a white square into a greater black square. ???
Please someone can suggest me another way to get screenshot of an ASCII game fullscreen?

Thanks
Title: Re: 30 Line Game Challenge
Post by: SMcNeill on September 21, 2018, 05:48:40 pm
http://qb64.freeforums.net/thread/55/save-image-library

SaveImage will save you a BMP or PNG image, regardless of screen mode.  Just call it when you want to grab a screenshot.
Title: Re: 30 Line Game Challenge
Post by: TempodiBasic on September 21, 2018, 07:36:36 pm
Hi Steve
Thans so much for your fantastic utility!
Now I'm posting screenshot of my ASCIIgame