# How to randomise the polygon stimulus?

**URL:** <https://discourse.psychopy.org/t/how-to-randomise-the-polygon-stimulus/45508>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [September 2, 2025, 9:17am UTC](https://discourse.psychopy.org/t/how-to-randomise-the-polygon-stimulus/45508 "2025-09-02T09:17:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daisy.s](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@daisy.s](https://discourse.psychopy.org/u/daisy.s)\
**Post date:** [September 2, 2025, 9:17am UTC](https://discourse.psychopy.org/t/how-to-randomise-the-polygon-stimulus/45508/1 "2025-09-02T09:17:30Z")

</div>

**OS** (e.g. Win10): Win10  
**PsychoPy version** (e.g. 2024.2.4 Py 3.8): 2025.1.1  
**Standard Standalone Installation? (y/n)**: y  
**What are you trying to achieve?:**

I am trying to create a stop-signal reaction time task with four different coloured circles. I have created the circles using the polygon stimulus, and want to randomise their colour - one loop for each learning section (which will happen in three blocks, where ppts will learn the associations between the colours and buttons); and one for the main task.

The only guidance on randomisation I can find is to do with image stimuli, rather than polygon stimuli. I would much rather use polygons as it makes it easier to standardise the size of the circles.

I apologise for the simple question, I am new to PsychoPy! If anyone has any guidance on how to randomise polygons that would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [September 2, 2025, 10:48am UTC](https://discourse.psychopy.org/t/how-to-randomise-the-polygon-stimulus/45508/2 "2025-09-02T10:48:38Z")

</div>

You could have the colours of the polygons in a list and then randomise the order of the list.

e.g.

```auto
colours = ['red', 'green', 'blue']
shuffle(colours)

```

then put the colour as $colours[blocks.thisN]

---

<div class="post-metadata">

**Author:** ![daisy.s](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@daisy.s](https://discourse.psychopy.org/u/daisy.s)\
**Post date:** [September 5, 2025, 9:58am UTC](https://discourse.psychopy.org/t/how-to-randomise-the-polygon-stimulus/45508/3 "2025-09-05T09:58:39Z")

</div>

Thank you for your reply!

I don’t know how to code unfortunately, do you have any tips on how to do this in builder; or where to place this code?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [September 5, 2025, 12:23pm UTC](https://discourse.psychopy.org/t/how-to-randomise-the-polygon-stimulus/45508/4 "2025-09-05T12:23:32Z")

</div>

Try creating a code component (in Builder) and adding this to the Begin Experiment tab.
