CS 112 - Introduction to Computer Science II
4th Hour Project: Flutter Traffic Lights Game

Due: Monday, November 28 before class 37.

NOTE: This work is to be done in pairs.  I strongly recommend the practice of Pair Programming described simply here.  Although team members are permitted to divide work, each team member should be able to informally present all work of his/her teammate.

Flutter Development of the Traffic Lights Game

There is only one actual due date for this project (see above).  Part of the learning experience here is to pace your own work towards a larger goal.  I'll make suggestions as to how one might break up the work and spread out your effort, but a large part of successful work practice is the ability to give priority to important, non-urgent tasks over unimportant, urgent tasks. This point is well-described in Covey, Merrill, and Merrill's book First Things First, where they assert that work effectiveness is highly correlated with predominance of "compass-driven" important, non-urgent activity over "clock-driven" unimportant, urgent activity.  For larger college projects, especially those that will develop important skills or open new doors, one needs to develop an ability to plan and track important tasks so as to avoid procrastination and thus reduce resulting important, urgent activity.  See also Brian Tracy's relevant book Eat That Frog!: 21 Great Ways to Stop Procrastinating and Get More Done in Less Time. For an excellent book on forming and breaking habits, I recommend James Clear's Atomic Habits.

Suggested Outline of Work (resources and specifications below):

Objectives

Traffic Lights Game

The game Traffic Lights, originally called Semaphore, was invented by Alan Parr.  Reported years of invention/publication vary from 1985 to 1992 to 1998.  We will focus on the 3-by-4 version of the game.

Each square of a 3-by-4 grid is considered to be a light, initially off.  Players alternate selecting a square that does not show a red light.

The first player that makes three lights on in a row/column/diagonal of the same green/yellow/red color wins.  (Played perfectly, 3-by-4 Traffic Lights is a 2nd-player win.)

Here are sources where you can learn more about the game:

Installing Flutter / Dart

Since Google no longer designs its development environments to be suited for shared installation, we are recommending that students install Flutter and Dart on their own personal computers. If you do not have access to a suitable machine, contact the instructor for options.

There are a number of popular integrated development environments (IDEs) for Flutter development. Since one needs Android Studio for Android device emulation, one can simply use the Android Studio IDE with the Flutter plugin. Others prefer Visual Studio Code (VS Code) with the Flutter extension. The choice is up to you. I have tested that our project may be developed with the same steps on either.

Flutter Tic-Tac-Toe Tutorial

There are several online tutorials for implementing Tic-Tac-Toe in Flutter that feature smooth presentation and yet have bad code design. I therefore decided that it would be better for you to have a not-so-smooth presentation with good code design. In particular, I demonstrate the important coding discipline of separating model/logic code from interface code. In both the tutorial and your later implementation of Traffic Lights, the separate concerns of modeling the game and creating the interface to the game are pointedly separated into different files. The game logic file is only Dart without Flutter. Flutter builds its interface on the Dart language, but one ideally shouldn't involve Flutter in the implementation of the game logic.

These videos are flawed, with occasional bugs being introduced by well meaning VS Code autocompletion. At one point, if you see me having difficulty typing an underscore, my keyboard had mysteriously slipped into Spanish mode. :) However, these one-take videos reach the goal and explain the code along the way. You should code along with them at your preferred pace.

Before starting the video, you should create a new Flutter project and make sure it runs properly. The steps are specific to your IDE, so you'll need to do some web searching for a walkthrough of the process.