I've seen some of the proposals for connecting Scratch projects to each other, and I'm not entirely sure where they are headed. Frankly, I don't think networking has to be all that complicated, although there are certainly "complications" that do apply.
What I'm looking for here is a way to try and simplify the process for creating a scratch project that can connect to other software... but more importantly can connect to other scratch project(s) or to another copy of itself. I'm interested in digging into the Squeak source code to make this happen (as Jens has done with the "Build Your Own Blocks" system) to try and make a demo of this concept as well.
I'm seeking here is to go over syntax within Scratch that would be keeping with the simplicity of Scratch yet still permit some rudimentary networking connections.
I'll also be blunt... I love serial interface programming, so I think most of these concepts could carry over to permitting a connection to an RS-232 serial port or other similar kind of device. If you think RS-232 is olde skool ancient stuff, there still is a surprising amount of stuff that uses that protocol and connection format and is an ideal way to introduce network programming as well... but I digress here with my rant. The point is that it can be used with a similar interface.
There are three parts to networking interfaces in software:
*Establishing connection parameters
*Sending Data
*Error handling (connection drops, garbled data, equipment error codes)
Of these, establishing the connection parameters seems to be the most complex and specific to the protocol that you are using (aka TCP/IP, RS-232, etc.) This is also, however, the most straight forward.
Error handling can also be complicated, although from the viewpoint of a scratch project some of this can be highly simplified or simply ignored.
Data transmission is surprisingly pretty simple, and here is at least what I was thinking. There would be a standard "network" variable that you could read and write to. For example:
transmit ( number )
And a "network" variable that could be used to receive the data. As with most network protocols, this would be a read-only variable where each "byte" transmitted would be read one at a time as it comes through the network connection.
One more critical feature for network connections is an "event" to notify the program that some data is waiting in the "buffer" to be read. In Scratch, this is quite straight forward and could be done with a "when" block like this:
[blocks]
<when I receive[ network data ]>
[/blocks]
A similar kind of "event" trigger could also (optionally) be added for error handling to a Scratch project looking sort of like:
[blocks]
<when I receive[ network error ]>
[/blocks]
And then another "variable" that would contain the "error code" or "error type" could be handled in some way. Keeping this simple is obviously going to be the hardest part of it all.
I'm curious if there are any other ideas for networking. Yes, I've seen the work-around "hack" that uses the scratch sensor controls, as well as the "Netscratch" demo that was created which simply created some common "variables" that were shared between projects. I'm wondering why Scratch should be so limited, however, and why networking has to appear so scary.
If a kid can figure out how to write a whole http damon in Scratch.... I give extra kudos to that kid (or seasoned adult trying to push the limits of Scratch). But that really isn't the point here. Networking scratch projects shouldn't be all that scary, nor does it have to be complicated... and there are a whole bunch of really cool concepts that could be taught to kids if they had these tools available to them.
Last edited by Roberth (2008-12-14 17:15:22)
Offline
I Agree, this tool is meant to be an introductory for kids in the field of programming. And what is programming without networking?
Offline
I like your ideas, also, you should include Sending & Recieving.
Changing the topic, some things you could do are:
-Highscore tables. The basics. As you play the game, it will record what you do with lists (so you can watch and tell if it was a hacker), then it would send the lists and the score, and then you could access the highscore table and see other people's scores, and watch them, and moderators would take out the fake ones.
-Online Chatrooms, talking. Not too hard, but might be a bit complex. By using Chalkmarrow's talking GUI widget, it would send the variables of the letters online, and it would send it to everybody in order and it would appear on their screens.
-MMORPGs. Well, lets put it this way, ITS SUPERYDUPERY HARD. Well you'd first of all use the talking module (above), you'd have to send there x position in the entire world (assuming its a scrolling MMO), you'd send which rank you are which would change the costume, and of course for the player to appear on the other screen, there would have to be sprites which would appear as the player, and of course there would have to be a limit.
Of course, just some ideas =P
Offline
Folks, to reveal a little secret: If you have a look at the Scratch Source Code you'll notice that these networking features are already in there, you might just have to activate a disabled menu. The so called "remote-sensor" protocol has all the functionality you need to setup Scratch as a peer-to-peer tool piping several Scratch sessions together and letting them interact with each other for colloborative multi-user projects.
Offline
The one problem I have with the "remote sensor" method of networking control is over three issues:
1) The protocol is needlessly huge. There is a bunch of information which simply isn't needed for most applications, and the protocol is needlessly complex for purely networked applications. This complexity also slows down the transmission of data considerably as well... over and above the already slow processing speed of interpreted Scratch.
2) The network requires the installation/creation of additional networking applications above and beyond just Scratch. What I'm proposing here is something that is completely native to Scratch as a language and not something hacked onto a feature to make it do something it wasn't really designed to do in the first place.
3) Perhaps restating the above problem, but the remote sensor approach is a huge kludge of the worst kind that generally programmers of all types should avoid if possible. This is hardly teaching sound software development techniques, and certainly shouldn't be something in a "teaching language" like Scratch.
Yes, I'll admit we could even develop a "generic networking" kind of 3rd party applet that would be a hack on a kludge on a back door approach to getting networking going. Kind of reminds me of writing device drivers for Windows... try PCI device drivers if you want to see convoluted communications... but that isn't what I'm trying to address here.
When I was in 9th grade oh so many years ago, I wrote a simple IRC-like community chat program that consisted of about 200 lines of BASIC on a timeshare system that had some interesting networking characteristics built into the variant of that language. I'd love to see that experience brought forward into Scratch, so kids here could easily do something just like that and not have to kludge something to make it work. With this protocol as I'm proposing, I think I might be able to get a chat program down under a few dozen Scratch blocks and no extra "software" beyond a network-modified Scratch. Multi-player (not necessarily "Massive") role-playing games wouldn't be significantly larger... at least in terms of similar kinds of RPG-type games that are currently being developed on Scratch.
I certainly think you could teach the seven-layer network model very effectively using Scratch as the application layer and teaching some basic of TCP/IP or networking theory in general for a high-school level of student... and perhaps even some middle school students could grasp the concept as well if presented properly. This isn't rocket science.
Offline
Actually, you do not need (to write or obtain) any middleware to make several Scratch sessions communicate directly with each other, if you take the existing Source Code and activate that (currently experimental and thus disabled) feature. This uses TCP/IP and the protocol is IMO very slim and straightforward. Afterwards each Scratch session can directly sense all global variables and broadcast / receive all messages of all other connected sessions. You can even simulate networked sessions on the same computer.
Offline
Jens wrote:
Actually, you do not need (to write or obtain) any middleware to make several Scratch sessions communicate directly with each other, if you take the existing Source Code and activate that (currently experimental and thus disabled) feature. This uses TCP/IP and the protocol is IMO very slim and straightforward. Afterwards each Scratch session can directly sense all global variables and broadcast / receive all messages of all other connected sessions. You can even simulate networked sessions on the same computer.
How would you activate that feature?
Offline
To enable "NetScratch" (or rather networked Scratch sessions) try this:
1. Open the Scratch Source Code.
2. Go to ScratchFrameMorph -> #addServerCommandsTo:
3. Change the first line to: disable := false.
4. Open Scratch (several times).
5. Connect using the Extras-Menu.
Enjoy!
Now, while this will connect Scratch sessions among each other it does not answer Roberth's issue of how networking could be expressed using Scratch blocks.
This is an extremely interesting question and very thought-provoking idea, and I'm still very curious about any ideas how these two could perhaps be combined so students may learn about networking and program simple networked applications using Scratch.
Any further thoughts / ideas on this?
Offline
Jens wrote:
To enable "NetScratch" (or rather networked Scratch sessions) try this:
1. Open the Scratch Source Code.
2. Go to ScratchFrameMorph -> #addServerCommandsTo:
3. Change the first line to: disable := false.
4. Open Scratch (several times).
5. Connect using the Extras-Menu.
Enjoy!
Now, while this will connect Scratch sessions among each other it does not answer Roberth's issue of how networking could be expressed using Scratch blocks.
This is an extremely interesting question and very thought-provoking idea, and I'm still very curious about any ideas how these two could perhaps be combined so students may learn about networking and program simple networked applications using Scratch.
Any further thoughts / ideas on this?
Thanks.
I guess
disable < false
works too? (at least it did for me...)
I am going to test out it's features!
Offline
JSO, every session in the mesh receives every broadcast in the mesh (from other projects as well as from itself), but as of now you have to know the message names of the other projects, as you don't find them in the drop-down menus. Also, every project in the mesh can sense any global variable of other connected projects using the sensor block (like in remote sensing). This in effect lets you do virtually anything (!)
Offline
Jens wrote:
Also, every project in the mesh can sense any global variable of other connected projects using the sensor block (like in remote sensing). This in effect lets you do virtually anything (!)
That makes sense
PS: I like how you can make two projects react to each other, even on the same pc...
Offline
Would be an idea
Offline
EDIT: Never mind...
Last edited by ihaveamac (2009-01-01 01:46:00)
Offline
Offline
Hi,
I made another solution that supports peer-to-peer connection by Scratch Networking Protocol.
I add two new blocks:
'broadcast [message] to [address]' for 'Control' category.
'update sensor [name] with [value] to [address]' for 'Sensing' category.
I found this thread today and I think NetScratch is more flexible. However my one may be of some help. So I publish it.
http://squeakland.jp/abee/tmp/NetworkingProtocolClient.zip
Best,
Kazuhiro Abe
P.S.
I and my colleague made another network collaboration system named NetMorph for Squeak Etoys between 2002 to 2005.
http://swikis.ddo.jp/NetMorph
Offline
abee wrote:
Hi,
I made another solution that supports peer-to-peer connection by Scratch Networking Protocol.
I add two new blocks:
'broadcast [message] to [address]' for 'Control' category.
'update sensor [name] with [value] to [address]' for 'Sensing' category.
I found this thread today and I think NetScratch is more flexible. However my one may be of some help. So I publish it.
http://squeakland.jp/abee/tmp/NetworkingProtocolClient.zip
Best,
Kazuhiro Abe
P.S.
I and my colleague made another network collaboration system named NetMorph for Squeak Etoys between 2002 to 2005.
http://swikis.ddo.jp/NetMorph
the example wont work
Offline
Hi techy,
Try the following steps:
1. Start NetworkingProtocolClient.image as a client and open TestForClient.sb.
2. Start any Scratch 1.3 or later image as a server and open TestForServer.sb. Don't forget "enable remote sensor connections" at the right-button menu of [slider sensor value] block.
3. Then click the green flag at the client side. If you can hear piano scale sound, it is OK.
If you are not so familiar with Scratch Network Protocol, I recommend checking this site:
http://scratchconnections.wik.is/
Last edited by abee (2009-02-02 01:06:10)
Offline