|
| 1 | +# Two-Armed Bandit Task (HTML Preview) |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +| Field | Value | |
| 6 | +|---|---| |
| 7 | +| Name | Two-Armed Bandit Task | |
| 8 | +| Version | html (v0.2.3-dev) | |
| 9 | +| URL / Repository | https://github.com/TaskBeacon/H000038-two-armed-bandit | |
| 10 | +| Short Description | Browser preview of the two-choice probabilistic reward learning task with block-wise contingencies | |
| 11 | +| Created By | TaskBeacon py2js port | |
| 12 | +| Date Updated | 2026-04-03 | |
| 13 | +| Modality | Behavior | |
| 14 | +| Language | Chinese | |
| 15 | + |
| 16 | +## 1. Task Overview |
| 17 | + |
| 18 | +This HTML companion mirrors the local `T000038-two-armed-bandit` task. Participants repeatedly choose between a left and a right machine, receive stochastic reward feedback, and learn which side is better within each block. The browser preview preserves the local trial contract and response mapping, while shortening the run to a 2-block, 12-trial preview for fast review in the shared runner. |
| 19 | + |
| 20 | +## 2. Task Flow |
| 21 | + |
| 22 | +### Block-Level Flow |
| 23 | + |
| 24 | +| Step | Description | |
| 25 | +|---|---| |
| 26 | +| Load Config | Load the browser preview config. | |
| 27 | +| Show Instructions | Present the Chinese instruction screen. | |
| 28 | +| Initialize Reward Tracker | Start cumulative reward at 0 points. | |
| 29 | +| Generate Conditions | Expand the block-wise left/right reward probabilities into repeated trial conditions. | |
| 30 | +| Run Trials | Execute the same fixation -> choice -> confirmation -> feedback -> ITI flow as the local task. | |
| 31 | +| Block Summary | Show per-block response and reward summary when more than one block remains. | |
| 32 | +| Finalize | Show the final total score and export data through the shared runner. | |
| 33 | + |
| 34 | +### Trial-Level Flow |
| 35 | + |
| 36 | +| Step | Description | |
| 37 | +|---|---| |
| 38 | +| Pre-choice fixation | A central fixation cross is shown briefly. | |
| 39 | +| Bandit choice | Left and right machines are shown; the participant presses `F` or `J`. | |
| 40 | +| Choice confirmation | The selected machine is highlighted briefly. | |
| 41 | +| Outcome feedback | Win/no-win feedback and running total are shown. | |
| 42 | +| Inter-trial interval | A short fixation interval separates trials. | |
| 43 | + |
| 44 | +### Controller Logic |
| 45 | + |
| 46 | +| Feature | Description | |
| 47 | +|---|---| |
| 48 | +| Condition scheduling | A block-specific `(p_left, p_right)` schedule is repeated across trials. | |
| 49 | +| Reward sampling | The chosen side is sampled with Bernoulli reward using the configured probability. | |
| 50 | +| No-response fallback | If the response deadline expires, a configurable fallback choice is imputed. | |
| 51 | +| State tracking | A cumulative reward tracker updates the running score after every trial. | |
| 52 | +| Adaptive control | None. This is a static probabilistic learning task, not a staircase or reversal task. | |
| 53 | + |
| 54 | +### Other Logic |
| 55 | + |
| 56 | +| Feature | Description | |
| 57 | +|---|---| |
| 58 | +| Trial context | Every participant-visible screen emits trial context before `show()` or `captureResponse()`. | |
| 59 | +| Deterministic QA seed | Preview sampling uses the configured block seeds for reproducible browser QA runs. | |
| 60 | +| Summary metrics | Block and final summaries report left-choice rate, win rate, response rate, and total score. | |
| 61 | + |
| 62 | +## 3. Configuration Summary |
| 63 | + |
| 64 | +Settings are defined in `config/config.yaml`. |
| 65 | + |
| 66 | +### a. Subject Info |
| 67 | + |
| 68 | +| Field | Meaning | |
| 69 | +|---|---| |
| 70 | +| `subject_id` | Numeric participant identifier supplied by the shared runner. | |
| 71 | + |
| 72 | +### b. Window Settings |
| 73 | + |
| 74 | +| Parameter | Value | |
| 75 | +|---|---| |
| 76 | +| `window.size` | `[1280, 720]` | |
| 77 | +| `window.units` | `pix` | |
| 78 | +| `window.screen` | `0` | |
| 79 | +| `window.bg_color` | `black` | |
| 80 | +| `window.fullscreen` | `false` | |
| 81 | +| `window.monitor_width_cm` | `35.5` | |
| 82 | +| `window.monitor_distance_cm` | `60` | |
| 83 | + |
| 84 | +### c. Stimuli |
| 85 | + |
| 86 | +| Name | Type | Description | |
| 87 | +|---|---|---| |
| 88 | +| `instruction_text` | text | Chinese instructions describing the left/right machine choice task. | |
| 89 | +| `fixation` | text | Central fixation marker shown before choice and during ITI. | |
| 90 | +| `machine_left` / `machine_right` | rect | Left/right machine panels. | |
| 91 | +| `machine_left_label` / `machine_right_label` | text | Left/right machine labels. | |
| 92 | +| `highlight_left` / `highlight_right` | rect | Selected-machine highlight overlays. | |
| 93 | +| `choice_prompt` | text | Prompt asking the participant to choose a machine. | |
| 94 | +| `target_prompt` | text | Brief confirmation of the selected machine. | |
| 95 | +| `feedback_win` / `feedback_loss` | text | Reward outcome feedback with the updated score. | |
| 96 | +| `block_break` | text | Optional block summary for multi-block preview runs. | |
| 97 | +| `good_bye` | text | Final total score shown at task completion. | |
| 98 | + |
| 99 | +### d. Timing |
| 100 | + |
| 101 | +| Phase | Duration | |
| 102 | +|---|---| |
| 103 | +| `timing.pre_choice_fixation_duration` | `0.5 s` | |
| 104 | +| `timing.bandit_choice_duration` | `2.5 s` | |
| 105 | +| `timing.choice_confirmation_duration` | `0.4 s` | |
| 106 | +| `timing.outcome_feedback_duration` | `0.8 s` | |
| 107 | +| `timing.iti_duration` | `0.6 s` | |
| 108 | + |
| 109 | +### e. Browser Preview Differences |
| 110 | + |
| 111 | +| Parameter | Meaning | |
| 112 | +|---|---| |
| 113 | +| `task.total_blocks` | Shortened to 2 for preview. | |
| 114 | +| `task.trial_per_block` | Shortened to 6 for preview. | |
| 115 | +| `task.total_trials` | Shortened to 12 for preview. | |
| 116 | +| `condition_generation.block_probabilities` | Uses the first two block contingencies from the full local task. | |
| 117 | + |
| 118 | +## 4. Methods (for academic publication) |
| 119 | + |
| 120 | +The HTML companion presents the same two-armed bandit learning task as the local PsychoPy build, but inside the shared browser runner. On each trial, participants choose one of two machines with block-specific reward probabilities, receive stochastic feedback, and update their choice strategy over time. The preview keeps the same stage order, scoring meaning, and timeout/fallback behavior as the local task while shortening the overall run length for browser testing and gallery navigation. |
| 121 | + |
| 122 | +## Run |
| 123 | + |
| 124 | +Open the TaskBeacon browser runner and launch `H000038-two-armed-bandit` to inspect the preview. |
0 commit comments