SC‐24sp‐2024‐04‐01‐Afternoon - TheEvergreenStateCollege/upper-division-cs-23-24 GitHub Wiki

Software Construction, Spring 2024

2024-04-01 Week 01 Afternoon

Back to sc-24sp Home

Software Setup

In this class, we'll give instructions on how to use GitPod workspaces which will give you a reproducible development environment on school computers, without administrator permissions.

You may use your own laptop if you bring it to lab, where you can customize and install your favorite text editor, terminals, integrated development environments, and more.

Git-Tac-Toe Email Exercise

In this exercise, imagine you are in the early 2000s and are playing a virtual version of a board game by email.

https://web.archive.org/web/20001215015400/http://iecg.org/Algebra.htm

image image

  • Form a programming pair and sit next to your assigned partner from the morning.
  • Open up a browser tab to your Evergreen outlook email
  • Copy the following empty grid and paste it into

Rustlings

We'll use the rustup / rustc / cargo toolchain to develop in the Rust programming language in this class.

In GitPod

These have already been installed in the class GitPod Dockerfile, and you can verify that they work by typing the following into a GitPod workspace terminal.

The cargo command is Rust's package dependency and project management tool. It is similar to npm for NodeJS, pip for Python, and similar tools.

cargo -v

The rustup command is Rust's tool version manager. It keeps cargo, rustc, and other tools up-to-date. It is

rustup -v

Questions and In-Class Activity Notes from the Morning

In-class Activity #1

Play tic-tac-toe on paper with a partner

Consider:

Abstraction:

  • What are the details of a tic-tac-toe game that can be hidden / abstracted away to write a software solver
  • What data types (you can just use English names) do you need to express an abstraction?

Specification:

  • What questions / parameters would you need to tell someone (including yourself) to write a tic-tac-toe solver this afternoon?

You may need a few games to think about this.

Questions:

  1. How many possible board states of tic-tac-toe are there?

Over-estimate:

9! = 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 2^9 3^9

Is this around 1000? 10,000? 100,000?
1,000,000?

  1. Why is this an over-estimate?

  2. How many winning board states are there?

  3. What strategy should you use in between a

    • completely empty board to start
    • one of few winning conditions at the end

    Is there more than one strategy that you can run at the same time, and how do you decide between them?

  4. What are conditions to detect a valid board? e.g. can’t be all 9 O’s, or all 9 X’s

Abstraction for a Tic-Tac-Toe Game:

  • keep track of what move you are on

In-Class Activity: 5 minutes until break

  • Discuss with your partner
    • Consider the straw-person abstraction / design. What do the parts mean?
    • What do the two submodules do?
      • MoveChooser
      • BoardValidator

Interesting Thoughts:

  • For overestimating board states:
    • are some board states double-counted?
    • does it matter whether X’s are indistinguishable from each other? Or O’s?
  • Is a while loop structure useful?
    • What is the termination condition?
    • What is in the body of the loop?