Stream: show and tell

Topic: Roctris


view this post on Zulip Jared Cone (Apr 10 2022 at 23:04):

I made a minimal Tetris clone in terminal to learn Roc and pure functional programming. https://github.com/cjcone/roctris

view this post on Zulip Richard Feldman (Apr 10 2022 at 23:56):

SO COOL!!! :smiley::smiley::smiley:

view this post on Zulip Ayaz Hafiz (Apr 11 2022 at 00:32):

This is so cool, thanks for sharing! Awesome that Roc can do this :)

view this post on Zulip Richard Feldman (Apr 11 2022 at 00:43):

anyone else tried it on a M1 Mac? I'm getting a segfault right away :sweat_smile:

$ cargo run ../roctris/Roctris.roc
    Blocking waiting for file lock on package cache
    Finished dev [unoptimized + debuginfo] target(s) in 6.85s
     Running `target/debug/roc ../roctris/Roctris.roc`
Segmentation fault: 11

this is from nix-shell in the roc/ dir

view this post on Zulip Nikita Mounier (Apr 11 2022 at 11:52):

Same here, I get a SIGSEGV error on M1 – pretty sure it's to do with Stdin, same thing happens on the interactive CLI examples in the roc/

view this post on Zulip Richard Feldman (Apr 11 2022 at 12:20):

SO COOL!!! :smiley::smiley::smiley:

view this post on Zulip Zeljko Nesic (Apr 11 2022 at 15:05):

On i7 Mac compiled but no dice of moving it ...

[nix-shell:~/projects/roc]$ cargo run roc build ../roctris/Roctris.roc
    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `target/debug/roc roc build ../roctris/Roctris.roc`
🔨 Rebuilding host... Done!
🎉 Built /Users/popara/projects/roctris/Roctris in 2484 ms

[nix-shell:~/projects/roc]$  /Users/popara/projects/roctris/Roctris
thread '<unnamed>' panicked at 'failed printing to stdout: Bad address (os error 14)', library/std/src/io/stdio.rs:1201:9
                                           note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

view this post on Zulip Jared Cone (Apr 11 2022 at 15:54):

seems like the kind of error you get when trying to write outside of a buffer, but for stdout. The game only writes within a ~40x20 character windows so probably not trying to write outside of the terminal window

view this post on Zulip Brendan Hansknecht (Apr 11 2022 at 15:55):

It's probably on the Roc side. We definitely have some bugs that access out of bounds.

view this post on Zulip Jared Cone (Apr 11 2022 at 15:58):

tonight I'll try putting up a test program for debugging

view this post on Zulip Brendan Hansknecht (Apr 11 2022 at 16:05):

Yeah, almost certainly a(multiple) Roc bug(s). When run with --optimized it gets farther

view this post on Zulip Brendan Hansknecht (Apr 11 2022 at 16:06):

Which means that branches that get optimized away and there conditionals are at least part of the cause of the bug

view this post on Zulip Jared Cone (Apr 12 2022 at 04:29):

I pulled latest Roc tonight and I think it's happening to me too. No segfault message, app just exits. Gonna start commenting stuff out to see what's triggering it

view this post on Zulip Brendan Hansknecht (Apr 12 2022 at 04:32):

With a debug build and gdb, you should be able to get the function name that it segfaults in.

view this post on Zulip Jared Cone (Apr 12 2022 at 04:36):

k Stdout wasn't working at all, looks like I just need to update my lib.rs to use &RocStr instead of ManuallyDrop<RocStr>

view this post on Zulip Jared Cone (Apr 12 2022 at 04:55):

k should be good to go

view this post on Zulip Richard Feldman (Apr 14 2022 at 01:30):

that update gets farther for me, but still segfaults :big_smile:

Screen-Shot-2022-04-13-at-9.30.02-PM.png

view this post on Zulip Jared Cone (Apr 14 2022 at 03:53):

boo

view this post on Zulip Brendan Hansknecht (Apr 14 2022 at 04:14):

Indeed. This is the fun and M1 and memory issues.

view this post on Zulip Zeljko Nesic (Apr 14 2022 at 17:57):

It works on my Machine!!! (TM)

Screenshot-2022-04-14-at-18.57.22.png

view this post on Zulip Zeljko Nesic (Apr 14 2022 at 18:47):

Just spent 20 minutes playing it! :D

view this post on Zulip Richard Feldman (Apr 14 2022 at 19:41):

interestingly, on x86 mac I get this opening screen...
Screen-Shot-2022-04-14-at-3.40.25-PM.png

then when I press spacebar it transitions to this: (no segfault or anything, just appears to hang)
Screen-Shot-2022-04-14-at-3.40.30-PM.png

view this post on Zulip Zeljko Nesic (Apr 14 2022 at 21:30):

which terminal emulator are you using? that might be the difference.

view this post on Zulip Zeljko Nesic (Apr 14 2022 at 21:39):

I have tested it so far on iTerm2, Kitty and VSCode ... everywhere behaves allright dough ...

view this post on Zulip Richard Feldman (Apr 14 2022 at 21:48):

ha, that was it! I was using macOS default terminal

view this post on Zulip Richard Feldman (Apr 14 2022 at 21:48):

works on kitty! :smiley:

view this post on Zulip Richard Feldman (Apr 14 2022 at 21:49):

@Jared Cone would you be ok with it if I included a demo of roctris in my talk on Tuesday?

view this post on Zulip Zeljko Nesic (Apr 14 2022 at 21:53):

Emacs farts it

view this post on Zulip Jared Cone (Apr 14 2022 at 23:20):

@Richard Feldman absolutely

view this post on Zulip Richard Feldman (Apr 14 2022 at 23:21):

awesome, thanks!

view this post on Zulip Karthik Ravikanti (May 27 2022 at 05:02):

This is probably to be expected, but I'm seeing a "Call parameter type does not match function signature!" (after fixing a few roc standard library changes, I think)

view this post on Zulip Jared Cone (Oct 04 2024 at 16:10):

I've updated https://github.com/jared-cone/roctris to latest roc. Moving on to a 3d game now :)

view this post on Zulip Hrishikesh Dharam (Oct 07 2024 at 17:45):

That's really cool! It looks like you are using unicode block characters for terminal rendering. If you don't mind my asking, how are you handling redrawing the canvas of the game while keeping the game info in the panel on the right? Are you using raw mode to navigate the cursor to specific positions, and only redrawing the parts of the screen that have updated?

view this post on Zulip Jared Cone (Oct 09 2024 at 01:42):

Yep!

view this post on Zulip Jared Cone (Oct 09 2024 at 01:43):

I don't recall if that was actually necessary. I think it was, IIRC clearing and redrawing the whole screen had black flickering


Last updated: Jul 06 2025 at 12:14 UTC