Skip to main content
6 of 12
saved 3 bytes
Arnauld
  • 197.8k
  • 20
  • 180
  • 650

#JavaScript (ES7),  216 212  209 bytes

Takes input as (block)(double), where block is either \$1\$ (top right), \$2\$ (bottom right), \$3\$ (bottom left) or \$4\$ (top left) and double is a Boolean value.

b=>d=>(g=x=>y<31?` |-+=OTF
`[X=x-19,Y=y-15,p=X>0^Y>0^b%2,q=Y>0^b/2&1,X*=X,Y*=Y,i=x*24%35<3|16>>Y%62%6&2,x<39?Y?p*X|(d?Y:X-87)>169?0:i-3?X-1|Y-16|q?i:7:q*(d?X-87:Y)%169?6:3:x%38?4:5:8]+g(x<39?x+1:!++y):'')(y=0)

Try it online!

Formatted version

###How?

We iterate from \$y=0\$ to \$y=30\$ and from from \$x=0\$ to \$x=39\$ for each value of \$y\$.

We first define \$X=x-19\$ and \$Y=y-15\$.

The variables p = X > 0 ^ Y > 0 ^ b % 2 and q = Y > 0 ^ b / 2 & 1 are used to determine what do draw in each quarter according to the block \$b\$.

From now on, both \$X\$ and \$Y\$ are squared in order to easily test absolution positions within each quarter of the field.

The expression x * 24 % 35 < 3 yields true if \$x\$ belongs to \$\{0, 3, 19, 35, 38\}\$ (the positions of the vertical lines) or false otherwise.

Try it online!

The expression 16 >> Y % 62 % 6 & 2 yields \$2\$ if \$y\$ belongs to \$\{0, 2, 12, 18, 28, 30\}\$ (the positions of the horizontal lines, excluding the net) or \$0\$ otherwise.

Try it online!

The variable \$i\$ is defined as the result of a bitwise OR between the two values above, and is therefore interpreted as:

  • 0: space
  • 1: |
  • 2: -
  • 3: + or T

The expression (d ? Y : X - 87) > 169 is used to crop the field according to the game type \$d\$ (single or double). The similar expression (d ? X - 87 : Y) % 169 is used to draw the T's at the appropriate positions.

Arnauld
  • 197.8k
  • 20
  • 180
  • 650