⚾ Round The Bases! - Code Golf Challenge!

Deadline: Never

You just hit a home run! In this challenge, you must construct a baseball diamond in ASCII and print it to the console.

Example:

       V






V      M      V





         
       V       

Final Result Example:

Summary
       P
      P P
     P   P
    P     P
   P       P
  P         P
 P           P
P      M      P
 P           P
  P         P
   P       P
    P     P
     P   P
      P P
       P       

Requirements / Guidelines:

  • The baseball diamond board must be 15 rows and 15 columns.

  • Whitespaces are the unit of measurement! Each 0 represents a single " " whitespace.

  • The console refresh rate of “printing/clearing the console” must be 25fps

  • The letter V must represent the bases.

  • The letter P must represent the player.

  • The letter M must represent the Pitcher’s mound (center of the diamond)

  • The speed the player runs around the bases must be every half a second.

  • Each base the player touches must be changed to a P. See example below:

  • The player must start from home base.

  • Once the player returns home, the app will exit.

The submission with the least amount of bytes wins!

edit: Yes, this isn’t a real diamond as displayed in the picture. But it’s good enough :)

2 Likes

Least amount of bytes: source code or binary?

1 Like

I believe that traditionally Code Golf uses source code size to determine scores.

1 Like

never tried code golfing, so my first entry:

360.times{|i|s=i/12.5;puts "\e[2J";(-7..7).each{|y|(-7..7).each{|x|print x.abs+y.abs==7?((x>0?s>7-y: s-21>y)?"P":(x.abs==7||y.abs==7?"V": " ")): x==0&&y==0?"M": " "};puts ""};sleep 0.04}

(186 chars)

4 Likes

Sorry, forgot to mention! Just the source code.

Konovod


@konovod That is… AWESOME!

You can shove off a little bit from @konovod’s solution:
360.times{|i|s=i/12.5;puts "\e[2J";r=-7..7;r.each{|y|r.each{|x|print x.abs+y.abs==7?((x>0?s>7-y: s-21>y)?"P":(x.abs==7||y.abs==7?"V": " ")): x==y==0?"M": " "};puts};sleep 0.04}
(176 chars)

3 Likes
360.times{|i|s=i/12.5;puts "\e[2J";r=-7..7;r.map{|y|r.map{|x|print x.abs+y.abs==7?((x>0?s>7-y: s-21>y)?:P:(x.abs==7||y.abs==7?:V: " ")): x==y==0?:M: " "};puts};sleep 0.04}

(171 chars)

3 Likes

For the last puts at the end, you should be able to do p instead :stuck_out_tongue:

1 Like