Do you happen to figure out why it produces empty list?
Yes, as @sorawee writes, I was supposed to use in-producer
instead of in-generator
.
Cool thread. I played a LOT of chess when I was 12–14 years old. I was at the US Junior Open when Richard Nixon resigned. The tournament was stopped so we could watch the news in all its solemnity. (Things were quite different then.) I remember when I was playing someone who was very good the intensity was incredible. I don’t know if I’ve experienced that level of concentration in anything else. I’ve flown and landed planes in difficult conditions and that certainly requires concentration, I’ve raced in (rowing) national and world championships, but even those experiences haven’t required the mental gymnastics needed to win against a superior opponent.
And if you haven’t seen The Queen’s Gambit, I recommend it.
Ditto!
@soegaard2 you found my repo - it’s not quite ready yet, but I figured I’d put it on github anyway :)
When I was in Iceland in 2018 I made a special trip to the hall where Fischer & Spassky played in 1972. The guy who showed me around said that after Bobby Fischer moved to Iceland before he died, Fischer stopped by daily at the little restaurant his wife ran. Every day he ordered a cheerburger and a glass of milk. Anyway, back to the 1970s, there used to be chess houses all over New York City. That’s what started me on chess. I’ll repeat myself: (Things were quite different then.)
When I started this, my goal wasn’t to make a competitive chess program, so I just used a 10x12 board. I think all the good engines use bitboards, but that seemed like too much work. I suppose I could always swap board representations later.
@badkins Just beat Deep Blue. I want Garry Kasparov to be happy again.
I have a hunch that to be competitive, C/C++/Rust is required. Maybe Julia could do it, but I’m not sure about that.
Racket could write the Rust if required.
What do you mean things were quite different then? Can you elaborate on that? I don’t think I get it.
A Dane (Bent Larsen - who lost in the candidates semi-final to Fischer) has the questionable honor of being the first GM to lose to a computer.
re: “Racket could write the Rust if required.” @gknauth I’m skeptical of that approach :)
I’d love to see examples of performant code in C/C++/Rust being generated by Racket.
I remember watching the Deep Blue vs. Kasparov match “live” - exciting times :)
Don’t forget, that these days, you can write bits and pieces in Chez Scheme and call them from Racket.
@badkins re: Racket writing Rust. Lisps are good at AI-type thinking. Talented humans are capable of great optimizations. How do humans do it? Heuristics? Flashes of insight? I think it’s mostly tricks they’ve learned over the ages, a bit like chess. If it’s possible to write a chess program that can beat the best human (even if only by brute force), the same sort of thing should be possible with writing Rust. Who knows, sprinkle in some machine learning and you could get chess games and Rust programs that no human has imagined (both good and bad). Maybe the human has a role in separating the good and the bad (“no, computer, that’s not what I meant!”).
Hm, revisiting my program written 2 weeks ago, and getting the following error. It did work previously :thinking_face: open-input-file: cannot open module file module path: typed/algorithms path: /usr/share/racket/pkgs/rackunit-typed/algorithms.rkt system error: no such file or directory; rktio_err=3
Just upgraded to Linux Mint 20.1
Should typed/algorithms be rackunit-typed/algorithms ?
This seems to be the offending line (require typed/algorithms)
, yes typed/racket
Is typed/algorithms
your own library?
No, it is a standard library.
Hmm. Maybe check with raco
which packages are installed?
Did the update also update racket?
not sure, so uninstalled and installed racket
just now, or before?
before
Maybe you need to reinstall some packages then.
As in raco pkg install some-package
I am unsure what the algorithms
package is.
I searched typed/algorithms
and found nothing in the doc
Then try: raco pkg install algorithms
Shouldn’t that be (require algorithms)
?
It’s not part of the standard distribution.
What is considered standard distribution then?
Good question. The set of packages that are bundled with Racket, when you download it from the home page.
Not sure where a complete list can be seen.
@nicholas.faiz has joined the channel
(string-split "{659ffea0-8381-42f9-ab19-c27085bf1445} bus:/" "} " #:trim? #f)
it’s giving me: '({659ffea0-8381-42f9-ab19-c27085bf1445" "bus:/")
how do i make it so it doesn’t erease the close brace }
?
unsure if this is a bug with #trim or am i mis-reading what it does
Why not just split on " "?
Btw, #:trim just applies string-trim before splitting
i can’t split on space because there might be other spaces, e.g : ("{659ffea0-8381-42f9-ab19-c27085bf1445" "bus:/hello world")
ah
passing #:repeat? #f
doesn’t do what i think it does either lol…
welp, for now ill just string-append back the closing brace
i would suggest taking two substrings instead
because the thing in brackets is always a uuid right?
if so, you could do (substring str 0 38)
to get the first part, and (substring str 39)
to get the second part
oo never thought of that
seems like it will always be 0–38
thanks!
np
(struct bar (y z))
(define-syntax (get-bar-field-names stx)
#`'#,(struct-field-info-list (syntax-local-value #'bar)))
(get-bar-field-names)
is there a way to pass in an instance of a struct and get its field names, (in this case ’(y,z)` ? at runtime
#lang racket
(require (for-syntax racket/struct-info))
(struct bar (y z))
(define-syntax (get-field-names stx)
(syntax-case stx ()
[(_ the-struct)
#`'#,(struct-field-info-list
(syntax-local-value #'the-struct))]))
(get-field-names bar) ;=> '(z y)
sweet thanks! never heard of syntax-case before
oh wait! what about passing an instance of a struct?
e.g (get-field-names (bar 3 1))
?
That’s not possible via the above protocol, but there might be other ways to do it.
It’s likely going to be very brittle though
tis outside my knowledge. either way thanks
Actually, jk, the way I thought would work doesn’t actually work
So yeah, I don’t know if it’s possible via the standard struct
usage
ahh well thanks anyways
Here’s one easy way to do it if you can use non standard struct
#lang racket
(require racket/generic)
(define-generics field-name-reflectable
(get-field-names field-name-reflectable))
(define-syntax-rule (my-struct name (fields ...) options ...)
(struct name (fields ...) options ...
#:methods gen:field-name-reflectable
[(define (get-field-names self)
'(fields ...))]))
(my-struct bar (y z))
(get-field-names (bar 1 2)) ;=> '(y z)
If you want to use this solution, you might want to refine it further to support field options, super struct type position, etc.