CSC223 2004F, Class 13: Project Management with Ant Admin: * www.cs.grinnell.edu seems to be down * file:///home/rebelsky/Web/Courses/CS223/2004F/EBoards/ant.txt * file:///home/rebelsky/Web/Courses/CS223/2004F/Outlines/current.html * Why attend convo * Grinnellians have no common intellectual heritage * Fun with prospies * Why come to Grinnell rather than top-ranked engineering school * Nice small classes and collaborative envrionment * Why come to Grinnell rather than other schools? * We won't let you take as much Math and CS * Great place to explore options: Open curriculum, "Take whatever you want" * Why come to Grinnell rather than Knox? * We're rich, they're poor. * Why come to Grinnell rather than UofC? * Open curriculum vs. carefully-designed core curriclum * Small town USA vs. "ten bookstores in a five block radius" * More drinking here (by those of legal age) (at least compared to when I was an undergraduate) * Danger, it's Friday, the 13th class! * Homework due. How much time? From 9 to 40 person-hours. * Homework assigned. Discussed during class. * ACM Programming competition forthcoming: Jesse and Mark * Who knows Swing, the primary GUI toolkit for Java? * Not many, covered week after next * Next week: XP (read the book) * How to read a book: * Carefully * Thoughtfully/Reflectively * Repeatedly (not for this class) Overview: * Homework, part 1: Representing World State * Homework, part 2: Implementing Bugs * Philosophy of Ant * Ant basics * Ant Variables /HW4, part 1: Representing the State of the World/ * "The state of the world": Associate a collection of objects with each x,y coordinate. * Implementation strategies: + Two-dimensional array: O(1) to find stuff at a position + Vector of vectors + List of location,contents pairs + Tree of area,contents pairs: O(log_n) time to find stuff at a position; If the grid is "sparsely" populated, may give more efficient storage + Hashtable of contents indexed by location * Design an implementation-independent interface, WorldState + addThingAt + listThingsAt + removeThingAt * Implement it in each of the five ways mentioned above. * Summarize the benefits and costs of each implementation. FOUR SKIPPERS Jesse,Mark,Chase /HW4, part 2: Implementing NotVerySmartSleepyAsexuallyReproducingAlienBugs/ * We are going to implement bugs as nondeterministic finite state machines * Finite state machine: A bug has a current state ("looking for food"; "running away from a BugEater"; "bringing food back to colony") and a way of deciding what to do based on state and environment. * Nondeterministic: More than one choice may be available in a particular state (given that there are many things happening in the environment) * The finite state machine is stored in a text file. Format STATE,INPUT,NEWSTATE,OPTIONAL-ACTION * Should states be strings or integers? * Strings: Readability; Easier for novices <--- da winner for the file * Integers: Faster (input, output, compare, store) * Actions: move(direction) - n,s,e,w,ne,nw,sw,se [1 time unit] run(direction) - moves two spaces, uses more energy [1 time unit] sleep [10 time units] eat - eats one unit of whatever it has in hand [1 time unit] pickup - pick up up to ten units of food (ten units if at least ten units in the current location, less otherwise) [1 time unit] drop - drops all of the food in hand [1 time unit] breed - generates a new bug [5 time units] secrete(type) - leave a pheremone at the current spot [0 time units] attack(direction) - attack another bug WANDERING,FOOD,GOHOME,PICKUP WANDERING,EATER(N),PANIC-SOUTH-0,SECRETE(WARNING) PANIC-SOUTH-0,*,PANIC-SOUTH-1,RUN(S) PANIC-SOUTH-1,*,PANIC-SOUTH-2,RUN(S) PANIC-SOUTH-2,*,WANDERING,RUN(S) GOHOME,P5(S),GOHOME,MOVE(S) Sam,Merrick,Luis Gene,Omondi,Margaret