This repository contains the implementation for the paper Task Synthesis for Elementary Visual Programming in XLogoOnline Environment.
The project is organized as follows:
scripts
: Contains scripts for task synthesis using various methods.src
xlogomini
: Utility functions for the XLogoOnline-Mini platform.xlogominidatagen
: Source code for task synthesis.
To install the required dependencies, run:
pip install -r requirements.txt
To load the reference task and code JSON files:
from src.xlogomini.utils.load_data import load_task_json, load_code_json
task_id = '87'
task_json = load_task_json(task_id)
code_json = load_code_json(task_id)
To visualize a task:
from src.xlogomini.utils.image_conversions import task2image
task_id = '87'
task_json = load_task_json(task_id)
task2image(task_json, show=True, save=False, show_desc=True)
To display the code for a task:
from src.xlogomini.utils.load_data import load_code_json
from src.xlogomini.components.code.xlogo_code import Code
task_id = '87'
code_json = load_code_json(task_id)
print(Code(code_json))
# Example output:
# fd
# rt
# repeat(3){
# fd
# }
# rt
# fd
To execute the code within a task:
import src.xlogomini.emulator.executor as executor
task_id = '87'
task_json = load_task_json(task_id)
code_json = load_code_json(task_id)
executor.execute(task_json, code_json)
# Example output: {'crashed': False, 'crashed_msg': None, 'goal_ok': True, 'cons_ok': True, 'err_msg': 'OK'}
We provide two techniques for task synthesis: XLogoSyn
and RotateFlip
.
To synthesize tasks using XLogoSyn
, run:
bash scripts/xlogosyn.sh
The following directories will be created:
./results/datagen/code
: Generated code JSON files../results/datagen/goal
: Generated goal JSON files../results/datagen/task
: Generated task JSON files../results/datagen/params
: Parameters used for data generation../results/datagen/image
: Images of the generated tasks.
In the script, you can specify the --task_id
and the --diff
parameters. There are three difficulty levels available for tasks: easy
, medium
, and hard
.
Note: Running the above script may take some time, ranging from a few seconds to several hours, depending on the specific tasks and parameters set in the script. The exact time and parameters used will be saved in a JSON file in the
./results/datagen/params
folder.
To generate tasks using RotateFlip
, run:
bash scripts/rotateflip.sh
The generated data will be stored in the ./results/datagen/image
folder.
If you use this code in your research, please cite the following paper:
@inproceedings{wen2024xlogosyn,
author = {Chao Wen and Ahana Ghosh and Jacqueline Staub and Adish Singla},
title = {Task Synthesis for Elementary Visual Programming in XLogoOnline Environment},
booktitle = {AIED Track on Late Breaking Results},
year = {2024}
}