Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Logo wrapper in Codea

edited December 2011 in Code Sharing Posts: 76

After playing the Roboarm, It inspired me to create the LOGO wrapper in Codea.

You can download from http://sanit.posterous.com/logo-wrapper-in-codea-96505

The available commands:

PU()-Pen Up

PD()-Pen Down

HM()-Move the turtle to the center of the graphics area

SetPC(r,g,b)-Set Pen Color

SetC(color)-Set Color for more detail

FD(distance)-Moves the turtle forward distance in pixels

BK(distance)-Move the turtle backward distance in pixels

LT(degree)-Rotate the turtle degrees left

RT(degree)-Rotate the turtle degrees right

CS()-Clear screen



The command does not support REPEAT command but you can use FOR command in Lua.



Sample: Square



function square()

for i=1,4 do

FD(100)

RT(90)

end

end

This is another sample from the Logo commands.

flower2

Comments

  • Posts: 1,255

    Very cool. The first Mac program I wrote was a version of Logo called "Turbo Turtle" that was sold by Hayden Software back in '84. I've never lost my fondness for the language.

  • Posts: 622

    A great tradition to bring back

  • BortelsBortels Mod
    Posts: 1,557

    Neat - but take it farther! A language in a language is good fun and a great learning tool. Add the other logo language constructs - indeed, consider parsing a string with real logo code. Even a simple implementation of that should be faster than logo was on any machine back in '84. :-)

    I can actually think of two ways - a parser that runs the code as an interpreter, or implementing the routines as you do, and a routine that translates logo into Codea-logo and executes it with load(). Not sure which is a better path to go.

  • Posts: 80

    Love it. An interpreter inside an interpreter!

  • Posts: 2,161

    Here's a crazy idea: how about making a visual drag-and-drop code writer for this so that kids can make little programs in logo by dragging stuff instead of writing code?

  • edited January 2012 Posts: 273
    Here's a crazy idea: how about making a visual drag-and-drop code writer for this so that kids can make little programs in logo by dragging stuff instead of writing code?
    

    Nice idea!

    On a (somewhat) related note... I love this image from the link @sanit posted above:

    From sanit's above link

     Even a simple implementation of that should be faster than logo was on any machine back in '84.
    

    @Bortels you mean slower! After they've programmed their turtle I'm sure today's kids would also like to watch it move!

  • BortelsBortels Mod
    Posts: 1,557

    Caption: "HAVE LOCATED TARGET: HUMAN MALE TERMINATED. TARGETING..."

  • Posts: 622

    This discussion has brought back memories of http://en.wikipedia.org/wiki/Big_Trak which may have gotten me into programming since it predated the Timex Sinclair but it did come out around the same time as the first programming environment I remember using http://en.wikipedia.org/wiki/BASIC_Programming

  • edited January 2012 Posts: 273

    @Bortels methinks you are mixing this up with Russ Meyer's 1965 exploitation flick..

    Edit: Oh wow ipda41001 thanks for the link -- it explains everything (and makes me feel very old).

  • BortelsBortels Mod
    edited January 2012 Posts: 1,557

    I miss my Big Trak. Just sayin. Oh yes, I had one. You betcha.

    Edit: I had the trailer too. Yes - yes, I am special. My mother told me so.

    It had issues because we had carpet. Not movement - calibration. If you made too many turns, the random jitter inherent in a turn on carpet would add up, and you'd veer off course.

    it was awesome anyway. :-)

  • BortelsBortels Mod
    Posts: 1,557

    UPDATE: http://www.bigtrakisback.com/xtr-coming-soon/

    Complete with iphone app.

    SQUEEEEEEEEeeeeee...

  • edited January 2012 Posts: 273

    Not in the same league but I had one of these when I was a kid...

    http://en.wikipedia.org/wiki/Digi-Comp_I

    I had my parents order it for me from an ad in a magazine.

    (Some 40 years later, I bought myself the Minds-On Toys replica but I still haven't got around to putting that one together...)

  • BortelsBortels Mod
    Posts: 1,557

    Hmm - can someone go to the English app store (or is it Euro?) and see if "bigtrak icalc" is available there? I click the link on the bigtrakisback site, but no love, and I'm wondering if it's just US-broken.

    Do I need say, bluetooth, we need to be able to control one of these bad boys in Codea? No, no I don't need to say it.

  • Posts: 273

    @Bortels... It's available on the Dutch appstore as the bigtrakxtr-idriver

    http://itunes.apple.com/nl/app/bigtrakxtr-idriver/id464252745?mt=8

  • BortelsBortels Mod
    Posts: 1,557

    Not the driver (I see that). There's another that was listed as "bigtrak sound effects". it's on the downloads link on that site, but doesn't come up in the app store.

    I just needed to subject my family to my nostalgia and watch them roll their eyes at me.

    That Digicomp looks fun, but can it shoot at your family? no, no it cannot. :-)

  • edited January 2012 Posts: 273

    Sadly no shooting... To be honest, I was rather disappointed by Digi-Comp I as a kid. If I had stuck with it I would have heard of Digi-Comp II when it came out and that was a bit more exciting...

    http://www.oldcomputermuseum.com/digicomp_2.html

    It's also due for a remake:

    http://digicompii.com/

  • edited January 2012 Posts: 622

    @Andrew

    a visual code writer would require a table/framework for the code

    I have the embers of one here http://post.ly/4fzI4

    It needs some control commands (along with a UI and a save format)

    I'm not that familiar with LOGO but if peeps are interested, I can continue.

    First question, should we assume that the first TO is the main and is code always required to be within a TO?

  • Posts: 76

    @Andrew_Stacey That is my first thought about the idea from Roboarm. However, I am not good in writting the programming in Lua. I just wanted to test that the Codea can draw Graphic pictures by using the LOGO command. I am studying how to handle the visual object with SUP framework (Simple UI Project from @Ruilov) and how to execute a series of commands from Roboarm. If someone can create the LOGO with the visual drag-and-drop UI, I would love to see and play with my daughter. Thank you for remembering the good programming in LOGO.

  • Posts: 1,255

    Hmmm. Digital code writer. Nested interpreter...

    I'm thinking it's time for a fresh version of Robot War. I loved the Apple II version so much that I licensed the idea for the Mac and was hard at work on an edition somewhere around '85, but the company I was doing it for got bought out and the whole project disappeared.

    I'd love to write it in Codea, but first I have to think of a way we could exchange robots. It's no fun without being able to hand off your champion as a challenge to someone else.

  • BortelsBortels Mod
    Posts: 1,557

    Robot War! On the Apple II!

    Why is it all the COOL stuff (Codea excepted) was 20+ years ago. I know I can't have changed... :-)

    So long as we have .codea files and global persistent storage, exchanging bots is easy - you make a standard bot skeleton (kinda like Codea is a lua skeleton), and include routines to save/load the bot code, by name, from global storage, kinda like Spritely does for fonts.

    If .codea goes away... sigh. Compile/compress it to a cut-and-pasteable string? Yucky.

    (This is what I mean by how important sharing is, btw - you can't robot war yourself. Well, you can, but it's like 1-man chess...)

  • edited January 2012 Posts: 622

    I believe @Blanchot mentioned a visual programming language in another thread.

    @Andrew mentioned it here

    And @Sanit brought logo

    When you all mention visual programming, I think programming with some kind of touchable picture based flow chart.

    This isn't modifiable but touch (nor does it have all the logo commands) but here is a thought:

    Code: http://ipad41001.posterous.com/logea-02

    Picture: http://ipad41001.posterous.com/picture-of-a-flowchart-of-logo-in-codea-lua

    I'm not sure how to represent numbers, I attempted to get away from numbers (for parms) by showing the digits place with a number of footprints after it. I can already predict that r,g,b color will be a bit large.

    Also traditional logo has the turns in angles. I didn't change it for this but I think a better representation for turns would be 1/2 for half-turn for 180 degrees, 1/4 for quarter turn for 90 degrees.

    (and I was also thinking about codewars :) )

  • BortelsBortels Mod
    Posts: 1,557

    Presented an an example of "visual programming", for inspiration: http://www.teamhassenplug.org/NXT/NXTGTips/

    And if you're running OS X and have the Developer stuff installed, go mess with Quartz Composer, another visual programming environment. I linked to a page with some of the stuff in that in the GLSL conversations in another thread.

  • BortelsBortels Mod
    Posts: 1,557

    The NXT-G stuff is surprisingly like the basic commands for Robot War - move, turn, look, etc. There's a flash demo on lego's site that's worth taking a look at.

  • Posts: 622

    My son was in the local chapter of FirstLegoLeague last year. My poor kids, with me constantly pushing the whole of nerdom on them :)

  • edited January 2012 Posts: 76

    Here the idea about UI

    The visual commands for square picture

    image

  • Posts: 622

    I was thinking a 3 or 6 digit abacus for the numbers...

    Anyway, hope this helps

    http://ipad41001.posterous.com/logea-03-pic

    http://ipad41001.posterous.com/logea-03

    I'm a bit too sleepy for the repeat command :)

  • Posts: 2,161

    Lego Mindstorms! Yay! Now that would be supercool: controlling a Lego mindstorms robot from an iPad via Codea. If that were possible, I'd vote for sockets in a trice (has Mindstorms evolved from the old IR line-of-sight control?). The original Lego programming system is what I had in mind (of course, as a Linux user then I program my robots in nqc).

    How about having different levels of control? The really basic ones have simple blocks to drag-and-drop with a few preset angles (I'd add a few more, maybe 30 and 60, to get more interesting behaviours). Then for the more advanced kids (aka grown-ups) the ability to choose a number. This could be via a number wheel to begin with, and then via a keyboard/keypad. Similarly for the distances.

    That way, it would be a tool that someone could use at several development stages.

    (My kids are 4,6,8)

  • BortelsBortels Mod
    Posts: 1,557

    The new Lego NXT stuff appears to use bluetooth, not wifi, sad to say for team sockets.

    I also used nqc! The first gen visual language lacked things (variables!), so it was largely useless - dunno if they ever corrected that, andthen I didn't care because nqc did :-). I don't have the next gen stuff because I'm old, boo hoo.

  • edited January 2012 Posts: 273
    I was thinking a 3 or 6 digit abacus for the numbers...
    

    Funny, I played around with an abacus yesterday... (Abacus Pro (appstore)) and thought it would be a good exercise to implement my own in Codea.

    It seems to me that a 3 digit abacus for number input would be a perfect fit for kids.

  • Posts: 622

    On Nxt ... Not that it's a concern, but for competitions, you are limited to making changes via hard line USB or on the Nxt screen itself. Wireless functionality has to be turned off. This is mainly because with 8 to 10 Nxt on a gym floor things would get muddled (also the audience bring their own devices to clog the airwaves). I see an IPhone app in the store, definitely something that could be improved.

    On abacus (abacuses? abacusi? :) ) ... I'm hoping one is readable in a 40 x 40 box which could be enlarged for manipulation.

  • Posts: 2,161

    Never had occasion to do Lego competitions, the closest I got was First Robotics (as a sort of helper for a team, not as a kid. Didn't have these things in the UK when I was growing up.).

  • Posts: 622

    I was just in the audience and only helped move things and tended kids for our team at competition. First Lego Legue, promotes a very polite and friendly kind of competition (unlike some of the behaviors from sports or even dance parents). I didn't do much on the software other than setting it up, getting a few things to function (finding some custom block for them to use), and guiding (if that works, make a backup, work in layers and pieces). They are very big on the kids doing the real work, not a competition between parents like science fairs seem to have turned into.

  • Posts: 80

    There are a couple other visual programming environments worth exploring.

    Check out Scratch at http://scratch.mit.edu/ for some ideas on how to handle control structures (One of my beefs with Labview in general and NXT is awkward control structure management.)

    There's also Lightbot as an example of a cool programming game, complete with simple conditionals and recursion: http://armorgames.com/play/6061/light-bot-20

Sign In or Register to comment.