# Randomizing the polygons

**URL:** <https://discourse.psychopy.org/t/randomizing-the-polygons/16049>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [August 28, 2020, 10:37pm UTC](https://discourse.psychopy.org/t/randomizing-the-polygons/16049 "2020-08-28T22:37:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![duyguyucel](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@duyguyucel](https://discourse.psychopy.org/u/duyguyucel)\
**Post date:** [August 28, 2020, 10:37pm UTC](https://discourse.psychopy.org/t/randomizing-the-polygons/16049/1 "2020-08-28T22:37:32Z")

</div>

Hello,

I use PsychoPy2.2. I want to randomize the polygons I have created in Builder. How can I do this by inserting a loop in Builder?

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [August 30, 2020, 5:33pm UTC](https://discourse.psychopy.org/t/randomizing-the-polygons/16049/2 "2020-08-30T17:33:41Z")

</div>

What about a polygon stimulus do you want to randomize: the position, the color, the presentation time, …? You’ll have to provide more information.

---

<div class="post-metadata">

**Author:** ![duyguyucel](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@duyguyucel](https://discourse.psychopy.org/u/duyguyucel)\
**Post date:** [August 31, 2020, 10:53am UTC](https://discourse.psychopy.org/t/randomizing-the-polygons/16049/3 "2020-08-31T10:53:44Z")

</div>

I want to randomize the position and the color. For example red circle will always come up at (0,3.5), blue circle will come up at (3.5,0) and the orange circle will come up at (-3.5,0). Totally I have 8 colorful circles.

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [August 31, 2020, 1:46pm UTC](https://discourse.psychopy.org/t/randomizing-the-polygons/16049/4 "2020-08-31T13:46:22Z")

</div>

The builder allows you to [enter parameters](https://psychopy.org/builder/components.html#entering-parameters) in component fields.

With these parameters, you can [access variables defined in a conditions file](https://psychopy.org/builder/flow.html#accessing-loop-parameters-from-components).  
You mention position. You could have a .csv file with one column of x values and one column of y values. Similarly, you could have a .csv file with rgb values or strings for your colors.

For the [loops you can then select a method of constants](https://psychopy.org/builder/flow.html#loops), which determines how the values from your conditions file are randomized.  
You could for example enter $(x, y) as position.

Have a look at some of the demos, which you can unpack from Demos \> Unpack Demos…  
Going over the Stroop demo may help you to learn how randomization works in Psychopy. In your case you might want `random` or `fullRandom`.
