Display a cribbage score in ASCII

Matricks, 1441 980 bytes

Hooray for esolangs!

Edit: compressed checking each number into a loop to save a ton of bytes. Also made the bottom part "copy" the top (I need a reverse function). I also replaced most ascii characters with their raw values to save a few more. Also, I fixed a bug in the interpreter where number input wasn't working right.

a45;u[m"|;:5:1;];a[a45;u[m42:5:1;];];a{};a{};z:1;a[m32:6:1;a{a{};};];a{a{};};u{};u{};u{};z5:;v[mic%2:42:32;:1:17;s::"|;;s:16:"|;;s:7:32;s:9:32;v[m32:4:7;s1:2:42;s2:4:42;s3:6:42;a[mi(re3)&(c=1):42:32;:4:3;];a[m32:4:7;s3::42;s2:2:42;s1:4:42;];];s3::"|;;s3:16:"|;;s2::47;s1:1:47;s:2:47;s2:16:92;s1:15:92;s:14:92;v[mi(cT3)&(cE13)&(r=1):45:32;:2:17;];a[m32:7:3;];a[a45;u[m"|;:5:1;];a[a45;u[m42:5:1;];];a{};a{};z:1;v[mic%2:42:32;:1:7;];];];u{z43:10;q1:;u{q5:;};u{q4:;z2:;};u{q3:;z4:;};u{q2:;z6:;};u{q1:;z8:;};u{z10:;};q6:;s2::92;s3:1:92;s4:2:92;s2:16:47;s3:15:47;s4:14:47;b[mi(c%2)&(ce6):42:32;:1:10;];};s:1:48;s:2:-1;j1;
s:1:g:1;+1;s:2:g:2;+1;s::n;;ig:;E36:s(40-g:;)*1.2+2:1+g:2;*2:g:1;;:ig:;T80:s(120-g:;)*1.2+2:21+g:2;*2:g:1;;:i(g:;E76)&(g:;T40):s(g:;-31)*1.2-4:15-g:2;*2:g:1;;:ig:;=37:s3+g:2;:2+g:2;*2:g:1;;:ig:;=38:s2+g:2;:8:g:1;;:ig:;=39:s3+g:2;:14-g:2;*2:g:1;;:ig:;=77:s51+g:2;:16-g:2;*2:g:1;;:ig:;=78:s52+g:2;:18:g:1;;:s51+g:2;:20+g:2;*2:g:1;;;;;;;;;;ig:2;e2:j1;:s::;s:1:;;s:2:;

Takes input on command line: python matricks.py <filename> [[]] <num1>,<num2>,<num3> --asciiprint

Matricks is a language of my own creation. Documentation is on the Github page. The most recent update was a bugfix, no new features added or anything.

Breakdown of this solution:

  1. First block created
  2. Block copied to fill entire board
  3. Top curve
  4. Bottom curve
  5. Checking the placement of each number

Python 2, 615 bytes

def f(a):
 D="-";S=" ";A=S*55+D+S;B="|/4 /41/4 - 2  -4-3   -|/4 /43/4 - 2  -4-1   -".replace("4","    ");C=B.replace("/","\\");s=t=u="";d={"1":0,"2":0,"3":0}
 for i in range(23):j=15>i>7;k=i-i/8;x=k%7*5;y=(6-k%7)*5;M=A+S*52+("123","321")[i<8]+D+S+A;N=chr((x,y)[j]/10+49);Q=("|"+N)[i%2]*5+D;s+=(S+S*5*(i<7)+C[x+39:x+34:-1]*j+B[y+39:y+34:-1]*(i>15)+("| "[i<7]+N)[i%2]+D+Q*(7+(i>15))+("|"+N)[i%2]+B[x:x+5]*(i<7)+C[y:y+5]*j+S*(i<16),(M[::-1],M)[i<8])[i%8==7]
 for x in s:
    if "4">x>"0":d[x]+=1;x=("*"+x)[d[x]==a[x]+1]
    t+=x
 for i in range(1512):j=i/27;k=i%27;u+=t[k*57+(56-j,j)[16>k>10and 51>j>5]]+"\n"*(k>25)
 print u

The function is called by passing in a dictionary that contains the scores. For example:

f({"1":40, "2":70, "3":76})

The byte count reflects indenting the "for x" loop with tabs instead of spaces.

Explanation

The first loop builds the board horizontally into a 57x27 string, with track numbers instead of "holes".

       -|||||-|||||-|||||-|||||-|||||-|||||-|||||-||/
      1-11111-11111-11111-11111-11111-11111-11111-1  /
       -|||||-|||||-|||||-|||||-|||||-|||||-|||||-|  1/
      2-22222-22222-22222-22222-22222-22222-22222-2    -
       -|||||-|||||-|||||-|||||-|||||-|||||-|||||-| 2  -
      3-33333-33333-33333-33333-33333-33333-33333-3    -
       -|||||-|||||-|||||-|||||-|||||-|||||-|||||-|3   -
                                                       -
                                                    321-
                                                       -
    \||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|3   -
   \  3-33333-33333-33333-33333-33333-33333-33333-3    -
  \3  |-|||||-|||||-|||||-|||||-|||||-|||||-|||||-| 2  -
 -    2-22222-22222-22222-22222-22222-22222-22222-2    -
 -  2 |-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|  1\
 -    1-11111-11111-11111-11111-11111-11111-11111-1  \
 -   1|-|||||-|||||-|||||-|||||-|||||-|||||-|||||-||\
 -
 -321
 -
 -   1|-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|
 -    1-11111-11111-11111-11111-11111-11111-11111-11111-1
 -  2 |-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|
 -    2-22222-22222-22222-22222-22222-22222-22222-22222-2
  /3  |-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|
   /  3-33333-33333-33333-33333-33333-33333-33333-33333-3
    /||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|

The second loop copies the string, replacing the numbers with asterisks except at the scoring peg locations. The peg locations in the straight lines in the middle of the track come out backward.

The third loop changes the orientation to vertical, correcting the pegs in the middle track and adding newline characters.

Try it here


Batch, 1302 1099 1096 1079 bytes

@set s= set 
@%s%o=echo 
@%o%off
%s%x=41
%s%y=35
%s%z=121
%s%m=-------
%s%w=     
%s%p=if %1==
%s%q=if %2==
%s%r=if %3==
%s%l=call:l
%l%
%o%%w%%w%%w%%w% %g% %h% %i%
%o%   %m%---- %w%%m%
%l%
%p%38%s%j=1
%o%  /%w%%j%%w%\  %n%
%l%
%q%38%s%j=2
%o% /%f%%w%%j%%w%%a%\ %n%
%l%
%q%37%s%j=2
%q%39%s%k=2
%o%/   %j%   %c%   %k%   \%n%
%l%
%o%^|%w%%c%   %d%%w%^|%n%
%l%
%o%^|%a% %b% %c%%w%%d% %e% %f%^|%n%
%l%
for /l %%a in (1,1,7)do call:b
%o%%m%   %m%   %m%
%o% %a% %b% %c%    ^|%d% %e% %f%%w%%g% %h% %i%^|
%l%
%o%%w%%w%^|%w%%f%   %g%%w%^|
%l%
%q%77%s%j=2
%q%79%s%k=2
%o%%w%%w%\   %j%   %g%   %k%   /
%l%
%q%78%s%j=2
%o%%w%%w% \%i%%w%%j%%w%%d%/
%r%78%s%j=3
%o%%w%%w%  \%w%%j%%w%/
%o%%w%%w%   %m%----
exit/b
:b
%o%%m%   %m%   %m%
for /l %%a in (1,1,4)do call:o
:o
%o%^|%a%^|%b%^|%c%^|   ^|%d%^|%e%^|%f%^|%n%
:l
for %%a in (a b c d e f g h i j k) do%s%%%a=*
%p%%x%%s%a=1
%q%%x%%s%b=2
%r%%x%%s%c=3
%r%%y%%s%d=3
%q%%y%%s%e=2
%p%%y%%s%f=1
%p%%z%%s%g=1
%q%%z%%s%h=2
%r%%z%%s%i=3
%s%n=   ^^^|%g%^^^|%h%^^^|%i%^^^|
set/ax-=1,y+=1,z-=1

Ungolfed:

@echo off
@rem values that pegs at the very top of each column would be
set x=41
set y=35
set z=121
rem deal with the four custom pegs on the top curve
call :loop
echo                      %g% %h% %i%
echo    -----------      -------
call :loop
if %1==38 (set j=1) else set j=*
echo   /     %j%     \     ^|%g%^|%h%^|%i%^|
call :loop
if %2==38 (set j=2) else set j=*
echo  /%f%     %j%     %a%\    ^|%g%^|%h%^|%i%^|
call :loop
if %2==37 (set j=2) else set j=*
if %2==39 (set k=2) else set k=*
echo /   %j%   %c%   %k%   \   ^|%g%^|%h%^|%i%^|
call :loop
echo ^|     %c%   %d%     ^|   ^|%g%^|%h%^|%i%^|
call :loop
echo ^|%a% %b% %c%     %d% %e% %f%^|   ^|%g%^|%h%^|%i%^|
call :loop
rem deal with the 7 sets of 5 standard rows
call :block
call :block
call :block
call :block
call :block
call :block
call :block
rem deal with the four custom pegs on the bottom curve
echo -------   -------   -------
echo  %a% %b% %c%    ^|%d% %e% %f%     %g% %h% %i%^|
call :loop
echo           ^|     %f%   %g%     ^|
call :loop
if %2==77 (set j=2) else set j=*
if %2==79 (set k=2) else set k=*
echo           \   %j%   %g%   %k%   /
call :loop
if %2==78 (set j=2) else set j=*
echo            \%i%     %j%     %d%/
if %3==78 (set j=3) else set j=*
echo             \     %j%     /
echo              -----------
exit/b
:block
echo -------   -------   -------
call :output
call :output
call :output
call :output
:output
rem prints each of the 35 main rows
echo ^|%a%^|%b%^|%c%^|   ^|%d%^|%e%^|%f%^|   ^|%g%^|%h%^|%i%^|
:loop
rem check for pegs in the current row, also works for some of the curve
if %1==%x% (set a=1) else set a=*
if %2==%x% (set b=2) else set b=*
if %3==%x% (set c=3) else set c=*
if %3==%y% (set d=3) else set d=*
if %2==%y% (set e=2) else set e=*
if %1==%y% (set f=1) else set f=*
if %1==%z% (set g=1) else set g=*
if %2==%z% (set h=2) else set h=*
if %3==%z% (set i=3) else set i=*
rem decrement the first and third columns, increment the second column
set/a x-=1
set/a y+=1
set/a z-=1