Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

help with code

edited May 2018 in OpenSesame

Hi All
I want to make an algoritem that goes like this:
1. chose radius
2. decide if its "long" or " short"/
3. if long do
3.1 for each radius (1-5) decide
3.1.1 or same--> and gap=0
3.1.2 or different--> chose randomly from 10 options

I hope it was clear.
this is what i did. but its not work good.

import numpy as np
from random import shuffle
import random
from random import uniform
RadiusList = [1,2,3,4,5,6]
NOC= 5 #NumberOfCircles
if (var.num>0.2):
    for Radius in range(0,NOC):
        print (Radius)
        var.Comparison= np.random.choice([0, 1], size=(NOC,), p=[3./4, 1./4])
        if var.Comparison==1:
            RadiusList[Radius]= int(var.RadiusBase)
            var.set(VarCorrect, var.Key_same)
            RadiusList[Radius]= round(var.RadiusBase*(1+var.Gaps[Radius]))
            var.set(VarCorrect, var.Key_Diff)   

thanks for your help


  • edited May 2018

  • Hi,

    I don't know what exactly you want to do but line 17: if var.Comparison==1: is the problem currently.
    You created a numpy array that has 5 (NOC) items. Therefore, python doesn't know whether it is true or false when you compare it to 1. You either have to compare the entire list to another list, make var.Comparison have only a single item, or test whether all or any of the items of var.Comparison are equal to 1.

    If you give more detail on what it is that you want to accomplish I might be able to help more.


  • Hi,
    my problem now is that i want the program to make me 2 options- SHORT\LONG.
    in the LONG one- In the long section, I need it to randomly skip between the Gaps, and choose 5 different Gaps each time. Right now it chooses the same Radius as the practice WITHOUT GAPS.
    this is the script:

    this is BAD logger:

    this is what i want it to do:

    ** i want that in the logger i can see in the LONG section the Radius*gap that was randomly chosen**
    and that in the logger will be different "Circle_Blue1","Circle_Blue2"...

    i hope it was clear

  • someone?

  • I do not exactly understand what you mean. But maybe your problem is a logging problem.
    If you do not want the second variable (whatever its called, maybe Circle_Blue2?) to vary, you need to log the changes in your inline script.

    use log.write_vars() instead of print
    print puts the result in your debug window, so you may see them there ;)

    One more point: The logged variables have the names you give them, e.g. "Gaps", "Type" etc. (see var.Gaps). Maybe you have not looked for them at the right point in your output yet?

Sign In or Register to comment.