iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

iOS: Evil Hangman Walkthrough

Equivalence Classes Tips and Tricks

Tommy MacWilliam Harvard University

April 7, 2011

Announcements iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

Lecture videos: https://www.cs76.net/Lectures

I

Section videos: https://www.cs76.net/Sections

I

Walkthrough videos: https://www.cs76.net/Projects

Today iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

I

Evil Hangman

Equivalence Classes

I

Setup

Tips and Tricks

I

Equivalence classes

I

Tips and Tricks

Evil Hangman iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

it’s evil.

Evil Hangman iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

I

goal: dodge user’s guess as best as possible

Equivalence Classes

I

strategy: be able to switch among the largest number of words

Tips and Tricks

I I

maximize ability to cheat optimal? eh, good enough

Evil Hangman iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes

I

- - -

Tips and Tricks

I

words: OWN, PUN, LOL, NVM, NOT, WON, NEW

Evil Hangman iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

- - -

I

guess: N I I I I

N -

N

-: LOL -: NVM, NOT, NEW N: OWN, PUN, WON -, N N -, N - N, - N N, N N N: ∅

Evil Hangman iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

I

- - N

Equivalence Classes

I

guess: P

Tips and Tricks

I I I

- - N: OWN, WON P - N: PUN - P N, P P N: ∅

Evil Hangman iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

greedy algorithm: optimize at each step to find optimal solution I

useful for graph problems (shortest path, minimum spanning tree)

Setup iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

Utility Application I I I

contains two views: MainView and FlipsideView flip side often used for settings, etc. e.g. Weather app

MainViewController iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

I

showInfo: creates/shows new controller

Equivalence Classes

I

Tips and Tricks

I I

presentModalViewController: just like pushViewController, but without the hierarchy connected via IB to UIButton Attribute Inspector → Type → Info Light/Dark

FlipsideViewController iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

done: hides this controller I I

connected via IB to UIBarButtonItem remember the self.navigationItem

Delegation iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes

I

don’t do it yourself, tell an object to do it for you

Tips and Tricks

I

make sure that object knows what to do!

FlipsideViewControllerDelegate iOS: Evil Hangman Walkthrough Tommy MacWilliam

I

FlipsideViewControllerDelegate declares flipsideViewControllerDidFinish

I

MainViewController implements FlipsideViewControllerDelegate

Evil Hangman Setup Equivalence Classes

I

Tips and Tricks

flipsideViewControllerDidFinish defined to hide the FlipsideViewController

I

FlipsideViewController’s delegate is MainViewController

I

FlipsideViewController tells the delegate when DidFinish

Equivalence Classes iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

Google didn’t work last time, let’s try Wikipedia!

I

http://en.wikipedia.org/wiki/ Equivalence_class

Equivalence Classes iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes

I

Tips and Tricks

I

[a] = {x ∈ X |x ∼ a} clear? okay we’re done, have a nice night

Equivalence Classes iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

no, there’s no NSEquivalenceClass either

Equivalence Classes iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman

I

define a group of words sharing a given letter at a location

I

order matters!

Setup Equivalence Classes Tips and Tricks

I I

- - N, N - - are different equivalence classes don’t forget about the option to say the letter is not present

Equivalence Classes iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

group words into equivalence classes based on user input

I

how do we define a group? I I I

NSMutableDictionary NSMutableArray NSMutableSet

Equivalence Classes iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman

I

okay we have our groups, which do we use?

Setup

I

Equivalence Classes Tips and Tricks

I

need deterministic mapping between word and equivalence class

each class needs a unique identifier I I

not rand()! equivalence class → identifier → objective-c collection

Equivalence Classes iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman

I

Setup Equivalence Classes Tips and Tricks

make sure your design can determine the best equivalence class! I

I

aka the largest equivalence class

knowing the largest class, make sure you can determine I I

what words are in the class what letter(s), if any, should be displayed on-screen

Time Consumption iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

I

try to make program as fast as possible

Equivalence Classes

I

look up a given index/key = fast

Tips and Tricks

I

iterate through entire collection 6= fast

I

re-checking words that cannot be right 6= fast

Space Consumption iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

try to make program use as little RAM as possible

I

words.plist is pretty big!

I

keep data structures as small as possible I I

huge collection with lots of unused space 6= fast remove anything unneeded immediately

Design iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

I

I

Equivalence Classes Tips and Tricks

keep time and space consumption in mind at all points

I

don’t get hung up on performance though!

also have to keep track of: I I

already used letters number of guesses made

Hidden Text Fields iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup

I

first responder: UIView currently with focus

Equivalence Classes

I

resignFirstResponder: blur element

Tips and Tricks

I

becomeFirstResponder: focus element

I

hidden property of UIView controls visibility

NSString iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman

I

length: length of string

Setup

I

characterAtIndex: get single character at numerical index

I

substringToIndex, substringFromIndex: substrings with a single boundary

I

substringWithRange: substring with two boundaries

Equivalence Classes Tips and Tricks

NSString iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

what if I just want a char*?

I

cStringUsingEncoding:NSASCIIStringEncoding: get const char* from NSString* I I

I

now we have an array of chars char a = ’a’; char b = ’b’; (a < b) == YES; http://asciitable.com

NSString iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

words in plist are in ALL CAPS

I

lowercaseString

I

capitalizedString

plists iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman

I

both NSArray and NSDictionary respond to initWithContentsOfFile

I

don’t forget about NSBundle, mainBundle, and pathForResource:ofType:

I

don’t parse the plist a bunch of times!

Setup Equivalence Classes Tips and Tricks

I

sloooooow

NSUserDefaults iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

just like SharedPreferences!

I

store persistent key/value pairs without the hassle of a database

NSUserDefaults iOS: Evil Hangman Walkthrough Tommy MacWilliam

I

[NSUserDefaults standardUserDefaults]: get defaults associated with the app

I

setObject:forKey: save a key/value pair into defaults

Evil Hangman Setup Equivalence Classes Tips and Tricks

I

just like NSMutableDictionary: pair created if not already existing

I

objectForKey: retrieve value associated with key

I

removeObjectForKey: remove item from defaults

NSUserDefaults iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman

I

Setup

can read/write anything saveable in a plist I

Equivalence Classes Tips and Tricks

I

NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary

convenience methods I

I

arrayForKey, dictionaryForKey, integerForKey, etc. setBool, setInteger, etc.

NSUserDefaults iOS: Evil Hangman Walkthrough Tommy MacWilliam Evil Hangman Setup Equivalence Classes Tips and Tricks

I

example time!

iOS: Evil Hangman Walkthrough - cdn.cs76.net

Apr 7, 2011 - Hangman. Walkthrough. Tommy. MacWilliam. Evil Hangman. Setup. Equivalence. Classes. Tips and. Tricks. iOS: Evil Hangman Walkthrough.

118KB Sizes 0 Downloads 198 Views

Recommend Documents

iOS: Evil Hangman Walkthrough - cs164
Mar 21, 2012 - Property Lists. Equivalence. Classes. Protocols. Transitioning. Between. Views. Settings. iOS: Evil Hangman Walkthrough. CS164 Walkthrough ...

iOS: Evil Hangman Walkthrough - cs164
Mar 21, 2012 - for each word in set: determine equivalence class for word; add word to equivalence class; determine largest equivalence class; remove all ...

iOS: Evil Hangman Walkthrough - cdn.cs76.net
Apr 7, 2011 - goal: dodge user's guess as best as possible. ▷ strategy: be able to switch among the largest number of words. ▷ maximize ability to cheat.

Evil Hangman - cs164
thereafter, you might also want to sign up for the iOS Developer Program at ... Because the course is part of the iOS Developer University Program, you will be ...

Evil Hangman - cs164
thereafter, you might also want to sign up for the iOS Developer Program at ... Because the course is part of the iOS Developer University Program, you will be ...

Evil Hangman - CS50 CDN - cs164
should be prompted to Create an Apple ID or Use an existing Apple ID. Review the explanation beneath each option, select the appropriate one, click Continue, then follow the on-‐screen prompts. If you plan to submit an app to Apple's App Store, whe

Seal Of Evil 1.06 Walkthrough Chapter 123.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Seal Of Evil 1.06 ...

Walkthrough 8
index.html – homepage. ▫ buildings.js – buildings in the game. ▫ houses.js – Harvard houses + locations. ▫ math3d.js – movement math. ▫ passengers.js – all the people in the game. ▫ service.css – appearance of the homepage. ▫

Walkthrough 8
Agenda. ▫ Distribution Code. ▫ HTML + CSS. ▫ Javascript. ▫ API's: Google Earth and Google Maps. ▫ Pickup. ▫ Dropoff. ▫ Choice of feature ...

Walkthrough 8
index.html – homepage. ▫ buildings.js – buildings in the game. ▫ houses.js – Harvard houses + locations. ▫ math3d.js – movement math. ▫ passengers.js – all the ...

CS 50 Walkthrough 5
Data structures, hexadecimal, and pointers. • Programs: – whodunit. – resize. – recover ... Image recovery! ... Go through each block in the disk image and: 1.

CS 50 Walkthrough 5
Image recovery - Steps. • Steps: Go through each block in the disk image and: 1. If we find a JPEG signature, start wriûng the bytes out to another file. 2. If we find a new JPEG signature, close that old file and go back to 2. 3. If we find the E

CS50 Walkthrough 4
To Do. ▫ distribution code. ▫ ncurses. ▫ move cursor. ▫ allow changing user-added ... Allows you to change colors, ... g.board[g.y][g.x] is spot on board where.

CS 50 Walkthrough 5
A bitmap is a series of consecuûve pixels described after each other. • Also has “metadata” in first 54 bytes consisûng of two headers.

CS50 Walkthrough 4
function, takes one argument ch (ascii). ▫ if ch is 0, . , KEY_BACKSPACE, KEY_DC. ▫ set that spot in the board to 0. ▫ if ch is numerical between '1' and '9'.

CS50 Walkthrough #3
search. ▫ sort. ▫ fifteen.c. ▫ distribution code ... Re-implement as binary! ▫ why? ▫ 2 main ways. ▫ iterative. ▫ recursive. Page 6. Binary Search: Iterative. Go to middle.

CS50 Walkthrough 4
distribution code. ▫ ncurses. ▫ move cursor. ▫ allow changing user-added numbers, but not original ones. ▫ allow replacement of blank with number. ▫ invalid move? ▫ won? ... Moving the cursor. ▫ Switch statements! switch (test). { case

CS 50 Walkthrough 6
create nodes for them. – put these nodes ... store each le›er i of the word in that node. • fgetc(dptr) is that ... put a pointer to your node that you just malloced there.

CS50 Walkthrough #3
Go to middle if k < value at middle search for k between first and the one before the middle if k > value at middle search for k between one after the middle and ...

Mobile Local Walkthrough
Feb 8, 2011 - or jQTouch) are not necessary, but you can certainly use more than one page if you'd like to. Page 6. Mobile Local. Walkthrough. Tommy. MacWilliam. Setup. JSONP. YQL. Tips and. Tricks. HTML Setup. ▷ HTML5 Doctype: . ▷ jQuery: .

CS50 Walkthrough 1
Videos on website. ▫ Purpose. ▫ To guide you through the week's assignment ... poor/fair/good/better/best ... Building Blocks. ▫ printf. ▫ GetInt(). ▫ “thinking”.

CS 50 Walkthrough 6
Topics: – More data structures, more pointers. – More File I/O. • You implement: ... convert each le›er of word tolower. • hash word and go to that place in array.

Computer Science 50 Walkthrough 2
This old man, he played one. He played knick-knack on my thumb. Knick-knack paddywhack, give your dog a bone. This old man came rolling home. This old man, he played two. He played knick-knack on my shoe. Knick-knack paddywhack, give your dog a bone.

Computer Science 50 Walkthrough 2
Computer Science 50. Introduction to Computer Science I. Harvard College. Marta Bralic [email protected]. Walkthrough 2 ...