MENU

Logic Gates - My WWDC18 Scholarship Submission

April 29, 2018 • Swift,Codes

Application

去年熬夜看WWDC直播,男神Craig Federighi出场讲macOS的时候现场一片欢呼。大概就是这个时候,我立了一个小小的Flag。

IMG_1984.jpg


坦白地说,彼时我还不太清楚WWDC除了Keynote和Session还有Lab和Bash,但我somehow被深深地触动了。

今年3月14号早上醒来收到了提醒邮件,Apple更新了WWDC18的页面并公布了Scholarship Application的信息。

QQ20180428-234720@2x.jpg

那个时候对于要写什么有一点初步的想法(最后一个Chapter的设计)。

接下来花了大概一天时间看前两年WWDC关于Swift Playgrounds的Video和读Documantation,主要是感受一下Apple对Swift Playgrounds的定位和设想,确定了写带Education色彩的Playground Book。

接着又花了一天看了WWDC17 Scholars开源的代码,正式开始写。


不得不吐槽的是,Playground Book的开发体验还是比较神奇。

Xcode上并不能像一个真正的Project那样补全和跳转;
每次在Xcode改完AirDrop到iPad,iPad上很快积累了成百上千的中间稿;
最神奇的是Submission Due前两天的晚上我升级了Xcode Version 9.3 (9E145),然后发现打开Playground Book的项目文件已经不能Reveal每个源代码文件了这个时候我的内心是崩溃的,甚至有点想用Sublime Text写剩下的代码。

关于开发过程中的很多Tips,Apollo的这篇文章已经总结的很全面了,可惜我在Submit之后才看到,不然也许可以少走很多弯路


虽然踩了很多坑,但Coding的过程其实还是很快乐。是那种最原始的"Build things from the bottom up"式的快乐;写的感觉很好的时候和感觉写不下去的时候,基本上一直在听朴树的《猎户星座》。断断续续写到Deadline的前两天,最后一天写了两篇Essay,Check了几遍改了两个Bug交了上去

QQ20180428-233147@2x.png

大概二十天的等待,我把Youtube上大家的Submission都看了一遍,基本上心态比较佛系了。

最后出结果的那天早上我睡到八点多,因为听说是PDT 17:00(也就是北京时间上午八点)发邮件公布结果。一边刷牙一边打开手机结果只看到几封推广邮件

然后打开电脑,emmmmmmPKU邮箱果然把它归到了Junk里面
QQ20180421-085931@2x.jpg

Project

The playground book can be downloaded from the GitHub Repo.

Following is my "About Your Playground" essay which was submitted with my swift playground.

This playground book introduces logic gates and logic design using several puzzles with guidance. The puzzles are not only interesting Boolean logic games but are also organized to convey philosophies of electronic engineering.

IMG_0463.jpg
IMG_0462.jpg
IMG_0464.jpg

The motivation for creating this particular playground can be divided into two parts. Firstly, I love things which are structurally organized and free to compose. Such things provide people with possibilities of rational design and achieve effortless elegance, such as logic gates, Markdown, and Swift Playground Books. As a matter of fact, programming itself is such a thing. I think that’s why it fascinates and motivates me all through the years. Another reason is the fact that an increasing number of computer science majors (myself included) only care about codes, algorithms, and software. We tend to neglect some basic aspects of computer science, such as digital circuits, computer organization and architecture, etc. Although we may not deal with them frequently, they are fundamental to everything we build with code, they are actually cool and fun to play with, and they provide us with insights and philosophies of engineering. This is something I try to convey using this playground book.

IMG_0465.jpg

In the first chapter, the playground introduces basic logic gates. At the beginning, their functions are demonstrated using the emojis. Logic gates can be connected to express logical relationships, which can be described using truth tables. The idea of "all inputs" is visualized using animations.

IMG_0472.jpg

In the second chapter, more gates are introduced, and the circuits become much more sophisticated. Then comes an important theorem that NAND gates and NOR gates are universal logic gates, which brings an important engineering principle: substitution. We can build something we don't have using something we have, or replace something complex with something simple, as long as they are functionally equivalent. In practical electronic engineering, such substitution is everywhere. Animations are used to imply input transition and to help understand cascading logic gates.

IMG_0467.jpg

The third chapter consists of the "build-your-circuit" puzzles, which is my favorite part. These problems are interesting and quite tricky. Each gate is assigned a "cost" and every puzzle has a "budget". The player does logical simplification to reduce the cost. It shows the importance of "substitution" in practice. Engineering is the art under realistic constraints, as is well exemplified by this chapter. Users can insert columns into the truth table to inspect variables, and when the truth table becomes too wide, a scroll bar will be created. While scrolling, the leftmost 5 columns are fixed for a better user experience. Also, a puzzle creator is attached so the users can create their own puzzles.

In general, technologies used in this playground include UIKit, Core Graphics, and PlaygroundSupport. The drawing, layout, and animations are implemented using UIKit and Core Graphics. Many features of Playground Book are used to create a rich, interactive environment, such as glossary, hints, placeholder tokens, customized code completions, cutscene page, and LiveViews. The CFRunLoop objects are used to manage asynchronous callbacks.

Thanks for reading.

Acknowledgments

Thanks to my parents' kind support and tolerance. 高考后我声称要在暑假学会iOS开发并给我妈在iPhone上写一个她曾经在WinXP非常爱玩但现在已经玩不了的小游戏,which虽然她一直嘲笑我但我到现在还没写

Thanks to Apple for their generous support and appreciation of my work.

Thanks to the course I took last year, An Introduction to Microelectronics and Circuits. 虽然《微电子与电路基础》是我大学目前分数最低的一门课(而且我相信之后不会有更低的了),但我学到了一些在iGEM2017和WWDC18 Scholarship两段经历中发挥重要作用的东西。

Thanks to WWDC 2016 Scholarship Winner, Alvin Ley, and my teammate in iGEM 2017, Cynthia Jin, for their advice and encouragement.

Thanks to the open source community, people from GitHub, Stack Overflow, and Apple Developer Forums.

Thanks to my girlfriend Y, who 截屏记录了我去年的flag,督促和鼓励我Coding,并成为了这个Playground的第一个体验者

Archives QR Code
QR Code for this page
Tipping QR Code
Leave a Comment