AltME: Rebol School

Messages

Maxim
for those who did not try the above script... do it (in 2.7.8) its pretty fun.
Reichart
"we could modify the script a little to make it work across two different machines.
That is the KEY, add that :)

Gabriele
Arnold
Johnk replied pointing to so chat, where my answer is too. Not going to subscribe to yet another site, there's too many already.
I have another nice question. I have 6 integers from 0 to about 23000 and I like to hash these. I calculated the 6 integer would fit into 96 (3 x 32 bit) bits. Any FUN ideas on howto do this?
Gregg
What is the context and the goal?

Arnold
The context is creating a Chinese chess game. I divided the board into 6 equal pieces and use the fieldcode and piece to calculate a number, I took some precautions that should make it unique. For the startposition the values are hash-1: 1508 hash-2: 2232 hash-3: 1508 hash-4: 1802 hash-5: 2293 hash-6: 1802, When I calculate for a maximally filled area there is an upperbound of approximately 23000. But I think in practice it could always be under 8000.
I could have gone the easy path and copy existing C programs using the bitboards and corresponding Zobrist hashing functions. But the easy path is boring and leads nowhere too ;-) So I decided to play around & find out an alternative way.
Arnold
I will have to shuffle my multiplication factors a bit more for now a black king of value 129 can be placed on a field with factor 115 giving 14835, that is a bit too much of a good thing :-)
Arnold
Placed a file in Rebol-school folder. You can see the board with pieces and a multiplication table that is the original field number multiplied with prime factor 3, 5, 7 and 11 for columns 2, 3,4 and 5. After that it is mirrored and reshuffled a bit to the other 5 sixths.
Maxim
Reichart, revised script with setup for two hosts.  all you need to setup the host names. if machines are on the same intranet, just their local host name should be ok.
rebol []
;-------
; note:  app must be launched on hosts in the order they are given here (this is a quick demo)
;
; replace foo & bar with hosts, or use localhost in both to launch both on a single host.
;-------
host-A: tcp://foo:33101
host-B: tcp://bar:33102
spec-A: net-utils/url-parser/parse-url ( context [url: host-A  host: port-id: none  serv-url: does[rejoin [tcp://: port-id ]]] ) host-A
spec-B: net-utils/url-parser/parse-url ( make spec-A [url: host-B] ) host-B
; try to connect to first host as client... if not available, then we are first host
either (attempt [ rmt-port: open host-A  close rmt-port true ])[
    lcl-spec: spec-B
    rmt-spec: spec-A
][
    lcl-spec: spec-A
    rmt-spec: spec-B
]
    
lcl-port: open/lines lcl-spec/serv-url
rmt-port: rmt-spec/url
print rejoin ["'" lcl-spec/host "' serving shared terminal on port: " lcl-spec/port-id]
con: open/binary [scheme: 'console]
remote-port: none
digit: charset "0123456789"
forever [
    p: wait [lcl-port con]
    chars: ""
    either p == con [
        key: first con
        either key = 27 [
            read-io con io: head clear "" 3
            cmd: copy "K [27 "
            foreach c io [ append cmd to-integer c append cmd " "]
            append cmd "]^/"
            chars: join "^[" io
        ][
            cmd: rejoin [ "K " key "^/" ]
            chars: to-char key
        ]
        
        insert ( rp: open rmt-port ) cmd
        close rp
    ][
        conn: first lcl-port
        if  (cmd: pick conn 1) [
            parse cmd [
                "K " here:
                "[" (chars: to-string to-binary load here)
                
                | ( chars: to-char load here )
            ]
        ]
    ]
    prin chars
]
Reichart
....that is very nice.  I will set up a second computer soon to play with this.
Next step, get them talking outside the net.    
The reason this "seed" of code is important, is once people see how truly easy this is, there are hundreds of cool little tools that use this as a base.
Gregg
It looks like they should already talk to any machine Reichart. Just config the names in Host-A/B.
Maxim
yep exactly.  you can put any hostname or ip address.  as long as dns resolves it you can reach it.
Gregg
Arnold, thanks for the info. Since I know nothing about Chinese Chess, I still don't know what the exact criteria are, so won't have any great suggestions. e.g., criteria being: given an integer of 0-23000, return a result that is <between M and N, and is otherwise totally random> .
Arnold
I know nothing about it too, I have bought a set say 20 years ago, never played. Since Doc is now in China and I did a checkers game in Rebol before, it looked like a nice challenge doing it the Rebol way.
Reichart
Indeed, i was speaking to the UI.  Making it for example so that your IP pops up, and you can tell that IP to another computer.
I have been working on a "trick" to get through firewalls and get two clients talking "without" a thrid party server.
It would use a third party of course, it would just be ...........well, using a trick so no one needs to pay for it and it is fast.

Cyphre
I believe it is possible to do do NAT UDP hole puching uisng pure R2. Couple years ago I tried that  just for fun and it sort of worked, but I haven't made any deep tests after that.
Gabriele
yes, i was doing things like that while playing with Chord in 2004
Pekr
Reichart - back at the time, I created one script for my friend. He had some HW device, sending data, and wanted to store the data into files. So I created kind of multiserver, which is able to gather data from multiple clients, and store it in separate files. You can find it in Folders/pekr
Reichart
Richard, exactly!
Perk - cool, I will take a look at that.
Here is a note a friend of mine just posted:
"STEM, CS, and couples therapy (!) musings: I had a teacher once explain to me that learning a foreign language was a way of thinking differently.
I have always applied this to computer languages, too.
The past few weeks I've been relearning/finally understanding a language I was introduced to about a decade ago. In a way, the language itself isn't important, rather the shift in thinking required for me to produce code that worked the first or third time  is what I want to focus on.
The language is, I believe, my first functional language and I quickly learned that the techniques for picking up a new programming language that I have always used, would not work here. I kept encountering weird and inscrutable errors.
So I went back to square one again and again and again, reading the docs, looking at code, and finally opening my mind to what was being said instead of what I thought was being said.
It's a skill usable in all aspects of life, to listen rather than interpret or, worse, assume.
Couples therapy, alluded to earlier, is really shorthand for clear communication. It is so easy, when you have a close and long-term relationship with someone, to think you know what they are telling you, so much of couples therapy, IME, is about letting go of what you think your partner is saying and to listen to what your partner is saying instead. I am thinking that this programming languages metaphor may be helpful for various friends in their own clear communication challenges.
So, thank you Mr. Locke, for teaching me the importance of language and thought, and thank you Reichart, for being the final push I needed to jump back into Rebol and not only gain a really useful skill that I need now more than ever (application #3 is being written, this one is client/server  but also for this useful insight about communication, presumption, and partnership."

Last message posted 184 weeks ago.