Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2048 Puzzle
#28
(10-22-2024, 03:26 PM)bplus Wrote: Some good points for sure!

I totally forgot about Input$(1) and am kicking myself for it.
That's what I know and respect from the amazing Steve Smile

I do disagree on two lines for Next when one will do, specially for 2D array on game board of graphic, just wasting space. I am a not forbidding colons; as you said and I said, makes sense for multiple assignments and I want to include multiple one word statements.

In Reply above, #24, I agree that first line is crap and I confess I was pushing it to get lines from like 65 to the cute 64. I don't think your alternate is much clearer, IMHO.

We could debate all day what maximum amount of characters per line might work best to avoid horizontal scrolling, so ehh to 80 Smile with 100 chars you have a better chance of fitting comments on same line as code. I say a big YEA! to that.

I think how I got from < 100 to 75 was more artfully done. But here's is a good thing I found getting to 64 lines:

Getting rid of 2 lines for Function definition /End Function, which you can do anytime you call a sub or function only once in main code, this was slightly ineffecient:
Code: (Select All)
Function RemaingMove '   == Can player still make a move? ==
    For y = 0 To 3: For x = 0 To 3 '                     == Look for empty space or combine move ==
            If B(y * 4 + x) = 0 Then RemaingMove = 1 '                     == yes a move is left ==
            If y < 3 Then If B(y * 4 + x) = B((y + 1) * 4 + x) Then RemaingMove = 1 '  move left ==
            If x < 3 Then If B(y * 4 + x) = B(y * 4 + (x + 1)) Then RemaingMove = 1 '  move left ==
    Next: Next
End Function
You could : Exit Function after each of 3 RemainMove = 1 to get back to it in main faster (but who would really notice) but that means more colons crap.

To this:
Code: (Select All)
    For y = 0 To 3: For x = 0 To 3 '                     == Look for empty space or combine move ==
            If B(y * 4 + x) = 0 Then 10 '                      == yes a move is left, skip to 10 ==
            If y < 3 Then If B(y * 4 + x) = B((y + 1) * 4 + x) Then 10 '  == a move left goto 10 ==
            If x < 3 Then If B(y * 4 + x) = B(y * 4 + (x + 1)) Then 10 '  == a move left goto 10 ==
    Next: Next
Which actually did function more efficiently using the old fashioned THEN (GOTO) line_number and no colon crap.


And you can consoldate all those lines down into one statement, since they're all doing the same thing:

Code: (Select All)
If (B(y * 4 + x) = 0) _ORELSE (y < 3 _Andalso B(y * 4 + x) = B((y + 1) * 4 + x)) _ORELSE _
(x < 3 _Andalso B(y * 4 + x) = B(y * 4 + (x + 1))) Then RemaingMove = 1 ' move left ==


Now question: Is the above one line of code, or two lines of code since I continued it with the underscore _ so it doesn't go past that 100 character limit?
Reply


Messages In This Thread
2048 Puzzle - by Dav - 10-17-2024, 02:19 AM
RE: 2048 Puzzle - by FellippeHeitor - 10-17-2024, 02:42 AM
RE: 2048 Puzzle - by Dav - 10-17-2024, 02:48 AM
RE: 2048 Puzzle - by FellippeHeitor - 10-17-2024, 03:17 AM
RE: 2048 Puzzle - by bplus - 10-17-2024, 09:16 AM
RE: 2048 Puzzle - by Dav - 10-17-2024, 01:01 PM
RE: 2048 Puzzle - by bplus - 10-17-2024, 03:36 PM
RE: 2048 Puzzle - by Dav - 10-17-2024, 04:19 PM
RE: 2048 Puzzle - by bplus - 10-17-2024, 04:26 PM
RE: 2048 Puzzle - by SMcNeill - 10-17-2024, 05:05 PM
RE: 2048 Puzzle - by bplus - 10-17-2024, 05:15 PM
RE: 2048 Puzzle - by SMcNeill - 10-17-2024, 05:28 PM
RE: 2048 Puzzle - by Dav - 10-17-2024, 10:46 PM
RE: 2048 Puzzle - by bplus - 10-18-2024, 12:48 AM
RE: 2048 Puzzle - by Dav - 10-18-2024, 11:49 AM
RE: 2048 Puzzle - by bplus - 10-18-2024, 01:51 PM
RE: 2048 Puzzle - by bplus - 10-18-2024, 09:59 PM
RE: 2048 Puzzle - by Dav - 10-20-2024, 10:44 PM
RE: 2048 Puzzle - by bplus - 10-20-2024, 11:32 PM
RE: 2048 Puzzle - by bplus - 10-21-2024, 09:18 AM
RE: 2048 Puzzle - by SMcNeill - 10-21-2024, 10:19 AM
RE: 2048 Puzzle - by bplus - 10-22-2024, 11:37 AM
RE: 2048 Puzzle - by SMcNeill - 10-22-2024, 02:27 PM
RE: 2048 Puzzle - by SMcNeill - 10-22-2024, 02:39 PM
RE: 2048 Puzzle - by bplus - 10-22-2024, 03:26 PM
RE: 2048 Puzzle - by SMcNeill - 10-22-2024, 03:49 PM
RE: 2048 Puzzle - by SMcNeill - 10-22-2024, 03:36 PM
RE: 2048 Puzzle - by bplus - 10-22-2024, 03:38 PM
RE: 2048 Puzzle - by bplus - 10-22-2024, 04:37 PM
RE: 2048 Puzzle - by SMcNeill - 10-22-2024, 08:18 PM
RE: 2048 Puzzle - by bplus - 10-22-2024, 04:47 PM
RE: 2048 Puzzle - by SMcNeill - 10-23-2024, 03:44 AM
RE: 2048 Puzzle - by bplus - 10-23-2024, 10:32 AM
RE: 2048 Puzzle - by bplus - 10-23-2024, 12:40 PM
RE: 2048 Puzzle - by SMcNeill - 10-23-2024, 01:51 PM
RE: 2048 Puzzle - by bplus - 10-23-2024, 05:00 PM
RE: 2048 Puzzle - by bplus - 10-24-2024, 06:42 PM
RE: 2048 Puzzle - by Dav - 10-25-2024, 07:32 PM
RE: 2048 Puzzle - by bplus - 10-26-2024, 12:34 PM
RE: 2048 Puzzle - by Dav - 10-26-2024, 01:21 PM
RE: 2048 Puzzle - by bplus - 10-26-2024, 01:33 PM
RE: 2048 Puzzle - by bplus - 10-27-2024, 01:39 AM
RE: 2048 Puzzle - by bplus - 10-27-2024, 10:08 AM



Users browsing this thread: 3 Guest(s)