Shop OBEX P1 Docs P2 Docs Learn Events
Does the stamp support self modifying software. — Parallax Forums

Does the stamp support self modifying software.

.:John:..:John:. Posts: 64
edited 2007-10-11 14:17 in BASIC Stamp
Does the stamp support self modifying software. Does it support a "master-slave" setup?

Post Edited By Moderator (Chris Savage (Parallax)) : 10/10/2007 2:37:21 PM GMT

Comments

  • D FaustD Faust Posts: 608
    edited 2007-10-10 01:18
    I think that BS2Ps can support a master slave I2C setup, but other setups depend on, well, your setup. Do you mean modifying it software while running? If so, I think that any stamp with multiple program slots can do this. No Guarantees

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum
    LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum
    ON subnum GOTO Hope_this_helps, Thanks!, WOW!!
    END 
    
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-10 01:30
    "Self-Modifying Software" is strongly discouraged, because it's VERY difficult to debug. Now, recently there have developed some "Genetic Algorithms", which attempt through randomness to achieve what cannot be achieved through deliberate design.

    For me, that's similar to having computers generate Poetry -- it STILL takes a human to provide feedback when they're doing it "right".

    In any event, they've published the download code, so you COULD create a PC that dynamically re-programs an attached 'real-time' BS2 platform. I'd think it would be a lot of work, however.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-10 01:31
    Oh, yes, and please don't post in ALL CAPS, it's considered on-line yelling and in that way is a little rude.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-10-10 02:23
    curious_roboticist·and allanlane5--
    A·Stamp is not a good candidate for generating genetic algorithms. You need great string and/or list·handling.
    I have written many genetic algorithm programs, or programs that produce other programs that continually evolve by testing for a better "fit", weeding out the "weak", mutating the "strong" (the ones that statistically come closer to solving the problem than do the weak ones) and doing it all over again, perhaps millions of times, but usually a few hundred thousand is sufficient to achieve acceptable results on the order of something like recreating the quadratic formula.
    Genetic algorithms are simply incredible and amazing to watch as they execute. (Of course, watching them slows them down enormously.)
    I have thought about writing PC-based code that would create Stamp programs ala above. I can in no way be called an expert in this field; however I have done quite a bit of it. Nothing I might write would ever do anything significant, but I believe creating syntactically correct PBasic programs that might correctly use unique features of the language to do things in a new (weird?) way would be relatively easy.
    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • karljhimzkarljhimz Posts: 1
    edited 2007-10-10 03:05
    know i probably don't think so! i got something new to you, and i would like to share this with you. Hope you like it as well! It's nice, I guarantee [noparse][[/noparse]URL Removed by Moderator]. Please check this out!

    Post Edited By Moderator (Chris Savage (Parallax)) : 10/10/2007 7:44:39 PM GMT
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-10-10 03:08
    All--

    Has the Parallax forum just been spammed?

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2007-10-10 03:25
    Bill, yes. I'll go ahead and lock the user out and ban his IP address. Usually Chris handles that stuff, but the poor guy was kinda under the weather today and needs a break from the forums. Hopefully I get the information he needs when I do this. . . so here goes!

    Ken Gracey
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-10 03:33
    curious_roboticist,
    The main reason why a Stamp is not a good candidate for self-modifying code is that the definition of the byte codes used by the Parallax Basic interpreter is not public information. It's proprietary to Parallax, so you don't really know what you need to generate or modify. It's possible to figure it out by compiling different statements and operators and seeing what gets produced by the compiler, but there's no existing documentation on this.
  • skylightskylight Posts: 1,915
    edited 2007-10-10 10:43
    hope this isnt the beginnings of Skynet freaked.gif

    The BS2 became self aware on date......

    Post Edited (skylight) : 10/10/2007 10:59:58 AM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-10 13:16
    With 26 bytes of ram, it's not going to be able to think very deep thoughts.
  • skylightskylight Posts: 1,915
    edited 2007-10-10 13:44
    not even the answer 42?roll.gif

    you see thats the trouble with programmers these days, used to having large resources to play with, in the old days(70's) you'd be surprised what could be fitted into tiny memories.lol.gif

    Post Edited (skylight) : 10/10/2007 2:04:34 PM GMT
  • .:John:..:John:. Posts: 64
    edited 2007-10-10 16:36
    Well thanks. I have a boe-bot right now, so that is why I want to use the Stamp. Would a master slave system work for genetic algorithms. That is the kind of program I want, something that ramdomly comes out with solutions and then mutates them. I just need to know if this is at all possible.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-10-10 18:23
    One of the factors that determines the success or failure of any optimization algorithm, GAs (genetic algorithms) included, is the continuity of the utility function over the representation space. While GAs are able to handle discontinuities much better than, say, gradient methods, any time you have a representation in which changing a single bit leads to radically different behavior, optimization is going to be tough. Sequential digital processors, such as the p-coded BASIC Stamp, certainly fall into this category.

    In general, you want representations (chromosomes) in which small changes in structure lead to small changes in behavior. A parallel network of analog or logic elements would be an example, and there has been some research here optimizing configurations for FPGAs (field-programmable gate arrays) using GAs.

    My recommendation, if you still want to explore optimization of sequential algorithms, is to design a simple, virtual CPU that you can simulate on your PC. Keep the instruction set small to start with. You can always add instructions later. Make sure that the task you want your CPU to perform is clearly defined, and come up with a utility function that not only rewards total correctness but also provides numerical measures of "pretty good" and "not so good".

    Good luck with your project! GAs are lot of fun to play with and can yield some surprising results. But you have to employ them with your eyes open and not expect miracles.

    -Phil
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-10-10 20:33
    curious_roboticist--
    Phil said the following (I don't know why I suddenly cannot get the format correct!) . . .
    My recommendation, if you still want to explore optimization of sequential algorithms, is to design a simple, virtual CPU that you can simulate on your PC. Keep the instruction set small to start with. You can always add instructions later. Make sure that the task you want your CPU to perform is clearly defined, and come up with a utility function that not only rewards total correctness but also provides numerical measures of "pretty good" and "not so good".

    I agree with Phil 100%. He put if far better than I.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • .:John:..:John:. Posts: 64
    edited 2007-10-10 21:05
    I want my robot to be able to move around, not be tethered to a computer. The ideal situation is that when the robot is presented with a situation, it finds the least complicated way to go by coming up with however many solutions and mutating them.
  • .:John:..:John:. Posts: 64
    edited 2007-10-10 21:10
    Eventually. I MEAN IN A LONG TIME. I would like the bot to learn based on interaction with the world. I am interested in GA because it seems like a good place to start.
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-10-11 00:30
    curious_roboticist--

    A Stamp simply will not do what you want. I don't think the Propeller would, either . . . but, I bet you could cut some wicked assembler for it! (I know very little about the Propeller. Perhaps others will chime in concerning it and this subject.)

    You need to use a PC. I have done it almost acceptably on a fast tablet-PC. But, all my programs were "proof of concept" type things designed just to see if I could do it in Visual Basic 6.0! (I could. It was tedious to say the least. However, once you get a template going that does all the garbage Windows demands, then it is not too bad.) My choices would be assembler--because I used to be an insane bit-blaster or c, although I am not too good with c. There are other languages that will work, as well.

    The difference between what I have done and what you want to do, even initially, is huge. However, I encourage you to go for it: Study GA. Like Phil said, build a phony instruction set and put GA to work on it.

    You could (eventually) build a 'bot using Stamps and stick a tablet-PC on it or in it that talks to the Stamps, downloading ever more successful progeny to the Stamp(s). For that matter, you could stick some 1Us in a rack, network them, WiFi'em,·and go into the GA-wireless Stamp business BIG TIME!

    Buy some GA books. I have several. The high-end ones are over my head, mostly. I still gain something from them, though.

    It doesn't hurt too much that my daughter and her husband are both brand new PhD geneticists. (Molecular Biology; but you do not need resources like that. Like I said, get a book.)

    Go for it! Darwin would like it.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • .:John:..:John:. Posts: 64
    edited 2007-10-11 00:46
    Ok, I guess that I will take Mike's advice and use the xBee system (darn it. I wanted to do this without buying anything except the adapter.)

    So tell me if this is what you guys are suggesting:
    I could have my computer do the algorithms and send them to the basic stamp. The stamp then executes them.

    Is that what you guys are saying?
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-10-11 01:17
    curious_roboticist--

    I could have my computer do the algorithms and send them to the basic stamp. The stamp then executes them.
    Yes, you could do that.

    However, I do not think any of us are saying much of anything about GA, including me. I am encouraging you to investigate your ideas, though. GA is more than just fascinating. It can actually be a little scary due to its evolutionary, survival of the fittest nature. It is CAPTIVATING to watch hundreds of thousands, or millions, of generations evole in minutes instead of millions of years.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-11 12:45
    The problem with your approach, 'curious', is that the BS2 simply doesn't have the memory space to do GA 'by itself'. It does not have the speed to do GA 'by itself'. As Bill points out, for GA to work, you need to be able to go through hundreds or thousands of iterations.

    If you put a 2000 Instruction Per Second processor in that loop, it will take forever.
  • .:John:..:John:. Posts: 64
    edited 2007-10-11 14:17
    Thanks for your input. I think I will try GA anyway. I already have everything I need.
Sign In or Register to comment.