# 10 print chr$(205.5+rnd(1)); : goto 10

**URL:** <https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483>\
**Category:** Coding Questions\
**Created:** [November 14, 2019, 10:30am UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483 "2019-11-14T10:30:45Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 17, 2019, 8:41pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/42 "2019-11-17T20:41:33Z")

</div>

Those radial mazes are quite fun! Consider this example as well – it isn’t written to be compact, but to show an (animated) equivalent to how the original 10PRINT is two randomized edges on a 45-degree angle rather than four on a cartesian grid.

```auto
/**
 * Radial 10PRINTing
 * Jeremy Douglass 2019-11-17 Processing 3.4
 * 
 */
float r; // radius
float rs = 10; // radius step
float a; // angle
float as = PI/16; // angle step

void setup() {
  size(400, 400);
  background(255);
  r = 2*rs;
}

void draw() {
  translate(width/2.0, height/2.0); // centered
  if (random(1)>0.5) {
    line(sin(a)*r, -cos(a)*r, sin(a+as)*(r+rs), -cos(a+as)*(r+rs)); // forward slash
  } else {
    line(sin(a)*(r+rs), -cos(a)*(r+rs), sin(a+as)*r, -cos(a+as)*r); // backslash
  }
  a += as; // advance around ring
  if (a>TWO_PI) {
    a = 0; // marks line *and* clips accumulating floating-point error
    r += rs; // expand ring
  }
  if (r > width*0.71) frameCount = -1; // auto-reset when offscreen (for square screens)
}

```

![Radial10PRINTing_20191117122055](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/877fa178770a2f0be6072b952b0f210750bb0baa.png) ![Radial10PRINTing_20191117122055](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/474ac6b2e25f6483a7ac3605ceb2fd1e0b8b84f7.gif)

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [November 17, 2019, 8:53pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/44 "2019-11-17T20:53:11Z")

</div>

Very nice indeed.

This movie shows the original code and a Commodore 64 display:

[![](https://img.youtube.com/vi/m9joBLOZVEo/hqdefault.jpg "10 PRINT CHR$(205.5+RND(1)); : GOTO 10") ](https://www.youtube.com/watch?v=m9joBLOZVEo)

If you were to thicken the lines and use some of those C64 colours (just saying):

#FFFFFF, #744335, #7CACBA,  
#7B4890, #64974F, #403285, #BFCD7A,  
#7B5B2F, #4f4500, #a37265, #505050,  
#787878, #a4d78e, #786abd, #9f9f9f

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 17, 2019, 9:16pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/45 "2019-11-17T21:16:08Z")

</div>

> [@glv](#):
>
> I thought I should be able to do the same with a circular maze and started modifying my vectors.

Great!

Right now your inner and outer slashes / walls are the same length. The key thing is that each line is anchored on the subdivisions of a ring-- 16ths, 24ths, whatever – by a certain number of steps n and n+1 / n-1. One part of the wall is on the inner ring, one is one the outer. If the ring is divided into n steps, then the we know the angle of each location – if we know the angle and the size of the ring, we can find the point. Note that the wall segments are getting longer and longer as the rings grow out (instead of each segment having the same fixed length – then they just get farther and farther apart).

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [November 17, 2019, 9:17pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/46 "2019-11-17T21:17:42Z")

</div>

> [@paulstgeorge](#):
>
> use some of those C64 colours (just saying)

Sure, if that’s your jam:

```auto
void setup() {
  size(400, 400);
  background(60, 60, 120);
  strokeWeight(3);
  strokeCap(ROUND);
  stroke(124, 124, 228);
  r = 2*rs;
}

```

![Radial10PRINTing_20191117131026](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0aed71e29db7d523866c94e5bce493690149cddc.png)

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [November 18, 2019, 7:45am UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/47 "2019-11-18T07:45:05Z")

</div>

Now that, sir, is a work of art!

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [November 18, 2019, 5:37pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/48 "2019-11-18T17:37:49Z")

</div>

Well people, a maze is incomplete until we have someone to find their way to the goal.

That someone could be a ball-bearing, a puddle of mercury, a genre-defying Pac-Man, one of Schrödinger’s cats in a multiverse of mazes, anything you like. Whatever it is, the object could find its way to the goal by using edge detection, calculating the shortest route by first taking a view of the complete maze, following all possible routes at the same time and then evaporating in a quantum cloud of dust when a cul-de-sac is reached, or the player could guide the ball through the labyrinth by tilting in the vertical or horizontal plane (a simple mouse movement should do it).

[Pac-Man](https://www.google.com/logos/2010/pacman10-i.html)

What do you think? Can we do it?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 18, 2019, 7:01pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/49 "2019-11-18T19:01:48Z")

</div>

Yesterday night I was reading the maze solving algorithms at wikipedia. But I would like to implement my own, by distance measuring. But unfortunately I have a project to complete this week. But definitely I want to try it.

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [November 18, 2019, 8:36pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/50 "2019-11-18T20:36:02Z")

</div>

Excellent! @noel

```auto
void setup() {
  size(400,400);
  background(0);
  pacMan();
}

void pacMan() {
  noStroke();
  fill(255,255,0);
  arc(200,200,200,200,PI/4,(2*PI)-PI/4);
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 19, 2019, 8:06am UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/51 "2019-11-19T08:06:31Z")

</div>

Woke up, a lot of stuff to do, but couldn’t resist. Had to walk.

```auto
int i;
float j;
boolean closed;

void setup() {
  size(600, 400);
  background(0);
  noStroke();
}

void draw() {
  fill (0);
  ellipse (i-1, 200, 210, 210);
  fill(255, 255, 0);
  arc(i, 200, 200, 200, j, 6);
  i += 4;
  if (j > 0.6) closed = true;
  if (!closed ) j += 0.05; 
  else j -= 0.05;
  if (j < 0) closed = false;
  if (i > 700) i = 0;
}

```

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [November 19, 2019, 8:06pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/52 "2019-11-19T20:06:49Z")

</div>

Excellent walking. I am working on adapting this so the Pac-Man walks left or right (and up or down) according to how the maze has been tilted. The maze is tilted by moving the mouse, but could be haptic on a smart device.  
Will think about constraining the movement later…

---

<div class="post-metadata">

**Author:** ![mnoble](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnoble/32/99_2.png) [@mnoble](https://discourse.processing.org/u/mnoble)\
**Post date:** [October 31, 2020, 4:44pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/53 "2020-10-31T16:44:51Z")

</div>

Love this design glv!

---

<div class="post-metadata">

**Author:** ![codeguppy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codeguppy/32/8322_2.png) [@codeguppy](https://discourse.processing.org/u/codeguppy)\
**Post date:** [November 3, 2020, 1:15am UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/54 "2020-11-03T01:15:23Z")

</div>

This is one of the coolest things you can try with processing

 ![commodore](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e30b8709f4bc5f177dddcddf6aae3e77a295871b.png)

A different way to implement this in processing is to define 2 small images for the characters / and . You have great support in processing for new p5.Images.

Once you do this you can just randomly display the characters (aka Images) on screen as the old Commodore 64 used to do.

This is an example from [codeguppy.com](http://codeguppy.com) - (note that the code to define images is not shown since [codeguppy.com](http://codeguppy.com) has this built in on top of p5.js). Anyway – you can do this outside [codeguppy.com](http://codeguppy.com) with the above mention and a little bit of extra implementation.

[https://codeguppy.com/code.html?t=commodore\_patterns&list=pixelart](https://codeguppy.com/code.html?t=commodore_patterns&list=pixelart)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 4, 2021, 11:29pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/55 "2021-08-04T23:29:40Z")

</div>

A bit leaner than [my last version](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/18).

```auto
size(529,529);for(int x=1,y=0,n=23;x<n*n;x++){int r=int(random(2))*n,t=x%n*n;line(t+r,y,t+n-r,y+n);if(t==0)y+=n;}

```

```auto
size(529, 529);
for(int x=1, y=0, n=23; x<n*n; x++)
  {
  int r=int(random(2))*n, t=x%n*n;
  line(t+r, y, t+n-r, y+n);
  if (t==0) y+=n;
  }

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1ac1a3e4ef16e73a75b4f973f452f65007801c15.png)

`:)`

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [August 5, 2021, 1:57pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/56 "2021-08-05T13:57:21Z")

</div>

> [@glv](#):
>
> ```auto
> size(529,529);for(int x=1,y=0,n=23;x<n*n;x++){int r=int(random(2))*n,t=x%n*n;line(t+r,y,t+n-r,y+n);if(t==0)y+=n;}
> 
> ```
> 
> ```auto
> 
> ```

Wow! Is that the leanest? Ever?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 18, 2021, 4:33am UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/57 "2021-08-18T04:33:17Z")

</div>

That is some code golf right there.

> [@paulstgeorge](#):
>
> Wow! Is that the leanest? Ever?

You can still shave off the `size` and set n=10 to take advantage of the default size=100x100.

```auto
for(int x=1,y=0,n=10;x<n*n;x++){int r=int(random(2))*n,t=x%n*n;line(t+r,y,t+n-r,y+n);if(t==0)y+=n;}

```

That’s 99 characters. Other than that,I can’t figure out how to shave off a character – I tried a couple approaches with `while`, but it got just a bit longer.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [August 18, 2021, 7:18am UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/58 "2021-08-18T07:18:24Z")

</div>

y=0 …. wondering won‘t 0 be the default anyway so skip  
=0

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 18, 2021, 2:37pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/59 "2021-08-18T14:37:13Z")

</div>

> [@jeremydouglass](#):
>
> ```auto
> for(int x=1,y=0,n=10;x<n*n;x++){int r=int(random(2))*n,t=x%n*n;line(t+r,y,t+n-r,y+n);if(t==0)y+=n;}
> 
> ```

That would work in Python, but Java is “belt and braces” and requires int initialization. Java is a pretty tough language for a good code golf score. 😉

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [August 18, 2021, 4:54pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/60 "2021-08-18T16:54:31Z")

</div>

You are correct

thank you!

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [August 20, 2021, 7:23am UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/61 "2021-08-20T07:23:13Z")

</div>

People!

Brevity is the soul of wit, golf, and much code. But many of the solutions here have something extra, and that is elegance. I suppose elegance is a short apparently simple statement (equation, sonnet, code, etc.) that when unpacked is huge and complex. An example would be the most beautiful equation in the world, "pow(e, i\*PI) + 1 = 0”, seen in a freeze-frame of Lisa Simpson’s book cover in ‘MoneyBart’ and named after Leonhard Euler.

I have been trying to find an elegant way to generate the permutations of all the members of a set. I can write code that does the job but it is far from elegant and certainly not brief. Perhaps this should be the subject of a new thread.

e = e = 2.71828; // Euler’s number  
i = sqrt(-1); // imaginary

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 20, 2021, 6:15pm UTC](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483/62 "2021-08-20T18:15:13Z")

</div>

Split this topic on August 20, 2021, 6:15pm UTC

3 posts were merged into an existing topic: [Is there an elegant way to generate the permutations of all the members of a set?](https://discourse.processing.org/t/is-there-an-elegant-way-to-generate-the-permutations-of-all-the-members-of-a-set/31810/4)

[Previous page](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483.md?page=2)

[Next page](https://discourse.processing.org/t/10-print-chr-205-5-rnd-1-goto-10/15483.md?page=4)
