none
Twenty Five Line Challenge

    General discussion

  • Working on developing projects for my Intro to Programming class, I reminded myself of an article I read back in the early days of the PC. The article was in one of the first PC only magazines, and it was publishing the results of a contest the magazine sponsored. Preliminaries complete, here is what they did:

    They challenged their readers to come up with the most useful BASIC programs they could using only a single line of code in the BASIC interpreter. With the colon instruction separator you could easily get twenty commands on a single line. And the winning submissions were brilliant. One was a screen saver-esk art program, a second was a working word processor, and the third was a full sub chase game. I wish I could share the article and results with this group, but my net search for mention of the article turned up nothing.

    So, in the spirit of the early days of PC programming, here is my proposal to all of you:

    The 25 Line Small Basic Challenge!

    Give us your clever, entertaining, most creative best, but keep it under twenty five lines.

    To get the ball rolling I wrote a text based version of Rock-Paper-Scissors in 24 lines (25 if you count my comment). Import Code: CTB433
    Saturday, October 17, 2009 2:44 AM

All replies

  • Entering the spirit here is a swarm of bees at 25 lines, I guess I could loose the window title if it has to be under 25.  Import Code: MSH031.

    • Edited by litdevModerator Sunday, October 18, 2009 2:12 PM Bee image web address fixed
    Saturday, October 17, 2009 9:31 PM
  • Heres mine: RRS083

    its simulates something like an atom and the mouse is the core. I didnt look at litdevs bee project to make this. my code is really different from his anyway.

    i did this some time ago and just changed it so it fits in 25 lines of code. (the original version looks prettier and runs faster..)

    have fun!

    btw, litdev. does your code run fine on your computer?

    it lags on mine. but runs very good at 50 bees.
    Live for nothing, OR CODE FOR SOMETHING!
    Sunday, October 18, 2009 12:04 PM
  • Simple, nice (it's why I love Small Basic) and working: GQP876
    It draws Lissajous curves.

    Still thinking about something more interactive... ;)
    Grzesio
    Sunday, October 18, 2009 7:40 PM
  • Yet another one.
    Paint program: FNW050
    You can paint using your mouse and choose one of the 8 colors from the palette.
    Grzesio
    Sunday, October 18, 2009 8:50 PM
  • just a little swarm of flies:
    LNR359

    just move the mouse around, and you'll see.

    you can increase the number of flies much more!
    i was too lazy to comment the code this time..

    have fun!
    Live for nothing, OR CODE FOR SOMETHING!
    Sunday, October 25, 2009 6:17 PM
  • Here's your Rock-Paper-Scissors in 18 lines: CTB433-0
    Sunday, October 25, 2009 8:38 PM
  • heres another version of the swarm of flies. this time i did it with shapes.animating. i removed the zooming, but this version supports about 200 flies without lag on my computer!

    WKN366

    and heres another version, wich runs even faster, but the code is a bit crappier:

    RPW587

    have fun!
    Live for nothing, OR CODE FOR SOMETHING!
    Monday, October 26, 2009 4:35 PM
  • Got Rock/Paper/Scissors down to 9 lines. Import code: CTB433-1

    The code does this by a) utilising the fact that a command window is 80 characters wide, thus concatenating the first three lines of output into a single line of code and b) generating the array dynamically in only five lines.

    You may want to use the array generating trick in your own code for this challenge if you will need an array comprising of more than 5 items.

    Best,

    Jason.

    Friday, October 30, 2009 1:31 PM
  • wow! nice work man!
    Live for nothing, OR CODE FOR SOMETHING!
    Friday, October 30, 2009 2:55 PM
  • Very nice, Jason. 
    Friday, October 30, 2009 5:48 PM
  • So, my submission to this challenge is a 25 line Sudoku Solver.

    The code does have some limitations:

    1. The solver only works for unambiguous puzzles, where every number can be determined by using the core rules of the game (each row column and three-by-three grid must contain the numbers one through nine once only). The code is iterative rather than recursive and does not try speculative patterns and thus can only solve sudoku puzzles typically classified as easy.
    2. Each puzzle must be serialised for use in the solver. The solver expects an 81 character string (exactly) with no line-endings and spaces representing the squares to be solved.

    The solver works by assuming any square can contain any number one through nine, until it is demonstrated otherwise using the above rules. After checking all the dependant squares the solver determines if there is an unambiguous solution available, and if so applies it, before checking the next square in the grid. The grid is checked 81 times which allows for only a single square to be solved on each pass - if no square is solved on a complete pass of all squares this indicates that the puzzle needs more advanced logic to solve and it is thus safe to terminate regardless.

    If you ignore my gratuitous use of blank lines and the comments (including a couple of additional puzzles to try) the code weighs in at exactly 25 lines. I can shorten it to between 22-24 if required by rearranging the logic and removing an if-statement (making it significantly slower) or removing the blank lines in the output (which make it much more difficult to determine the solution from the steps displayed).

    The solver does always terminate, even if it can not find a comprehensive solution, and displays the incomplete solution that it manages to discern.

    There are a couple of interesting 'cheats' used such as using compound for-loops where the values of what would be nested loops are calculated on the fly using Math.Ceiling() and Math.Remainder() saving around 6 lines of code (at a very high price in performance) and a special or-condition which saves an additional two lines of code in the form of a separate if-statement. I have once again used dynamic generation of the array to create a 9-by-9 grid in only 6 lines of code.

    The solution is highly inefficient, and I suspect some of the Math.Remainder() calls could be factored to reduce their number, but this is the price you pay for brevity of length.

    After that immense build up, the import code is: CGW786

    Hope everyone finds this both amusing and educational.

    Best,

    Jason.
    Sunday, November 01, 2009 8:27 PM
  • Sub Hunt!

    My latest tiny opus: KDN168

    Complete with a graphic playing board. Be patient with the picture rendering, the photos have to be repeatedly loaded from flickr as there was no room for optimization.

    I found that writing this was highly entertaining. I hope you enjoy playing it and marveling at the ridiculously long lines of code.


    Friday, November 06, 2009 9:26 PM
  • wow! really nice!

    would have been nice if you could control it with the mouse...
    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, November 07, 2009 3:04 PM
  • wow! really nice!

    would have been nice if you could control it with the mouse...
    Live for nothing, OR CODE FOR SOMETHING!

    I've re-written Coding Cat's Sub Hunt to work with the mouse. :-)

    Import code: KDN168-0


    Ideally, I'd also swap the 'patrol area' to be a single 400x400 image and use one of the spare lines to show how many depth charges are left, which I couldn't do in this version.

    I also removed the line that moves the sub when you get a narrow miss.
    Sunday, November 08, 2009 10:56 PM
  • cool!

    nice work!
    Live for nothing, OR CODE FOR SOMETHING!
    Monday, November 09, 2009 5:50 PM
  • Very nice job of one upping me DW. :-)

    This is a lesson in tunnel vision and the need for code reviews. The original version I wrote was recreating a text based game from my early days on the PC. All of the changes I made were a play on that idea and an attempt to cram code into 25 lines. The idea using the mouse and loading the pictures as single pieces didn't even occur to me.

    I have put my current 25 line project on hold and have already started playing with your updated code. I should have a version with full mouse support and faster graphics in a few days. I should be able to drop the code down to about 20 lines... or add more to the game.

    Tuesday, November 10, 2009 6:45 PM
  • Here's a tip for you 25-liners:

      You can create an array in one line

    'setup card array
    cardValues = "1=One;2=Two;3=Three;4=Four;5=Five;6=Six;7=Seven;8=Eight;9=Nine;10=Ten;11=Jack;12=Queen;13=King"
    
    suit = "1= of Hearts;2= of Spades;3= of Diamonds;4= of Clubs"
    
    For I = 1 To 13
      r = Math.GetRandomNumber(4)
      TextWindow.WriteLine(cardValues[I] + suit[r])
    EndFor
    
    Tuesday, November 10, 2009 8:06 PM
  • Good trick, Rushworks!
    Tuesday, November 10, 2009 8:55 PM
  • hehe, hope you didn't mind Cool Cat.

    Actually, I realised yesterday that the code I uploaded isn't quite correct as there can only ever be two results: Either 'dpthChrg=10' or 'dpthChrg=11'. I'd coded it to allow for any number of remaining depth charges from 1 to 9, but as it's always set to 11 when the sub is hit, it's irrelevant.

    This means that the following two lines should be changed from my published version to these...

    finishMsg="10 "+Text.GetCharacter(10)+Text.GetCharacter(10)+Text.GetCharacter(10)+"   Depth charges depleted."+Text.GetCharacter(10)+"   The sub has escaped."+Text.GetCharacter(10)+"   You are responsible for the deaths of 5 billion people." + Text.GetCharacter(10) + Text.GetCharacter(10) + "11 " + Text.GetCharacter(10)+Text.GetCharacter(10)+Text.GetCharacter(10)+"   Bull's Eye!" + Text.GetCharacter(10)+"   You sank the sub." + Text.GetCharacter(10)+"   Billions praise you as the savior of humanity." +Text.GetCharacter(10)+Text.GetCharacter(10)

    and

    TextWindow.WriteLine( Text.GetSubText(finishMsg, text.GetIndexOf(finishMsg, dpthChrg)+2, 114)) 'Describe the outcome. Did we get the sub? Did the sub escape?

    Also, if you're re-doing the graphics, you could remove the instructions going to the text window and include them in the graphic which will save another line of code. In fact, with these savings, you should be able to do away with the text window altogether :-)

    Anyway, have fun!


    @RushWorks... cool, thanks for that array tip. Duh, I'd noticed arrays were stored like that, but it hadn't clicked to actually create them that way.
    Wednesday, November 11, 2009 1:49 AM
  • Got Rock/Paper/Scissors down to 9 lines. Import code: CTB433-1

    The code does this by a) utilising the fact that a command window is 80 characters wide, thus concatenating the first three lines of output into a single line of code and b) generating the array dynamically in only five lines.

    You may want to use the array generating trick in your own code for this challenge if you will need an array comprising of more than 5 items.

    Best,

    Jason.

    Hehe, Jason, I got your Rock/Paper/Scissors down to 3 lines.

    Import code: CTB433-2
    Wednesday, November 11, 2009 3:24 AM
  • Hehe, Jason, I got your Rock/Paper/Scissors down to 3 lines.

    Import code: CTB433-2
    Wow!
    Wednesday, November 11, 2009 3:36 AM
  • Yes, Wow. I was thinking on my drive home tonight that I could get the RPS code down to five or six lines by doing away with the array and accessing a string containing the values directly using the text commands. But this beats my idea.

    So you definitely win... This round. ;-)


    This exercise has reminded me of the programmers theorem:

    1) Every program can be reduced by at least one line
    2) Every program has at least one bug.

    By induction:
    -- Every program can be reduced to one line; which will be wrong.


    :-D
    Wednesday, November 11, 2009 3:49 AM

  • By induction:
    -- Every program can be reduced to one line; which will be wrong.

    And then to zero lines which makes it 100% bugless ;))
    Grzesio
    Wednesday, November 11, 2009 6:24 AM

  • By induction:
    -- Every program can be reduced to one line; which will be wrong.

    And then to zero lines which makes it 100% bugless ;))
    Grzesio

    ROCK-PAPER-SCISSORS, again. No, I haven't improved on 3 lines, lol, although I tried hard.

    As this forum is about learning as well as helping, I've published the R-P-S again but with comments to describe what is happening.

    New import code: CTB433-3
    Wednesday, November 11, 2009 4:18 PM
  • SBace-Invaders-25 : Import code: XDK444

    Here it is, Space Invader(s) in 20 lines!

    3 lives, increasing difficulties, skill ratings, awesome graphics ;-)

    What more can you ask for in under 25 lines?  Well, I've left you 4 lines to add your own features (possibly add more aliens, or make them fire back?). Enjoy.

    *EDIT* See below for updated version.
    • Edited by Davey-Wavey Tuesday, November 17, 2009 1:03 AM New version added below.
    Wednesday, November 11, 2009 11:14 PM
  • Davey-Wavey,

    While I do think your solution was utterly brilliant, not to be out done here is Rock-Paper-Scissors in only two lines: CTB433-5

    I do note that my 'solution' is possibly the most manual and verbose way of coding the game, but hey, it's vertically very short!

    Even though I doubt it can be done (due to the write-read-write cycle required), I'd love to see a one line version!

    As an aside, Rushworks, the manual serialisation of the arrays is a wonderful discovery and while I won't be using it in any of my normal coding (I doubt it is a 'supported' array generation technique) I am extremely impressed by its brevity.

    Best,

    Jason.
    Saturday, November 14, 2009 4:21 AM
  • Davey-Wavey,

    While I do think your solution was utterly brilliant, not to be out done here is Rock-Paper-Scissors in only two lines: CTB433-5



    Ha Ha, absolutely awesome, well done Jason.
    Saturday, November 14, 2009 4:14 PM
  • Davey-Wavey,

    While I do think your solution was utterly brilliant, not to be out done here is Rock-Paper-Scissors in only two lines: CTB433-5



    Ha Ha, absolutely awesome, well done Jason.

    You guys are absolutely incredible.  I had never imagined this being possible in Small Basic :)

    Sunday, November 15, 2009 12:42 AM
  • Well, feeling inspired by our new found stardom in Vijaye's blog, I went back to play with my SBaceInvaders-25, and I proudly present...

    SBace-Invaders-25 v2:

    Now there's 5 aliens to pit your skills against, and they're not just sitting there, they're coming to get ya!
    I've sorted the bullet 'bug' (well, it bugged me) so now you can only kill one alien with each bullet.

    Oh yeah, and I figured that I'd cut it down to only 18 lines of code while I was at it, hehe, so you've got plenty of room to add new features.

    See v2 here: http://smallbasic.com/program/?SPR072 - it is heavily commented, which I'm not counting in the '18' lines.

    Or import it to play: SPR072
    Tuesday, November 17, 2009 12:53 AM
  • Not wanting to be left out of the festivities I hereby submit the update for Sub Hunt. Version 2.0 expands on DW's idea of using the mouse to hunt down the sub. Also, everything is image based, the pictures load in sheets rather than tiles,  and transparency in png files is used to layer the splashes. All of this does away with the textwindow entirely.

    Import: KDN168-1

    I also posted a fully commented version of the game with four extra lines that separates out the math making the logic easier to follow.

    Import KDN168-2

    Enjoy... on to my next idea.
    • Edited by Coding Cat Tuesday, November 17, 2009 9:10 PM
    Tuesday, November 17, 2009 8:09 PM
  • Ah, this is great! Congratulations on the amazing entries so far!

    Here's my submission: CCN060

    It's a 24 line 3D renderer that displays a rotating triangle based model.
    As an example I've included the definition of a triangular piramid, mostly because it's the 3D shape with the fewest triangles ;) . Theoretically it can draw any convex model though, so I'll try and make something a bit more interresting.

    Edit: Make that any convex model. There's no hidden surface removal, obviously.

    Update:

    Image and video hosting by TinyPic

    Here's a new version containing a (somewhat glitchy) model of the Arwing from StarFox (StarWing in Europe): JNV862 (updated )

    As I mentioned above, the program can only render convex models, i.e. no part of the model may overlap with another. The Arwing model does not meet this requirement. By carefully sorting the triangle list I've made sure that the inner triangles of the blue sections (the triangles facing towards the main body of the ship) are draw first, then the grey body, and lastly the outer triangles of the blue sections (the triangles facing away from the main body). This means that the innner triangles of the blue sections are always overdrawn by the body of the ship, and the body of the ship always overdrawn by the outer triangles of the blue sections. A sort of primitive Painter's Algorithm. This approach is by no means perfect, as you can see from the glitchy result, but at least it doesn't even require a single line of code ;) .
    • Edited by ThirdMagus Thursday, November 19, 2009 8:00 PM
    Tuesday, November 17, 2009 8:39 PM
  • now this sucks.


    just kidding! this is one of the coolest projects ive seen so far! this beats the pants off  my 3d projects!
    really awesome!
    Live for nothing, OR CODE FOR SOMETHING!
    Thursday, November 19, 2009 6:22 PM
  • Of course, getting my matrix multiplications right does help. Here's another update (hopefully the last): JNV862

    Thanks to me screwing up basic linear algebra the previous version didn't actually do any perspective projecting... I messed around with the model and viewer distances as well, I think it looks okay now. And finally I've increased the window size to 800 x 600.
    Thursday, November 19, 2009 7:58 PM
  • I just made an Imagesaver, wich saves an image to a textfile, wich can be loaded with the imageloader.

    Imagesaver:
    VQS181 (the imagesaver saves an image to a textfile, wich can be loaded with the imageloader after that. and it can have much less lines, but i didnt want to make it have less lines...)

    Imageloader:
    SKK869 (WARNING! YOU NEED TO HAVE RUNNED THE IMAGESAVER AT LEAST ONCE FOR THIS TO WORK! i know, when you zoom the image, it becomes "transparent". thats because i didnt code it to duplicate the pixels. maybe someone wants to?^^)


    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, November 21, 2009 8:05 PM
  • is this thread dead or what?
    Live for nothing, OR CODE FOR SOMETHING!
    Thursday, November 26, 2009 6:26 PM
  • I am entering my pebble guess game, it is very basic, i am still a very novice programmer, around 20 lines i believe
    code MRR315
    it is, like i said, very basic
    Sunday, November 29, 2009 1:24 AM
  • This might be of some interest to you all, basically you type in a name or phrase or word and it works out what the value of that name wor of phrase is

    Import Code: JHK469-0
    Link: JHK469-0
    Tuesday, December 01, 2009 4:35 PM
  • neat app
    Wednesday, December 02, 2009 1:32 AM
  • lol!

    nice idea!
    Live for nothing, OR CODE FOR SOMETHING!
    Thursday, December 03, 2009 10:00 PM
  • I was looking for a programming environment that I could use to teach my 11 year old daughter the basics (excuse the pun) and I came across Small Basic and then this post. So I thought I would give small basic a quick spin. Nothing original, but here is a line drawing program with a color palette.

    Code ID: RFL372
    http://taylorza.blogspot.com
    Sunday, December 06, 2009 3:31 PM
  • Really nice app Taylorza :)
    My FNW050 did similar thing but your "paint" looks more user friendly.

    Grzesio
    Sunday, December 06, 2009 6:31 PM
  • Thanks Grzesio, I think SmallBasic is going to be ideal teaching tool for my kids, but right now I am enjoying it :).
    http://taylorza.blogspot.com
    Monday, December 07, 2009 6:22 PM
  • Probably most of us begun adventure with IT from 8bit BASIC so SmallBasic is the perfect toy for us ;)
    Grzesio
    Monday, December 07, 2009 7:58 PM
  • here's a color palette:
    QJP611

    its got a mistake... it just displays 3 colors.. but when you look at the textwindow, it should show all of them, shouldnt it?
    Live for nothing, OR CODE FOR SOMETHING!
    Friday, December 18, 2009 8:31 PM
  • here's a color palette:
    QJP611

    its got a mistake... it just displays 3 colors.. but when you look at the textwindow, it should show all of them, shouldnt it?
    Live for nothing, OR CODE FOR SOMETHING!
    You have three loops, but only use two of them for coords, so it draws over the same spot.
    This shows more clearly what's going on: QJP611-1
    Saturday, December 19, 2009 7:41 AM
  • ohh...

    i see... thx!

    do you know a way tto make a nice color transition with all the colors (0-255)?
    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, December 19, 2009 1:27 PM
  • Here's my imageloader in 14 lines!
    QFR228

    put this file: http://cid-429dcdb86b9de3e6.skydrive.live.com/self.aspx/.Public/Imageloader/imhappyplz.txt in the same folder as the imageloader.
    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, December 19, 2009 1:55 PM
  • Ok, so my first submission was, terrible, so i am trying again, in 15 lines, this program automatically generates a sentence based off of some of the core parts of speech, so nouns don't make sense,  but they are not supposed to.
    Import Code
    WVS274

    I am still a novice programmer
    Saturday, December 19, 2009 6:01 PM
  • Ok, so my first submission was, terrible, so i am trying again, in 15 lines, this program automatically generates a sentence based off of some of the core parts of speech, so nouns don't make sense,  but they are not supposed to.
    Import Code
    WVS274

    I am still a novice programmer
    i improved it a bit and it has 14 lines now..

    WVS274-0

    btw, i guess you could reduce the code by 4 more lines if you save all the words in one variable. and then you get a random number for a noun from words 1 to 10 for example. i hope you know what i mean.. you can do it if you want..

    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, December 19, 2009 6:26 PM
  • WVS274-0

    btw, i guess you could reduce the code by 4 more lines if you save all the words in one variable. and then you get a random number for a noun from words 1 to 10 for example. i hope you know what i mean.. you can do it if you want..

    Live for nothing, OR CODE FOR SOMETHING!

    You could reduce it down to 4 lines if you really wanted it condensed, or 3 lines if you wanted to go wild, or even 1 if you got rid of the loop!  But why fix it when it's not broken :-)
    Saturday, December 19, 2009 10:56 PM
  • impossible to do in 1 line...
    Live for nothing, OR CODE FOR SOMETHING!
    Sunday, December 20, 2009 12:32 AM
  • impossible to do in 1 line...
    Live for nothing, OR CODE FOR SOMETHING!

    Hey Dudeson,

    Here's a hint to get you started :-)

    TextWindow.WriteLine( Text.GetSubText("1=Igor      2=Megan     ", (Text.GetIndexOf("1=Igor      2=Megan     ", (Math.GetRandomNumber(2)+"="))+2), 10) )


    As I said, you'd only do it if you 'wanted to go wild', and it would be one heck of a long line, but it IS possible!
    Monday, December 21, 2009 1:19 AM
  • omg..

    ok.. i'll shut up..

    i didnt know that .. i dont know how to use most of the text functions anyway..
    Live for nothing, OR CODE FOR SOMETHING!
    Monday, December 21, 2009 2:29 PM
  • Is this still open?
    Because I want to enter mine.
    It's an Image to ASCII converter.
    I just managed to squeeze it down to 25 lines (excluding the comment at the top).
    Import Code: PCM483

    Due to the fact that I had to remove certain lines, it works a bit slow, and I'm recommending not to use big pictures.
    The default picture at the moment is the small basic icon, if you see how big it turns out to be you will understand.
    Wednesday, December 30, 2009 11:28 PM
  • Nice code! i changed the image url to test if it did work (i used your forum image) and it did ! nice one!
    Wednesday, December 30, 2009 11:32 PM
  • OMG! im really impressed!
    nice work! i never knew this was possible in sb!

    it also runs very fast for me! about 1 second to calculate the image. (maybe you meant it just runs slow for other pictures than the one included..)
    Live for nothing, OR CODE FOR SOMETHING!
    Friday, January 01, 2010 4:13 PM
  • it also runs very fast for me! about 1 second to calculate the image. (maybe you meant it just runs slow for other pictures than the one included..)
    Ha ha, maybe I just have a slow computer...

    I realized that I have made an error in it as well.
    The improved one is here, it's just two minor errors: WLW146
    The trouble with it is the fact that Small Basic doesn't support individual RGB components.
    So I have 14 lines of code to just get those individual components.
    Other then that, well including that, it's all quite simple.
    Friday, January 01, 2010 9:03 PM
  • nice! nice!

    but why is the ascii image always so horizontally scrunched?
    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, January 02, 2010 5:35 PM
  • It's horizontally scrunched because letters are taller then they are wide.
    So if every pixel is replaced by a letter, then the picture will end up being scrunched.
    Saturday, January 09, 2010 12:57 AM
  • ahh.. i see..

    do you want to fix it?
    Live for nothing, OR CODE FOR SOMETHING!
    Monday, January 11, 2010 7:47 PM
  • I deleted my other entry, had a lot of unneeded code.
    It is a random string generator, where you can choose the numbers/letters/symbols and how long you want it to be.
    It gives you the string, and the calculation time
    Here is revised version: GJJ034 (OLD)
    Revised again: QTH420
    • Edited by Dapezboy Thursday, February 11, 2010 11:03 PM
    Saturday, January 23, 2010 11:09 AM
  • Greetings every one. Here is my latest submission for the Challenge:

    An Analogue Clock in 24 lines. Works perfectly and I was surprised how easy it was to write. Two issues, which I welcome input on solving: 1) The flashing is caused by the need to clear the screen. The anti-aliasing causes rendering errors when the lines are written over, and the less invasive solutions (like drawing a fill-ellipse over the face) do not work because the turtle works on a different layer from the other graphics commands. 2) There is an issue with the turtle system that causes the little guy to slow down to a crawl after a few minutes. This will eventually cause the clock to become difficult to read.

    But like I said, it works. And it is pretty slick even if I do say so myself. ;-)

    Import code: JQX269
    Saturday, January 23, 2010 4:59 PM
  • Greetings every one. Here is my latest submission for the Challenge:

    An Analogue Clock in 24 lines. Works perfectly and I was surprised how easy it was to write. Two issues, which I welcome input on solving: 1) The flashing is caused by the need to clear the screen. The anti-aliasing causes rendering errors when the lines are written over, and the less invasive solutions (like drawing a fill-ellipse over the face) do not work because the turtle works on a different layer from the other graphics commands. 2) There is an issue with the turtle system that causes the little guy to slow down to a crawl after a few minutes. This will eventually cause the clock to become difficult to read.

    But like I said, it works. And it is pretty slick even if I do say so myself. ;-)

    Import code: JQX269
    not bad!

    but i dont see a reason to do this with the turtle...
    btw, you did a quite complex angle calculation^^

    i'll see what i can do!

    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, January 23, 2010 5:01 PM
  • Okay.
    Heres my Analogue Clock in 14 lines: JQX269-0

    this might not be the best solution, and the hands dont affect each other. that means:
    if its 6:30 for example, the hour hand isnt between 6 and 7 but on 6...

    i'll fix that maybe ..
    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, January 23, 2010 7:01 PM
  • I redid my clock again!
    here it is in 12 lines!

    JQX269-3
    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, January 23, 2010 8:10 PM
  • Greetings every one. Here is my latest submission for the Challenge:

    An Analogue Clock in 24 lines. Works perfectly and I was surprised how easy it was to write. But like I said, it works. And it is pretty slick even if I do say so myself. ;-)

    Import code: JQX269
    not bad!

    but i dont see a reason to do this with the turtle...
    btw, you did a quite complex angle calculation^^

    Coo-dos on  your solutions Dudeson. They are elegant and straight to the point.

    And Thanks for the compliment. The reason I used the turtle commands was to keep the calculations simple. This project was inspired by a students idea and I wanted to show that it could be easily cobbled together. By using the turtle commands it only took was a little arithmetic to get the angles right. Using the line drawing commands would require some trig and a fair knowledge of polar the whole coordinate plane thing. In other words, its a solution that anyone could understand.


    Saturday, January 23, 2010 8:24 PM
  • Coo-dos on  your solutions Dudeson. They are elegant and straight to the point.

    And Thanks for the compliment. The reason I used the turtle commands was to keep the calculations simple. This project was inspired by a students idea and I wanted to show that it could be easily cobbled together. By using the turtle commands it only took was a little arithmetic to get the angles right. Using the line drawing commands would require some trig and a fair knowledge of polar the whole coordinate plane thing. In other words, its a solution that anyone could understand.



    ok cool^^

    you should check out the updated version i just posted. its a bit simpler..

    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, January 23, 2010 8:31 PM
  • Clock UPDATE:

    I fixed the hour and minute hand issues: HZF709

    damn.. why do i have the feeling that this could be even shorter??

    [UPDATE]

    YESS!! i managed to get rid of another line! so it has just 11 lines now!
    XSB692

    this line here seems very suspicious to me ("could be shorter"-suspicious):
    Shapes.Remove(Hand[i])
    Hand[i] = Shapes.AddLine(150,150,150+Math.Cos(Math.GetRadians(Angle[i]))*(100-i*10*i/2),150+Math.Sin(Math.GetRadians(Angle[i]))*(100-i*10*i/2))


    Live for nothing, OR CODE FOR SOMETHING!
    Monday, January 25, 2010 8:25 PM
  • ANOTHER UPDATE!

    heres the clock in just 9 LINES!

    PWV279

    [UPDATE]

    Here's an a bit optimized version:
    PWV279-0


    Live for nothing, OR CODE FOR SOMETHING!
    Monday, January 25, 2010 10:24 PM
  • Heres a simple 3D wireframe model:

    25 Line version (much faster ): [UPDATED]
    RTQ437
    set the "Corner_Amount" and "Radius" to what ever you like!

    10 lines version (much slower ): [UPDATED]
    TCM178-0

    Have fun!
    Live for nothing, OR CODE FOR SOMETHING!
    Tuesday, January 26, 2010 4:48 PM
  • here is my effort MNG692 . Includes a handy explosion subroutine. (code corrected)
    • Edited by oldgrandadjoe Saturday, January 30, 2010 3:18 PM code corrected
    Saturday, January 30, 2010 3:00 PM
  • I believe it might be MNG692.
    Saturday, January 30, 2010 3:20 PM
  • here is my effort MNG692 . Includes a handy explosion subroutine. (code corrected)
    is it possible that your code has a little more lines than 25? ^^

    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, January 30, 2010 3:22 PM
  • yep - got carried away
    Saturday, January 30, 2010 3:27 PM
  • yep - got carried away
    well.. this is the 25 line challenge.. not 30 line challenge..

    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, January 30, 2010 3:29 PM
  • I have got my bomb down to 24 lines - MNG692-1
    Monday, February 01, 2010 12:24 PM
  • Another one for the stack: HGM633

    The game Snaking.

    The snake starts coiled in the top left corner and grows by a segment every half second. The goal is to last as long as possible without colliding with the edges of the window or another part of the snake itself. Bonus points for catching the triangular target.

    The interface was kept purposely simple with the default blue shapes. I didn't want the pauses and confusions that having pictures for body segments or a background would have caused. I have been working in this one since November. Getting the collision system to work quickly, consistently and stay under 25 lines was a bit of a trick. Good luck figuring it out.

    My high score is just over 32000. Have fun.
    Tuesday, February 23, 2010 10:01 PM
  • Another one for the stack: HGM633

    The game Snaking.


    Wow, fantastic job Coding Cat - some nice techniques in there to take note of.

    Your high score is a piece of pants though ;-) as the score increases right from the beginning even before you start to move the snake. Just hang around for 5 mins and your score is history! :-)

    Anyway, to make the snake move right from the start, add this at the beginning of your vals array:  none= 0 1;
    As there is no graphicswindow.lastkey at the start of the game, 'none' is reported, so this adds that 'keypress' into your array which forces a move to the right.
    Tuesday, February 23, 2010 11:54 PM
  • That is a great idea DW that did not occur to me. There is a catch though; it doesn't work. For some reason when you put the None entry in the array, it forces the triangle target into the 0,0 position of all other new shapes. I could fix this with a another line below the definitions that relocates the initial location of the target... but after spending so long shrinking this program, the last thing I want to do is add a line. :-)
    Wednesday, February 24, 2010 2:29 AM
  • There is a catch though; it doesn't work. For some reason when you put the None entry in the array, it forces the triangle target into the 0,0 position of all other new shapes. 

    CC, it's not actually the inclusion of 'none' that is causing the error, but the auto-movement of the snake.  Even before putting the 'none' in, the triangle always started at 0,0 but as the snake wasn't moving then it would eat the triangle therefore forcing it to move to a new random position.

    The reason the triangle *always* appears at 0,0 is because you are trying to both set the array variables tx, ty *and* read them in the same line, which always returns 0,0. The only way to make this issue less apparent is by hard-positioning the starting place of the triangle rather than trying to calculate a random position for it.

    I was going to say...

    To make it hard-positioned (say at 120,120), just change the bit in line 1 to: 
    target=" + Shapes.AddTriangle(120 + 5,120 + 0,120 + 0,120 + 10,120 + 10,120 + 10) + ";

    however, that stops the collision detection with the triangle from working.  I'll look into it a bit more and see if I can work it out.

    *EDIT*

    CC, I've posted a new version, and cut the line-count down to 23! ... HGM633-1
    (although I did sneak an optional line in there which is commented out, so I'm not counting it in the total!)

    My idea above wouldn't work due to SmallBasic's handling of triangles, so I rethought it.
    I've added a few comment lines to show what I've changed. The target now moves from the beginning; I've combined both collision detections with an elseif (to save 1 line of code); I've tweaked the scoring slightly due to the hack for the 'target' giving an immediate bonus; I've tidied up the array variable slightly; and I've (mostly) stopped the 'lazy' segment from lingering at the top-left corner.

    Very impressed with your coding on this though, nice one. Particularly like the use of the titlebar as a variable to hold the score.
    Friday, February 26, 2010 1:33 AM
  • This is only 14 lines. 
    Thursday, March 04, 2010 12:28 AM
  • Will Small Basic Programs Be Accepted Into The Blog Even If They Require An Extension? http://smallbasic.com/program/?BXQ947 Requires The FC Extension (http://tinyurl.com/ydze8u9
    Thursday, March 04, 2010 5:50 PM
  • I like small basic very much.
    This program calculates Fibonacci Number. I feel I exercise how to use stack, push and pop.

    Import Code : MCC787
    Friday, March 12, 2010 1:06 PM
  • jug_wady,

    Clever use of stack and recursion.

    This is the simple way which is less inventive.

    fib[0] = 0
    fib[1] = 1
    For i = 2 To 20
      fib[i] = fib[i-1] + fib[i-2]
    EndFor

    For i = 0 To 20
      TextWindow.WriteLine("param=" + i + ", value=" + fib[i])
    EndFor
    Friday, March 12, 2010 9:12 PM
  • Oh! It is a beautiful code, and I am amazing no push / pop is used. :-)
    Saturday, March 13, 2010 2:57 AM

  • Is this still open?
    Because I want to enter mine.
    It's an Mandelbrot program.
    I just managed to squeeze it down to 25 lines.
    Import Code: WXZ755

    It runs very slow.

    Monday, March 22, 2010 8:32 PM
  • Slow but Nice.

    Very slightly modified to be colourful - Import WXZ755-0

    Tuesday, March 23, 2010 10:02 PM
  • Thank you litdev  It was very kind of you to make the program more colorful.  I had been working on a color version.  Your small modification is a lot more elegant than what I was working on.  This forum is a wonderful resource for someone like me who is still trying to learn the Small BASIC language.

    You guys are the best!

     


    Wednesday, March 24, 2010 11:27 AM
  • A trick to speed it up if you are interested is:

    1] Graduate it to VB using the Graduate button in the Small Basic interface - you first need Visual Basic Express (free).

    2] Replace the Primitive type with Double type at the top of the VB variable declarations.

    Dim y, b, x, a, v, w, i, c, d As Double

    At least *20 faster

    Wednesday, March 24, 2010 9:26 PM
  • A program that uses fremy's extensions and allows you to shuffle through wallpaper's located on your computer.

    TLQ850

    Monday, March 29, 2010 11:42 PM
  • Thank you litdev for the advise.  I have tried repeatedly but I can not do anything in Visual BASIC Express.

     

    If Small BASIC is compiled rather that interpreted why is it so much slower that Visual BASIC.  I would have thought the result from either language would run at near assembly language speed.  Do you think Microsoft is keeping Small BASIC hobbled for some reason?

    Tuesday, March 30, 2010 10:56 AM
  • I very much doubt anything in SmallBasic is deliberately hobbled, however performance is not its priority at all.  Certainly larger arrays and the Primitive data type are slow compared to pure VB or other .Net program.  For example the SB arrays are actually a dictionary map rather than true array (i.e. they can be indexed by anything, including strings, hence for the compiler to 'find' an entry in the array requires significantly more searching than by just using an integer index), and the Primitive data type covers integers, reals, strings and others in order to keep the syntax simple and not have to specifically 'type' data variables - this requires type checking and conversion as required internally.

    If you have VB Express installed, the 'Graduate' feature of SmallBasic should do 90% of the work for you converting the file to run in VB.  The reason this feature is there is to ease and encourage the progress from SmallBasic to other more powerful, but larger and more complex languages like VB.

    If you want to continue learning with SmallBasic, great.  I wouldn't have normally suggested the Graduate, except in this case it makes such a significant difference and is a relatively short example.

    If you want help with this Graduate, then say what you have done so far and what issues you have and someone will help - if you take this route, then I suggest starting a new thread, rather than clogging this one - Good Luck.

    Tuesday, March 30, 2010 8:13 PM
  • Wow that mandelbrot thing is awesome!!!

    I was doing something and ended up needing a dec to hex converter and decided to see how far i can cut it down. It works in 3 lines and will convert a single decimal byte value to hex, so 0 tp FF

     

    TPQ127

    Thursday, April 08, 2010 9:20 PM
  • This my programm from Russia. I am 9 years old and I am studying Small Basic.

    BXQ447

    Good luck.

    Wednesday, April 21, 2010 8:43 PM
  • Good job Alex!

    Two additions from my side:

    1. use "black" not "blace".

    2. you may set your initial turtle position using width/2 and height/2. It makes further window resizing simpler.

     

    And some day try to paint similar patterns without turtle. It may be harder but it's worth trying.


    Grzesio
    Wednesday, April 21, 2010 9:23 PM
  • Alex, Very creative, it reminds me of those pictures you could make by painting black over some coloured wax drawing, then scraping off the paint in a pattern.

    Wednesday, April 21, 2010 9:38 PM
  • program id: NCK373. VERY pointless program
    -Phillip
    Thursday, April 22, 2010 12:18 AM
  • Thank your for your comments.

    This is my small programm "Clock" XRS775.

    Good luck.

     

    Thursday, April 22, 2010 7:54 PM
  • Hello Alex!

    I hope you'd like to hear our suggestions :)

    Your programs are OK (and they work OK!) but there's some place for improvements.

    1. Try to avoid "goto" statement in your apps. I know it works I know it makes sense in this case and I know it's typical for BASIC programs. But if you are thinking about more "serious" languages some day you will see why it isn't so nice.
    2. You iterate trough main loop very frequently causing high CPU usage. If you add a counter inside your loop you can see how fast it is increasing. Maybe it makes sense to stop execution after each pass using Program.Delay() ? 100ms is ok - it frees CPU but makes your clock still working nicely.
    3. Adding "/something" to path variable makes double "/" characters in the resulting path. Usually it doesn't matter but it's a mistake in your code.

    Hope it helps you writing your programs.


    Grzesio
    Thursday, April 22, 2010 8:40 PM
  • Hello Grzegorz Tworek!

    Thank your for your suggestions.

    I only have started to program and I don’t understand some things yet. Therefore your remarks and sentences so are important for me.

    1.      About Goto operator I know. My daddy spoke about it, but here it has good approached. In the new version I have substituted its another operator - While Clock operator. Year< 2100. But probably it is a question of issue. My daddy has shown me as it is possible to be saved of Goto operator.

    2.      About delay of the program I did not know, thanks, I will try to sort it out myself.

    3.      Superfluous / it is my carelessness, thanks,next time I will be more attentive.

    If it does not complicate you to express an opinion about my programs, it would be interesting in what follows too.

    Friday, April 23, 2010 7:17 PM
  • Hi!

    This my programm for generating labirints. My full version with generating labirint, I will post later in another theme. I'm sorry my programm without comments. I am not good in English. 

    HZB686

    Good luck.

    Tuesday, May 11, 2010 6:12 PM
  • Hi!

    This my programm for generating labirints. My full version with generating labirint, I will post later in another theme. I'm sorry my programm without comments. I am not good in English. 

    HZB686

    Good luck.

    Alex, very cool.

    Hope you don't mind, but I rewrote it in 9 lines (although I did leave out the window resize prevention) and made the labyrinth larger by leaving out the window height setting: HZB686-0

    It doesn't work properly in silverlight, but here's the location to see the code: http://smallbasic.com/program/?HZB686-0

    Tuesday, May 11, 2010 8:05 PM
  • Very cool.  Next step - Pacman!
    Wednesday, May 12, 2010 3:47 AM
  • Alex, very cool.

    Hope you don't mind, but I rewrote it in 9 lines (although I did leave out the window resize prevention) and made the labyrinth larger by leaving out the window height setting: HZB686-0

    It doesn't work properly in silverlight, but here's the location to see the code: http://smallbasic.com/program/?HZB686-0


    Hi, Davey-Wavey!

    You did it very cool!!! I am studing yet and you comments very interesting for me. Hope you don't mind if I use your code in my next programm ;-)

    Wednesday, May 12, 2010 8:50 AM
  • Hope you don't mind if I use your code in my next programm ;-)

    Alex, certainly don't mind. That's why this forum is here, to offer suggestions, improvements and help. 

    By the way, I don't actually understand what the variable d is doing, but you'll see that it is mainly being calculated using the same calculation as in your original version. I am just using math.floor() instead of your If x=2 checks to give me a value of 1 when the loop variable equals the value 2. 

    I wrote a similar maze program in excel a while back. I may recode that into SB and post it in the forums at some point. 

    Wednesday, May 12, 2010 2:47 PM
  • I wrote a similar maze program in excel a while back. I may recode that into SB and post it in the forums at some point. 


    It will be great. I like solving labirints very much.

    By the way, me and my Dad don't understand what the variable d is doing, too :-) This algorithm we find in old programming book.

    Wednesday, May 12, 2010 8:51 PM
  • Here is my contribution with a hangman game.

    http://smallbasic.com/program/?SLH362

    I'm sure it can be optimized, but thanks to the array syntax (array = "1=foo;2=bar") I managed to make it in 25 lines.

    The only thing is that there is no end...

    SLH362

    Saturday, May 15, 2010 10:44 PM
  • Some of you may recognize me from an earlier post asking about some arrays and my screenChange program. Thanks for the help there!

    Well recently, when working on my project I'm doing in Small Basic I found I was generating multiple good sized arrays. So I got to thinking about writing an array generating program. Better yet, I wrote two.

    The first one is a single dimensional array generator that uses input in the text window to generate an array for you to copy. Since its in a command prompt style window you can't copy immediately. Simply click the command icon in the upper left corner of your TextWindow and click on properties. There check the quickedit box and go back to your TextWindow. Now you can highlight your text. Once all of your array is highlighted hit enter and paste it in your program!

    ZZN203

    My second one was a simple improvement. I added another couple lines to allow my program to generate a multi dimensional array for you.

     KCK324

     

    Both of these simply ask the user to input the array's name, and the number of rows and columns. Also, I added in a restart process where if you type in "y" or "Y" and enter the program will restart so you never have to close and reopen it. Enter any other value into that section and the program will simply end.

    Tuesday, May 18, 2010 10:34 AM
  • The first one is a single dimensional array generator that uses input in the text window to generate an array for you to copy. Since its in a command prompt style window you can't copy immediately. Simply click the command icon in the upper left corner of your TextWindow and click on properties. There check the quickedit box and go back to your TextWindow. Now you can highlight your text. Once all of your array is highlighted hit enter and paste it in your program!

    ZZN203

    My second one was a simple improvement. I added another couple lines to allow my program to generate a multi dimensional array for you.

     KCK324

    Marek, nice idea.

    Hope you don't mind, but I've rewritten it slightly: KCK324-0

    It now creates either 1D or 2D arrays and stuffs the new array into the clipboard.  After running the program, simply Paste (Ctrl V) into your code to get the generated array.

    Wednesday, May 19, 2010 4:02 PM
  • :P new edition of RockPaperScissors now with looping and text coloring.

    CTB433-23

    • Edited by Kroltan Tuesday, May 25, 2010 11:53 PM oops forgot id
    Tuesday, May 25, 2010 11:52 PM
  • Hi all,

    just found the Small Basic only two days ago. I love it. Still exploring the possibilities and here's my first program - the BrainFX language interpreter in 25 lines with some samples included. Hope you will like it.

    BJL054

    David

    Wednesday, June 16, 2010 12:23 AM
  • BrainF***

    Ooops, sorry for the four letter word. I was not sure, but I thought it might be fine if used in the original context.

    David

    Wednesday, June 16, 2010 7:37 AM
  •  BrainFX language interpreter in 25 lines with some samples included. Hope you will like it.

    BJL054

    David

    Erm, never heard of it.  What's the point of it?
    Wednesday, June 16, 2010 10:08 PM
  • I just picked up small basic this week, been having a blast going through the tutorial. Here's my rendition of Rock, Paper, Scissors: VMC577. Very simple, very basic.

    Edit: I made a goof in the code, it still works, but the logic behind doesn't make sense. See if you can spot it!

    Edit2: Nvm, there's a lot wrong with it, help?

    Saturday, June 26, 2010 4:30 PM
  • i have multiple entries

    -XXV212

    this is a simple text drawer it takes a random colour and fontsize and writes your text werever you click

    -GSN866

    this is a coin flip simulator

    -TDZ928

    a guess the number game

    -ZRH103

    this is a random circle drawer

    -QBC675

    this is supposed to be a target drawer but is cool when you set it to draw circles close together

    thanks guys and please bear in mind  im new at this and if these programs  seem bad/have been done before    theres not much i can do until i improve thanks.

    Thursday, July 08, 2010 5:52 PM
  • This is 25-line Keyboard. Program ID is ZWF718.
    Wednesday, July 21, 2010 1:06 PM
  • Very nice Nonki.
    Wednesday, July 21, 2010 7:57 PM
  • This is 25-line Keyboard. Program ID is ZWF718.

    Very cool, Nonki.
    Thursday, July 22, 2010 5:59 AM
  • Very nice, wandering whether a auto detect keyboard layout is possible ... mine has AZERTY ....
    Friday, July 23, 2010 4:30 PM
  • RonnyVB,

    This is not auto detect, but AZERTY version of keyboard.  The program ID is ZWF718-0.

    I hope this will work with your keyboard.  I only tested this with my QWERTY.

     

    Sunday, August 01, 2010 2:11 PM
  • Solomon,

    In SmallBasic, click on the Import button on the toolbar, then paste or type in that code.  It will load the program from the microsoft server.

     

    Sunday, August 08, 2010 12:06 PM
  • Wow that mandelbrot thing is awesome!!!

    I was doing something and ended up needing a dec to hex converter and decided to see how far i can cut it down. It works in 3 lines and will convert a single decimal byte value to hex, so 0 tp FF

     

    TPQ127


    New shorter version, SRB543 or http://smallbasic.com/program/?SRB543 using GraphicsWindow.GetColorFromRGB().
    Friday, September 03, 2010 1:42 PM
  • Here's my 1-line dictionary:

    JCT146

    Saturday, October 09, 2010 3:37 AM
  • I was feeling a little nestalgic today, and recreated my entry in the original contest whoa those so many years ago... at least it would have been my entry if I had heard about the contest before it was over.

    Import Code: MQT592

    Rnds -- Random boxes.

    It took 24 lines to accomplish what I did in one line. Gotta love progress.  :-)

    Saturday, October 09, 2010 9:59 PM
  • Here's my 2-line guess the number game:

    XXC593

    Sunday, October 10, 2010 4:32 AM
  • I have nothing against the extensions; From a learning stand point they make the topic more fun. Personally I wish someone with some free time would write a client/server extension for Small Basic.

    But I have to call foul on the play. The idea with this thread is to write something in 25 lines given the tools of Smallbasic by itself. The games that we have play with the arrays have kind of pushed the limit... but I think this goes too far.  :-)

    Can you rewrite it without fremies extension?

    Sunday, October 10, 2010 6:56 PM
  • There is Client/Server extension for Small Basic Called Data Extension.
    Sorry My Bad English
    Sunday, October 10, 2010 8:07 PM
  • Okay, here's the re-writen guess the number game in 5 lines (took out all unnessicary stuff and has no extensions):

    import code: TGQ394

    Sunday, October 10, 2010 8:22 PM
  • A notepad program in 11 lines when not including comments

    import code: PSV120

    Sunday, October 10, 2010 8:35 PM
  • I know it's been done, but here's a quick Analog Clock.  In 22 lines it:

    • Creates tick marks for each hour/minute (built during the first minute)
    • Has accurate hour/minute/second hands
    • Renders visually differentiated hands
    • Minimal resource use

    Functional code is 6 lines, the rest is presentation.

    Import Code: QJL661

    Live Link: http://smallbasic.com/program/?QJL661

     

    Friday, November 05, 2010 10:49 PM
  • This is Nowhere near 25 lines but try it and remember keep things simple, You can find all of the cheats in the code if you get really stuck. DJH340
    Tuesday, January 11, 2011 7:09 AM
  • This is my first non tut attempt. GNM401 It's a program that brings up a window to the US Current weather from weather.com.
    Sunday, January 16, 2011 5:18 PM
  • Davey,  Solomon is just a spammer whose goal is to add hidden link seo spam to forums.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Friday, January 28, 2011 5:47 AM
  • Isn't it a bit harsh to declare someone to be a spammer without any proof but one post?

    ~~AirWaves!!~~
    Saturday, January 29, 2011 3:03 AM
  • View the HTML source of the replies from the user. What do you call a user who post a hidden link to a web site that has nothing to do with any thread topics being posted in?



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Saturday, January 29, 2011 6:30 AM
  • Could  you inform me on how to view the html source?
    ~~AirWaves!!~~
    Saturday, January 29, 2011 8:04 AM
  • The menu name varies from browser to browser, but generally speaking you can invoke the command in the right-click menu.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Saturday, January 29, 2011 2:31 PM
  • Do you meant to view the html source?

    ~~AirWaves!!~~
    Saturday, January 29, 2011 8:53 PM
  • AirWaves,

    Yes, Sheng Jiang does mean the html source - what the spammers seem to be doing is replying to a tread with a quote of from a previous post + a vague question, and at the same time insering a hidden link to some other spam related site in the html source.  This can be hard to spot, but the clues are there even without the methods Sheng Jiang or others are using to systematically spot them.  One good idea is to have a quick look at the poster's other posts by clicking their name and make a common sense judement, I would tend to assume the best until it is clear there is an obvious spammer.  Most spammers try multiple forums and there are plenty of experts on the case so no action is required other than to be aware or hit the 'Report As Abusive' in clear cases to warn others.

    Saturday, January 29, 2011 10:34 PM
  • Thanks litdev
    ~~AirWaves!!~~
    Sunday, January 30, 2011 1:11 AM
  • thanks for the code. Another updated version using the TURTLE is right here. added some logic for changing color too.

    http://smallbasic.com/program/?HGF990

     

     

    Saturday, October 08, 2011 9:34 PM
  • Entering the spirit here is a swarm of bees at 25 lines, I guess I could loose the window title if it has to be under 25.  Import Code: MSH031.

    Hi Litdev,

    Your program is really great. But I am not able to understand mathematics/Logic which you used behind designing this program. Could you pl just elaborate on this. this will help me to design games like this.

    thanks

     


    Best Regards..
    Sunday, October 09, 2011 8:45 PM
  • The arrays store the bee shape, X and Y positions and the X and Y velocities for the 100 bees.

    Each timestep (While loop) each bee position is updated (For i = 1 To 100 loop).

    1] For each bee we calculate its distance from the current mouse position, this is the variable 'dist' and just uses Pythagoras d*d = x*x + y*y

    2] Using this distance we update the bee velocity to be its current velocity + a vector in the direction towards the mouse.

    The vector towards the mouse is:

    (GraphicsWindow.MouseX-beeX[i],GraphicsWindow.MouseY-beeY[i])

    If we divide by the distance (length of this vector, which we just calculated as dist, then we have a vector towards the mouse of length 1:

    ((GraphicsWindow.MouseX-beeX[i])/dist,(GraphicsWindow.MouseY-beeY[i])/dist)

    We then add each component X,Y to the current velocity and multiply the whole thing by 0.97 to slow it a bit as the bee approaches the mouse position.

    3] If the mouse button is down, then we push the bees away, by subtracting 5 times the vector - a negative vector is just the same vector in the opposite direction.

    We also add a random element to the flying away velocity to spread the swarm,

    Math.GetRandomNumber(15)-8 is a random number from -7 to 7.

    4] We update the position of the bee from its velocity

    5] We move the bee to its new position, note we use the bee centre (hence the -30)

    6] We zoom the bees so that the nearer they are to the mouse the bigger they are, using dist.  The 0.2+Math.Min(2,60/dist) is just something that sets a number from 0.2 to 2 increasing as dist gets smaller to do the scaling - perhaps try printing or plotting some values calculated from this in excel or try modifying it.

    7] We rotate the bees, the dist*dist/200 is pretty much another made up function that has the feature that when dist is small the bee is not rotated and when dist is larger the bees rotate as they are further from the mouse.  I could use dist/5 or something else.

    If there any bits you want more info on, then elaborate.

    Sunday, October 09, 2011 9:43 PM
  • This was a pretty fun and amusing thing to program. It's a 23 line version of a troll program I made in Visual Basic, just try it out to see what I mean. Probably not the most special or complex program, but I still like it. :)

    Meaning of Life

    Import Code: FHB571

    Friday, March 09, 2012 9:21 PM
  • Here is my Six liner

    MyVar=("Cir="+(GraphicsWindow.Width/5)+";dRot="+Math.GetRandomNumber(25)+";dRad="+Math.GetRandomNumber(25)+";") beginLoop: GraphicsWindow.DrawEllipse((GraphicsWindow.Width/2)+Math.Sin(MyVar["Rot"])*(MyVar["Cir"]+(Math.Sin(MyVar["Rad"])*MyVar["Cir"]/2)),(GraphicsWindow.Height/2)+Math.Cos(MyVar["Rot"])*(MyVar["Cir"]+(Math.Sin(MyVar["Rad"])*MyVar["Cir"]/2)),1,1) MyVar["Rot"]=MyVar["Rot"]+MyVar["dRot"] MyVar["Rad"]=MyVar["Rad"]+MyVar["dRad"] Goto beginLoop

    And

    Here is what these Six lines of code can do.

    Screenshot


    They say working hard is good but i say working smart is best...

    Tuesday, April 17, 2012 4:54 PM
  • Hello, Amir CPS,

    I added 2 lines in your program.

    GraphicsWindow.BackgroundColor = "Black"
    MyVar=("Cir="+(GraphicsWindow.Width/5)+";dRot="+Math.GetRandomNumber(25)+";dRad="+Math.GetRandomNumber(25)+";")
    beginLoop:
    GraphicsWindow.DrawEllipse((GraphicsWindow.Width/2)+Math.Sin(MyVar["Rot"])*(MyVar["Cir"]+(Math.Sin(MyVar["Rad"])*MyVar["Cir"]/2)),(GraphicsWindow.Height/2)+Math.Cos(MyVar["Rot"])*(MyVar["Cir"]+(Math.Sin(MyVar["Rad"])*MyVar["Cir"]/2)),1,1)
    MyVar["Rot"]=MyVar["Rot"]+MyVar["dRot"]
    MyVar["Rad"]=MyVar["Rad"]+MyVar["dRad"]
    GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
    Goto beginLoop


    Nonki Takahashi

    Friday, April 27, 2012 4:59 AM
  • 25-line chessboard : CLP327.


    Nonki Takahashi


    Saturday, August 04, 2012 12:03 PM