Online SPARC for Drawing and Animation

Elias Marcopoulos, Maede Rayatidamavandi, Crisel Suárez, Yuanlin ZhangAAAI 2017 · DOI

Abstract

Logic programming, particularly Answer Set Programming (ASP), offers a powerful declarative approach to solving combinatorial problems but often alienates beginners due to its abstract, text-based output and complex environment setup. This paper presents an extension to the SPARC language and its online development environment that introduces visual feedback through draw and animate predicates. By transforming logical answer sets into interactive HTML5 canvas graphics, the system provides a "what you see is what you coded" experience, facilitating visual debugging and making logic programming more accessible for educational purposes.

Introduction

Traditional Answer Set Programming (ASP) systems typically output "answer sets" as long lists of text-based literals. For students and novices, interpreting these lists to verify the correctness of a solution—such as coordinates in a grid or steps in a pathfinding problem—is often difficult and uninspiring. Furthermore, the technical barrier of installing local compilers and solvers can deter adoption in introductory courses.

To address these challenges, we introduce a web-based IDE for SPARC that prioritizes visual output. By integrating a visualization layer directly into the logic programming workflow, users can generate drawings and animations directly from logical rules, bridging the gap between abstract logic and intuitive visual representation.

Methods and System Architecture

The core of the system is an extension of the SPARC language using two primary "display predicates":

  • draw(c): Defines static visual elements. A command c can specify styles (e.g., colors) or geometric shapes (e.g., lines).
  • animate(c, i): Associates a drawing command c with a specific frame index i, enabling the creation of motion sequences rendered at 60 frames per second.
The Online SPARC IDE interface, showing the code editor (1), animation controls (2), and the visual output canvas (3).

The workflow follows a four-step process:

  1. Coding: The user writes a SPARC program in the browser-based editor.
  2. Execution: The system computes the answer set (the collection of true facts) for the program.
  3. Extraction: An algorithm scans the answer set for all draw and animate atoms.
  4. Rendering: The system generates an HTML5 program that utilizes the <canvas> element to render the graphics or sequence the animation in real-time.

Key Insights

Declarative Animation

Unlike imperative programming, which requires explicit step-by-step instructions for movement, SPARC allows for declarative animation. Users describe what should be true at any given frame i. For instance, moving an object is achieved by defining its coordinates as a function of the frame index, allowing the logic engine to handle the state transitions.

Visual Debugging and Safety

Visualization provides an immediate feedback loop. Logical errors in problems like Sudoku or pathfinding become instantly apparent when viewed on a grid compared to reading a list of predicates. Additionally, SPARC’s use of "sorts" (types) helps catch structural errors early, providing a more robust learning environment than untyped ASP systems.

Results and Discussion

The tool has been successfully integrated into the online SPARC environment, removing installation barriers. We have demonstrated that complex animations, such as a moving box, can be implemented with minimal logic (e.g., animate(draw_line(redline, I+1, 70, I+11, 70), I).). This simplified syntax allows students to focus on the underlying logic of AI problems rather than the mechanics of graphics programming.

Limitations and Future Work

While the current implementation is effective for educational use, several areas for improvement remain. The predicates could be further abstracted to provide even simpler drawing commands. Additionally, the performance and scalability of rendering highly complex logical scenes in a browser-based canvas require further investigation. Finally, while initial feedback from high school students is promising, formal quantitative studies are needed to measure the impact on learning outcomes and student engagement.

Summary updated

BibTeX
@inproceedings{marcopoulos2017online,
  author = {Elias Marcopoulos and Maede Rayatidamavandi and Crisel Suárez and Yuanlin Zhang},
  title = {{Online SPARC for Drawing and Animation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2017},
  doi = {10.1609/aaai.v31i1.10555},
}

Loading related content...

Figure