Howdy, Stranger!

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

Supported by

[solved] Rnd Positions - Inline Script - Newbie

edited January 2014 in OpenSesame

Hello everybody,

I am new to OpenSesame and trying to create my first experiment with it, but I have some problems:

My experiment is a calculation task, where subjects have to calculate a problem (e.g. 6x7) and on the next screen choose an answer with the mouse out of seven choices presented in an ellipse. This is what the general program structure looks like:

image

Within all the different loops for each trial I have the following variables: Operand 1, Operand 2, Choice 1, ..., Choice 7, x-Coordinate 1, y-Coordinate 1, ..., x-Coordinate 7, y-Coordinate 7 (op1, op2, choice1, ..., choice7, x1, y1, ..., x7, y7)

My goal is simple: I just want to randomly set the positions for each trial. Thats why after showing the calculation problem with the two operands (problem_symbolic) I inserted the following inline script (randomly_set_positions_symbolic):

Prepare phase: #empty
Run phase:

import random
coords = [[0, -220],[248,-160],[340,80],[128,222],[-128,222],[-340,80],[-248,-160]]
random.shuffle(coords)
for i in range(1,8):
    xvar = "x" + str(i)
    yvar = "y" + str(i)
    c = coords.pop()
    x = c.pop(0)
    y = c.pop()
    exp.set(xvar, x)
    exp.set(yvar, y)

If I try to run it, all answer choices end up in the centre of the screen, so the preassigned 0 0 coordinates are not overwritten by the script.

This is what the answer_symbolic sketchpad looks like:

set duration "0"
set description "Displays stimuli"
set start_response_interval "yes"
draw circle 0 -220 250 fill=0 penwidth=3 color=white show_if="always"
draw circle 128 222 250 fill=0 penwidth=3 color=white show_if="always"
draw circle -248 -160 250 fill=0 penwidth=3 color=white show_if="always"
draw circle 248 -160 250 fill=0 penwidth=3 color=white show_if="always"
draw circle -128 222 250 fill=0 penwidth=3 color=white show_if="always"
draw circle -340 80 250 fill=0 penwidth=3 color=white show_if="always"
draw circle 340 80 250 fill=0 penwidth=3 color=white show_if="always"
draw textline [x1] [y1] "[choice1]" center=1 color=white font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always" html="yes"
draw textline [x2] [y2] "[choice2]" center=1 color=white font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always" html="yes"
draw textline [x3] [y3] "[choice3]" center=1 color=white font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always" html="yes"
draw textline [x4] [y4] "[choice4]" center=1 color=white font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always" html="yes"
draw textline [x5] [y5] "[choice5]" center=1 color=white font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always" html="yes"
draw textline [x6] [y6] "[choice6]" center=1 color=white font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always" html="yes"
draw textline [x7] [y7] "[choice7]" center=1 color=white font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always" html="yes"

Can anybody who has experience with OpenSesame please help me with this? It should not be a difficult task I guess ;)

Thank you very much in advance for any idea!

Cheers,
Hannes

Comments

  • edited January 2014

    Hi Hannes,

    You've actually done a really good job, there's simply a single detail you might have overlooked: a sketchpad is constructed in the Prepare Phase. Since your inline_script is run only in the Run Phase the variables used in your sketchpad (x1,...,x7, and y1,...,y7) are not properly defined yet. That is: the variables are defined, but they still have the preassigned values that you mention.

    The solution is very simple: move your code from the Run Phase to the Prepare Phase and you should be good to go!

    EDIT: Thought this might be useful. If you want to know more about the difference between the two phases, and why OpenSesame uses an approach in which your stimuli are pre-created before they are run, please see this page on the Documentation website.

    Good luck!

    Edwin

  • edited 12:43AM

    Hey Edwin,

    thank you soooo much for your quick help, it works perfect now!

    And also thanks a lot for the link!! I guessed it would be some stupid mistake on my side since I don't know OpenSesame well yet.

    I really appreciate your fast support, getting started in a new environment can be frustrating in the beginning when encountering problems like this.

    Have a nice day,

    cheers
    Hannes

  • edited 12:43AM

    Hi Hannes,

    That's excellent, very good to hear that you've got things running and that you're happy with us! I'll mark the issue as solved, and I wish you the best of luck with your experiment.

    Cheers!

    Edwin

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games