#!/usr/pkg/bin/perl use strict; use warnings; use utf8; use lib qw( /usr/pkg/lib/perl5/5.24.0 /meta/p/peteyboy/perl5/lib/perl5 ); #make request for all of the following use CGI::Tiny; use Mojo::Template; use Mojo::Loader 'data_section'; #use Routes::Tiny; #don't even need use Readonly; #=== # MAKE SURE ORIGIN PAGE MATCHES FILENAME (especially if you are testing changes)! # #=== my $ORIGIN_PAGE = "/wordle-life.cgi"; my $defaulttext = "Paste your wordle share here"; cgi { #error handler from the CGI:Tiny cookbook my $cgi = $_; $cgi->set_error_handler(sub { my ($cgi, $error, $rendered) = @_; warn $error; unless ($rendered) { if ($cgi->response_status_code == 413) { $cgi->render(json => {error => 'Request body limit exceeded'}); }elsif ($cgi->response_status_code == 400) { $cgi->render(json => {error => 'Bad request'}); } else { $cgi->render(json => {error => 'Internal server error'}); } } }); my $wordle; my $method = $cgi->method; my $rle = ""; #Simple switch: make a one page app, and always go back to the same page. #GET or HEAD loads the page blank, POST runs the Life file maker if ($method eq 'GET' or $method eq 'HEAD') { $wordle = $defaulttext; #$wordle = ""; } elsif ($method eq 'POST') { #textarea name, pull the value from POST and reload into textarea $wordle = $cgi->body_param('wordle-result'); #if input textarea not changed from default text, do nothing unless ($wordle =~ /\Q$defaulttext\E/) { #[Cc] /){ #cheat, if they put in something that looks like an RLE, pass output through if ($wordle =~ /^#[Cc] /){ $rle = $wordle; #if none of that, do the thing: generate RLE }else{ $rle = generate_rle($wordle); } } } else { #some other request? PUT, DELETE? $cgi->set_response_status(405)->render; exit; } die "Invalid wordle parameter" unless length $wordle; #Load template from DATA section and output my $mt = Mojo::Template->new(auto_escape => 1, vars => 1); my $template = data_section __PACKAGE__, 'index.html.ep'; my $output = $mt->render($template, { ORIGIN_PAGE =>$ORIGIN_PAGE, defaulttext => $defaulttext, wordle => $wordle, rle => $rle }); #my $output = $mt->render($template, {wordle => $wordle}); $cgi->render(html => $output ); }; #Try to Generate the RLE. Makes a lot of assumptions sub generate_rle { my $headline = ""; my $rleline; my $rowcount; my $myline; Readonly my $headline_prefix => "#C "; #Part of RLE spec https://conwaylife.com/wiki/Run_Length_Encoded Readonly my $row_prefix => "x = 5"; #for wordle always 5 Readonly my $col_prefix => ",y = "; my $wordle = shift; # this is how you get variables in your function call! $rowcount = 0; my @lines = split /^/, $wordle; foreach $myline (@lines) { chomp($myline); if ($headline eq "" && $myline =~ /Wordle/){ $headline = $headline_prefix . $myline; }else{ #in case of text mode $myline =~ s/\R//; $myline =~ s/^(.*)$/$1\$/; $myline =~ s/:yellow_square:/o/g; $myline =~ s/:green_square:/o/g; $myline =~ s/:[a-z-]*square:/b/g; # for normal unicode $myline =~ s/\N{U+1f7e8}/o/g; #yellow $myline =~ s/\N{U+1f7e9}/o/g; #green $myline =~ s/\N{U+2B1B}/b/g; #black $myline =~ s/\N{U+2B1C}/b/g; #white #broken copy/paste text $myline =~ s/black_large_square/b/g; $myline =~ s/white_large_square/b/g; $myline =~ s/yellow_square/o/g; $myline =~ s/green_square/o/g; #skip blank lines, count rows added if(length($myline) > 1){ $rowcount += 1; $rleline= $rleline . $myline; } } } #this is the format with b,o, and $. Done lazily because I don't compress the repeated b or o. return "$headline\n$row_prefix$col_prefix$rowcount\n$rleline"; } __DATA__ @@ index.html.ep Play Conway's Life with your Wordle Score

Wordle->Life

Play your Wordle Share score in Conway's Life!

Hey, nerds, isn't it funny how the Wordle Scores can look like a glider in that old computer programming exercise, Conway's Life?

Glider image from Conwaylife.org, it looks like an 8-bit staple gun
  1. Paste your wordle share below and submit to convert it to a Conway's Life file so you can run it (to learn more about Conway's Life, read this).


  2. Click "Submit" and and RLE format file for Conway's Game of Life will appear in the box below and get loaded into the Life Viewer.

  3. Watch your Wordle score play LIFE!

    If the RLE is correct, it should be loaded in the Life Viewer, and so you are ready to go!

    • For best results with the Life Viewer, adjust the Zoom and the playback speed (from "1x", slide left to "3/s" or so) and press the Play button:

    • Press "[Pause]" when it seems stable.

This should work with the share/copy button in wordle, or copy/pasting your friends' wordles out of Discord or wherever as well. See whose Wordle Score runs the coolest!

If it doesn't seem to be working:

  1. If there is extra text or lines in your paste, you might not get a valid file in the box above, so look and make sure it looks like a proper RLE file, for example:

    #C Wordle 235 3/6
    x = 5,y = 3
    boobo$bobbo$ooooo$
    

    For details about the Life RLE file format above, read this.

  2. You can also copy the contents of the Conway Life box above and try it somewhere else:
    1. go to a Conway's Life site, such as this one at copy.sh or this one at lazyslug.com and load and run your file.
      1. specifically for the one at copy.sh:
      2. Press the [Import] button at the top
      3. paste in your Life file contents in the box and press [Import]
      4. It will put up a box telling you it loaded your Wordle, press [OK]
      5. Press the [Run] button and watch your Wordle score play LIFE!


Disclaimer: I made this! People and/or corporations may own their marks or copyrights, etc, on words mentioned on this page I don't claim to

Questions, kudos or comments, mail me @sdf.org

Thanks to the community at conwaylife.com, and the friendly folks in the forums there, and for their Javascript Life Viewer, which I use here.

Thanks to hankchizljaw for making his basic css publicly available

Made in February 2022

Hosted by SDF.org

SDF.org

@@ viewer.html.ep Play Conway's Life with your Wordle Score

Wordle->Life

Play your Wordle Share score in Conway's Life!

Hey, nerds, isn't it funny how the Wordle Scores can look like a glider in that old computer programming exercise, Conway's Life?

Glider image from Conwaylife.org, it looks like an 8-bit staple gun
  1. Paste your wordle share below and submit to convert it to a Conway's Life file so you can run it.

    To learn more about Conway's Life, read this


  2. Click "Submit" and and RLE format file for Conway's Game of Life will appear below.

if there is extra text or lines in your paste, you might not get a valid file here, so look and make sure it looks like a proper RLE file, for example:

#C Wordle 235 3/6
x = 5,y = 3
boobo$bobbo$ooooo$

For details about the Life RLE file format above, read this.

Next steps:

  1. copy the contents of the Conway Life box above
  2. go to a Conway's Life site, such as this one at copy.sh or this one at lazyslug.com and load and run your file.
    1. specifically for the one at copy.sh:
    2. Press the [Import] button at the top
    3. paste in your Life file contents in the box and press [Import]
    4. It will put up a box telling you it loaded your Wordle, press [OK]
    5. Press the [Run] button and watch your Wordle score play LIFE!

This should work with the share/copy button in wordle, or copy/pasting your friends' wordles out of Discord or wherever as well. See whose Wordle Score looks coolest!


Disclaimer: I made this! People and/or corporations may own their marks or copyrights, etc, on words mentioned on this page I don't claim to

Questions, kudos or comments, mail me @sdf.org

Thanks to hankchizljaw for making his basic css publicly available

Made in February 2022

Hosted by SDF.org

SDF.org