# Nim is No Longer Nifty

• Context: Programming Languages Class
• We use Prolog as “mind bending” language
• Problem: Easier to google than to bend mind
• Capstone:
```move(X,Y) :- numlist(1,X,S), member(Y,S),
X > Y, X =< 2 * Y.
win(X) :- X=:=2.
win(X) :- move(X,Y), not(win(Y)).```
• Problem: Is that nifty???

# Cheapass == Nifty

• Solution: Cheapass Games Double Secret Web Site
• Flip:
• Simple rules
• Subtle strategy
• Fresh source for bite-size algorithms

# Flip

• Get bulk dice
• Have buddies play in lab
• Confused about rules? Practice with this app:
• Algorithm challenges:
• Keep track of unflippable vertices
• Enumerate all possible takes

# Work != Nifty

• What if you don't teach programming languages?
• Analyzing games can be nifty
• But...that's a lot of work
• Work is never nifty

# Flip and OOD

• Context: OO Design/Software Engineering class
• Teach design through critique
• ...but don't use your code...
• ...students don't trust it. It must come from the internet.
• Mark Cohen's game framework
• Useful, small enough, sufficiently imperfect

# Design Critique

• Tic Tac Toe is not nifty. Make it work with Flip.
• Critique
• Good: Interfaces
• Remedy: AbstractBoard.java
• For which other interfaces is this a good idea?
• Where else did you see this?
• Lots of discussion topics
• Empty `IPiece` interface (Study use in TTT)
• Return types. `Iterator`. `IPiece[][]`.
• Strategy pattern for moves
• GUI player

# SIGCS1

• But wait...I don't teach OOD/SE. I teach CS1/CS2
• Have no fear...
• Have students implement
• Is board in winning state?
• Make flip move, "play" move
• Check if move is valid
• Fresh context for lots of nested loops, collections of sets
• Not too easy, not too hard
• Sell unit testing on its merits
• No framework—works with simple runner
• Change data representation (sets -> frequency arrays)

# Flip is Nifty

• Maybe not nifty: game analysis
• For quiche-eaters?
• Motivating to keep the mystique?
• Nifty #1: Programming Languages. Bite-size Prolog challenges that google poorly
• Nifty #2: OOD. Put Flip in game framework, critique framework
• Nifty #3: CS1/2. Endless source of loops and data structures