BoardGame: A MiniDraw extension
|
|
- Clyde Whitehead
- 5 years ago
- Views:
Transcription
1 BoardGame: A MiniDraw extension Henrik Bærbak Christensen Status: Draft. November 29, 2010
2 Chapter 1 Boardgame Architecture The MiniDraw framework is described in Chapter 30 in Flexible, Reliable Software. The Boardgame extension is a set of classes defined in the minidraw.boardgame package and defines an augmented framework in itself for the more specialized domain of supporting graphical user interfaces for board games. It does so by providing implementations of some of MiniDraw s hotspots (essentially turning these into frozen spots) while providing new hotspots to be defined by developers of board games. Boardgame assumes a well-defined decoupling between the game itself (called the domain) and the graphical user interface (the GUI) which of course is a classic architecture. Boardgame provides hotspots to support the two flows of information and control: From GUI to game domain: That is, when a user manipulate some graphical object, this action is converted into an action in the domain. The archetypical example is the user dragging a token from one square of the board game board to another which must be translated into a call to a move() sor similar method in the game domain. From game domain to GUI: That is, when the state changes in board game, then the GUI must be updated to reflect this. For instance if a chess piece hits an opponent piece, then the opponent piece must disappear or move to a place outside the chess board. Boardgame provides a number of hotspots to support this flow more directly than does MiniDraw. [DISCUSSION PENDING] 1.1 Notes on the Process Note that the focus here is on the GUI and no domain code exists beforehand. 2
3 Chapter 2 Snakes and Ladders by TDD The snakes and ladders game is a very old childrens game. The game s logic is extremely simple: roll a die and move forward accoring to the die value, if you hit a square with a ladder you will move (forward) to the square at the end of the ladder and if you hit a snake you will move (backward) to the square at the end of the snake. The first player to reach the end square wins. From the extension package boardgame s perspective it is ideal because it requires all the behaviour supported by the framework: Generic type LOCATION: The squares on which the players tokens rest. BoardFigure: Moveable objects with a graphical appearance (representing the tokens of the players) that are moved by the user using the mouse. Props: Static objects with an appearance that can be clicked by the user (the die, clicking telling it to roll) PositioningStrategy: Once a tokens has been put on a square we would like to adjust its position to appear nice. To start the project I devise a short test list ] Show the board and a die ] Make tokens and die into BoardFigures ] Move a token invokes the game s move method 2.1 Iteration 1: Show Board and Die A Ant build script is written and a standard folder setup is created like that in FRS chapter 6. A simple snakes and ladder board is found on wikipedia and its size is increased a bit to make room for a die. Together with die images it is copied to the resource folder. 3
4 4 Snakes and Ladders by TDD In package snakesandladders.visual I create a simple test program, just to load the board background and show a single die (and target show). This is basically just a copy of a similar show graphics test program from the HotGammon project from FRS. Note that it only uses the standard MiniDraw API. package snakesladders. v i s u a l ; import minidraw. standard. ; import minidraw. framework. ; import java. awt. ; import javax. swing. ; / Show v i s u a l a p p e a r a n c e o f game. <# i f t y p e == " c o d e "> <# i n c l u d e " / d a t a / a u t h o r. t x t "> </# i f > / public c l a s s ShowLayout { public s t a t i c void main ( S t r i n g [ ] args ) { DrawingEditor e d i t o r = new MiniDrawApplication ( " Show Layout... ", new SnakesAndLaddersFactory ( ) ) ; e d i t o r. open ( ) ; Figure die = new ImageFigure ( " die4 ", new Point ( 6 9 0, 4 0 ) ) ; e d i t o r. drawing ( ). add ( die ) ; e d i t o r. settool ( new S e l e c t i o n T o o l ( e d i t o r ) ) ; c l a s s SnakesAndLaddersFactory implements Factory { public DrawingView createdrawingview ( DrawingEditor e d i t o r ) { DrawingView view = new StdViewWithBackground ( editor, " snakes and ladders background " ) ; return view ; public Drawing createdrawing ( DrawingEditor e d i t o r ) { return new StandardDrawing ( ) ; public J T e x t F i e l d c r e a t e S t a t u s F i e l d ( DrawingEditor e d i t o r ) { J T e x t F i e l d s t a t u s F i e l d = new J T e x t F i e l d ( " Hello Snakes... " ) ; s t a t u s F i e l d. s e t E d i t a b l e ( f a l s e ) ; return s t a t u s F i e l d ; The resulting graphics is shown in Figure 2.1.
5 Iteration 2: Making BoardFigures 5 Figure 2.1: Visual test case of iteration Iteration 2: Making BoardFigures Next I want to make a One Step Test to start building up the boardgame extension stuff. The first one is getting boardgame to understand the three BoardFigures that must be on the GUI. This involves creating BoardFigures using the FigureFactory. I start by making a new test case program ShowFigures as a copy of iteration 1 program. Unfortunately, the next step is really a several step process: 1) I have to create a FigureFactory which 2) require generic type LOCATION and 3) configure MiniDraw with a BoardDrawing instance instead of just a StandardDrawing (see method createdrawing in the previous listing). Furthermore, step 3 s BoardDrawing requires a PositioningStrategy which is then step 4! To get to this point I have to Fake It a lot. It appears that point 3) is actually the proper first step, so I need to fake both LOCA- TION and FigureFactory. This leads to the following code change (TDD rhythm step 1): public Drawing createdrawing ( DrawingEditor e d i t o r ) { return new BoardDrawing<Square >(new SnakeLadderPieceFactory ( game ), new SnakeLadderPositioningStrategy ( ), null / wait with t h e d i e prop / ) ; which of course does not compile at all! I hurry up to define some fake it implementations as local classes in the same file.
6 6 Snakes and Ladders by TDD c l a s s Square { c l a s s SnakeLadderPositioningStrategy implements P o s i t i o n i n g S t r a t e g y <Square > { public Point calculatefigurecoordinatesindexedforlocation ( Square l o c a t i o n, i n t index ) { return new Point ( 8 0, ) ; public Point calculatefigurecoordinatesforprops ( S t r i n g keyofprop ) { return null ; c l a s s SnakeLadderPieceFactory implements FigureFactory <Square > { public Map<Square, L i s t <BoardFigure >> generatepiecemultimap ( ) { return null ; public Map< S t r i n g, BoardFigure > generatepropmap ( ) { return null ; Now it at least compiles but I get an exception from boardgame extension at runtime: BoardGame contract violation: buildpiecemap assumes a non-null map is return from the FigureFactory. So to get at Step 3 I add the images of two tokens, one for blue and one for red. I start by adding just one token, as I then do not have to add any implementation of Square. The graphics I found on the net and it is licensed under the Free Art License. c l a s s SnakeLadderPieceFactory implements FigureFactory <Square > { public Map<Square, L i s t <BoardFigure >> generatepiecemultimap ( ) { Map<Square, L ist <BoardFigure >> m = new HashMap<Square, List <BoardFigure > >(); Square square1 = new Square ( ) ; BoardFigure redtoken = new BoardFigure ( " game token red ", true, null ) ; L i s t s q u a r e 1 l i s t = new ArrayList ( ) ; s q u a r e 1 l i s t. add ( redtoken ) ; m. put ( square1, s q u a r e 1 l i s t ) ; return m; public Map< S t r i n g, BoardFigure > generatepropmap ( ) { return null ; I get to step 4 which looks like in Figure2.2. Why is the red token positioned there? At this stage I still lack to add the blue token and the die. The die is really a prop that is an unmoveable object so I postpone that into a new test on the test list.
7 Iteration 2: Making BoardFigures 7 Figure 2.2: Iteration 2. Show the board and a die Make tokens into BoardFigures Make die into a Prop BoardFigure Move a token invokes the game s move method So I need to add the blue token as well. As it is also located on square 1, this is easy. c l a s s SnakeLadderPieceFactory implements FigureFactory <Square > { public Map<Square, L i s t <BoardFigure >> generatepiecemultimap ( ) { Map<Square, L ist <BoardFigure >> m = new HashMap<Square, List <BoardFigure > >(); Square square1 = new Square ( ) ; BoardFigure redtoken = new BoardFigure ( " game token red ", true, null ) ; BoardFigure bluetoken = new BoardFigure ( " game token blue ", true, null ) ; L i s t s q u a r e 1 l i s t = new ArrayList ( ) ; s q u a r e 1 l i s t. add ( redtoken ) ; s q u a r e 1 l i s t. add ( bluetoken ) ; m. put ( square1, s q u a r e 1 l i s t ) ; return m; public Map< S t r i n g, BoardFigure > generatepropmap ( ) { return null ;
8 8 Snakes and Ladders by TDD Visually, the only change I see is that the visible token is blue now as it fully covers the red token. If you solved the reflection exercise above you know why: it is because the PositioningStrategy always returns graphical position (80,300). Thus I once again extend the test list. Show the board and a die Make tokens into BoardFigures Make die into a Prop BoardFigure Move a token invokes the game s move method Arrange tokens on the correct square Arrange non-overlapping if on the same square End of iteration. 2.3 Iteration 3: Tokens Appear On Correct Square This again involves multiple steps: 1) implement a PositioningStrategy that works correctly given the square a token is on 2) implement some domain code so tokens can actually be moved around. The latter point is a consequence of the way I have choosen to structure my process here: normally I use TDD to develop a quality domain implementation first and then fit a GUI afterwards. Here, however, I have choosen to go the other way, but I still have to provide some stub behaviour of the domain code. I realize that I can add these modifications with the context of the previous test case program: no need to define new java files! The changes are minimal but require a tiny bit of domain design: I have to have a way to distinguish one square from the other. I decide on the obvious choice inspired by the numbers on the game board. I add a method int index() to Square. Furthermore I fake this method as well as add fake-it code to the PositioningStrategy: only square 1 is possible and recognized. c l a s s Square { public i n t index ( ) { return 1 ; c l a s s SnakeLadderPositioningStrategy implements P o s i t i o n i n g S t r a t e g y <Square > { public Point calculatefigurecoordinatesindexedforlocation ( Square l o c a t i o n, i n t index ) { i f ( l o c a t i o n. index ( ) == 1) { return new Point ( 2 0, ) ; return new Point ( 8 0, ) ; public Point calculatefigurecoordinatesforprops ( S t r i n g keyofprop ) { return null ;
9 Iteration 3: Tokens Appear On Correct Square 9 I am lucky, the graphical position (20,400) is actually quite good for square 1 on the board. The question is how to drive the proper algorithm into place for squares other than 1? I realize that I can come some of the way by putting red and blue token on different squares in their configuration in the figure factory: c l a s s SnakeLadderPieceFactory implements FigureFactory <Square > { public Map<Square, L i s t <BoardFigure >> generatepiecemultimap ( ) { Map<Square, L ist <BoardFigure >> m = new HashMap<Square, List <BoardFigure > >(); Square square1 = new Square ( ) ; BoardFigure redtoken = new BoardFigure ( " game token red ", true, null ) ; L i s t s q u a r e 1 l i s t = new ArrayList ( ) ; s q u a r e 1 l i s t. add ( redtoken ) ; m. put ( square1, s q u a r e 1 l i s t ) ; Square square20 = new Square ( ) ; BoardFigure bluetoken = new BoardFigure ( " game token blue ", true, null ) ; L i s t s q u a r e 2 0 l i s t = new ArrayList ( ) ; s q u a r e 2 0 l i s t. add ( bluetoken ) ; m. put ( square20, s q u a r e 2 0 l i s t ) ; return m; public Map< S t r i n g, BoardFigure > generatepropmap ( ) { return null ; Note that this is still fake-it code but serves to triangulate a better PositioningStrategy into existence. Step 2: It compiles but blue token is still not on square 20, as all squares return index 1. I have to add the understanding of index into class Square. c l a s s Square { private i n t index ; public Square ( i n t index ) { t h i s. index = index ; public i n t index ( ) { return index ; and update the constructor calls in the SnakeLadderPieceFactory. Now I compile and run - and the two tokens finally appear in different places like seen in Figure 2.3. Finally, I triangulate a positioning strategy in a number of edit-compile-run cycles. (I was pretty confused by wrong calculations until I discovered that the board is actually jumping a square after square 17!) c l a s s SnakeLadderPositioningStrategy implements P o s i t i o n i n g S t r a t e g y <Square > { public Point calculatefigurecoordinatesindexedforlocation ( Square l o c a t i o n, i n t index ) { i n t sqindex = l o c a t i o n. index ( ) ; / / Note t h e t r i c k y b o a r d l a y o u t what i s s q u a r e 18 i s v i s u a l l y
10 10 Snakes and Ladders by TDD Figure 2.3: Iteration 3a. / / s q u a r e 1 9!!! i f ( sqindex > 17) { sqindex ++; / / c a l c u l a t e t h e row and column i n t row = ( sqindex 1) / 7 ; i n t column = ( sqindex 1) % 7 ; / / System. out. p r i n t l n ( " r, c = "+row +","+ column ) ; return new Point (20+ column 92,400 row 9 2 ) ; public Point calculatefigurecoordinatesforprops ( S t r i n g keyofprop ) { return null ; The result appears quite ok for the moment, see Figure 2.4. Show the board and a die Make tokens into BoardFigures Make die into a Prop BoardFigure Move a token invokes the game s move method Arrange tokens on the correct square Arrange non-overlapping if on the same square
11 Iteration 4: Move a Token 11 Figure 2.4: Iteration 3 at the end. 2.4 Iteration 4: Move a Token I would like to see things move! I want to move the tokens. This entails activating the proper tool of boardgame, namely BoardActionTool. To ensure that it will not interfere with the present test cases I create a new test case program: MoveToken. I create this as a copy of the ShowFigures class just developed. The compiler now complains highly that there are duplicate classes. Thus I have to refactor the class structure and put all the local classes I developed into separate java files. Thus I put this iteration on hold and do iteration 3 s step 5: refactoring. 2.5 Iteration 3:... Refactored This is a simple exercise in slicing up the java source file and put the local classes into separate java source files and in the proper folders. I create two new folders in the src folder: snakesladders.domain and snakesladders.view and put Square in the first and put classes SnakesAndLaddersFactory, SnakesAndLaddersPieceFactory, and SnakesAndLaddersPositioningStrategy in the latter. I refactor ShowFigures to use these classes instead of defining them locally. When it runs the refactoring step is complete.
12 12 Snakes and Ladders by TDD 2.6 Iteration 4: Move a Token Continued Back to MoveToken. Step 1: I tell MiniDraw to use the frozen spot tool supplied by boardgame, namely BoardActionTool. public c l a s s MoveToken { public s t a t i c void main ( S t r i n g [ ] args ) { DrawingEditor e d i t o r = new MiniDrawApplication ( "Move a token... ", new SnakesAndLaddersFactory ( ) ) ; e d i t o r. open ( ) ; e d i t o r. settool ( new BoardActionTool ( e d i t o r ) ) ; Step 2 it runs and I can move a token, but... When I release it I get a null pointer exception. This is because I did not define any COMMMAND pattern object to be associated with the token figures: BoardFigure redtoken = new BoardFigure ( " game token red ", true, null ) ; We need to define some tool. First, let us just get rid of the exception: BoardFigure redtoken = new BoardFigure ( " game token red ", true, new NullCommand ( ) ) ; Great I can move tokens and there is no exception. But of course nothing happens in the game domain. The command object is the one responsible for telling the domain code that some action happened: here that a token has moved. As always I fake-it and triangulate, so my first implementation of a MoveCommand simply writes something on the console. public MoveCommand implements Command { public boolean execute ( ) { System. out. p r i n t l n ( " Moving from ( "+fx+", "+fy+" ) to ( "+ tx+", "+ty+" ) " ) ; return valid ; private i n t fx, fy, tx, ty ; public void setfromcoordinates ( i n t fromx, i n t fromy ) { f x = fromx ; fy = fromy ; public void settocoordinates ( i n t tox, i n t toy ) { tx = tox ; ty = toy ; No thing happens??? Ahh, I forgot to associate command objects with the tokens in the factory. I realize that I only need one command object for both tokens.
13 Iteration 5: Move a Token Continued 13 public c l a s s SnakesAndLaddersPieceFactory implements FigureFactory <Square > { public Map<Square, L i s t <BoardFigure >> generatepiecemultimap ( ) { Map<Square, L ist <BoardFigure >> m = new HashMap<Square, List <BoardFigure > >(); Square square1 = new Square ( 1 ) ; BoardFigure redtoken = new BoardFigure ( " game token red ", true, new MoveCommand ( ) ) ; L i s t s q u a r e 1 l i s t = new ArrayList ( ) ; s q u a r e 1 l i s t. add ( redtoken ) ; m. put ( square1, s q u a r e 1 l i s t ) ; Square square20 = new Square ( 2 0 ) ; BoardFigure bluetoken = new BoardFigure ( " game token blue ", true, new MoveCommand ( ) ) ; L i s t s q u a r e 2 0 l i s t = new ArrayList ( ) ; s q u a r e 2 0 l i s t. add ( bluetoken ) ; m. put ( square20, s q u a r e 2 0 l i s t ) ; return m; public Map< S t r i n g, BoardFigure > generatepropmap ( ) { return null ; It works, every time I move a token I get output written on the console: move: [java] Moving from (605,253) to (431,427) [java] Moving from (429,429) to (337,245) [java] Moving from (338,243) to (431,342) [java] Moving from (431,341) to (535,418) [java] Moving from (534,419) to (607,331) [java] Moving from (607,336) to (623,438) [java] Moving from (623,437) to (166,150) [java] Moving from (164,150) to (59,249) So this iteration ends in success I can move tokens but also in the realization that it is not quite enough. I have to convert the graphical coordinates into the square indices in order to call a move(from,to) method in the game domain. Show the board and a die Make tokens into BoardFigures Make die into a Prop BoardFigure Move a token Move a token invokes the game s move method Arrange tokens on the correct square Arrange non-overlapping if on the same square 2.7 Iteration 5: Move a Token Continued Several One Step Tests are possible at this point in time. As the focus is on the boardgame abstractions I will pick the item that shows the special handling of props: Make die into
14 14 Snakes and Ladders by TDD a Prop BoardFigure. I will do this in terms of the ShowFigures test case as props are also figures and thus the test case name is a cohesive name for what it does. Basically, the die is just a BoardFigure that cannot be moved, which is indicated by a boolean value in the constructor. public c l a s s SnakesAndLaddersPieceFactory implements FigureFactory <Square > { public Map<Square, L i s t <BoardFigure >> generatepiecemultimap ( ) { [... ] public Map< S t r i n g, BoardFigure > generatepropmap ( ) { BoardFigure die = new BoardFigure ( " die0 ", false, new NullCommand ( ) ) ; Map<String, BoardFigure > m = new HashMap<String, BoardFigure > ( ) ; m. put ( " die ", die ) ; return m; When run I get figures: [java] Exception in thread "main" java.lang.runtimeexception: BoardDrawing:PositionStrategy returns null for Prop with key die... (This requires MiniDraw version 1.4 or later, earlier versions just throw a null pointer exception) Alas, I need to define the position strategy for the die as well. public c l a s s SnakesAndLaddersPositioningStrategy implements P o s i t i o n i n g S t r a t e g y <Square > { public Point calculatefigurecoordinatesindexedforlocation ( Square l o c a t i o n, i n t index ) { [... ] public Point calculatefigurecoordinatesforprops ( S t r i n g keyofprop ) { i f ( keyofprop. equals ( " die " ) ) { return new Point ( 6 9 0, 4 0 ) ; return null ; And I get to Step 4: Run all tests and see them all succeed. In Step 5: Refactor to remove duplication I remove the ugly magic constant of string value die by defining the constant instead in a introduced class Constant. package snakesladders. view ; public c l a s s Constant { public s t a t i c f i n a l S t r i n g diepropname=" die " ;
15 Iteration 5: Move a Token Continued 15 One final test case remains: Can I move the die? I run move target that runs the MoveToken test case class and verify that I can still move tokens, but the die remains impossible to move. I can strike out a test case on the test list but quite a few new test items appear on my mind because when I move the tokens they are not neatly arranged on the squares as you can see in Figure??. Also we must create the coupling from the game domain state changes to the GUI. Show the board and a die Make tokens into BoardFigures Make die into a Prop BoardFigure Move a token Move a token invokes the game s move method Arrange tokens on the correct square Arrange non-overlapping if on the same square Position tokens neatly on the squares Update die prop when domain die is rolled Update token when domain token is moved Figure 2.5: Iteration 5 at the end.
16 16 Snakes and Ladders by TDD 2.8 Iteration 6: Update Die Prop When Domain Die Rolled In this iteration the focus is on introducing the coupling from the domain to the GUI. This is (of course) via an OBSERVER pattern. In Boardgame it is known that the domain is a board game and therefore a special BoardGameObserver class and protocol is provided having two methods: one for tokens/pieces and one for information objects/props. I need a test program that can call a method to roll a die in order to verify that the GUI shows the new die face. I first create a test program, note the use of a very specialized tool just to call the roll die method. public c l a s s ShowDomainUpdate { public s t a t i c void main ( S t r i n g [ ] args ) { Game game = new GameImpl ( ) ; DrawingEditor e d i t o r = new MiniDrawApplication ( "Move a token... ", new SnakesAndLaddersFactory ( ) ) ; e d i t o r. open ( ) ; e d i t o r. settool ( new DomainUpdateTool ( game ) ) ; c l a s s DomainUpdateTool extends NullTool { private Game game ; public DomainUpdateTool (Game game ) { t h i s. game = game ; public void mousedown( MouseEvent e, i n t x, i n t y ) { game. r o l l D i e ( ) ; Of course, this does not work - there is no Game defined. I will just introduce one that seems feasible for a snakes and ladders game, again only focusing at the test item at hand, namely the die and getting the observer protocol running. public i n t e r f a c e Game { public void r o l l D i e ( ) ; public i n t getdievalue ( ) ; public void addobserver ( BoardGameObserver<Square > observer ) ; with a pretty Obvious Implementation: package snakesladders. domain ; import minidraw. boardgame. BoardGameObserver ; import snakesladders. view. Constant ; public c l a s s GameImpl implements Game { private i n t die = 1 ; public void r o l l D i e ( ) { die = ( i n t ) ( Math. random ( ) ) ;
17 Iteration 6: Update Die Prop When Domain Die Rolled 17 Sidebar 2.1: Polution of Domain Code PENDING observer. propchangeevent ( Constant. diepropname ) ; public i n t getdievalue ( ) { return die ; p r i v a t e BoardGameObserver<Square > observer ; public void addobserver ( BoardGameObserver<Square > observer ) { t h i s. observer = observer ; Of course, this is also a fake-it implementation as there can only be one Observer at a time. Note that the domain code actually now contains strains of GUI oriented code. I am not too happy about that, see 2.1. The GUI appears and pressing the mouse throws a null pointer exception: Step 2: Run all tests and see the new one fail. Ahh - I forgot to register the GUI as observer. This is one of the places where Boardgame is a bit tedious still. public s t a t i c void main ( S t r i n g [ ] args ) { Game game = new GameImpl ( ) ; DrawingEditor e d i t o r = new MiniDrawApplication ( "Move a token... ", new SnakesAndLaddersFactory ( ) ) ; e d i t o r. open ( ) ; e d i t o r. settool ( new DomainUpdateTool ( game ) ) ; BoardDrawing<Square > drawing = ( BoardDrawing<Square >) e d i t o r. drawing ( ) ; game. addobserver ( drawing ) ; Better now a get an exception telling me what is wrong: update: [java] Exception in thread "AWT-EventQueue-0" java.lang.runtimeexception: BoardGame contract violation: The PropAppearanceStrategy must be defined if propchangeevents are posted. The PropAppearanceStrategy is an algorithm that based upon the string valued key of a prop calculates which image name to use for the graphical prop. Alas, if the die rolled is value two, then we need to show the image named die2. Alas I define one: public c l a s s SnakesAndLaddersPropAppearanceStrategy implements PropAppearanceStrategy { private Game game ; public SnakesAndLaddersPropAppearanceStrategy (Game game ) { t h i s. game = game ;
18 18 Snakes and Ladders by TDD public S t r i n g calculateimagenameforpropwithkey ( S t r i n g key ) { return " die "+game. getdievalue ( ) ; And I also have to tell BoardGame to use it which require changing the Factory: public c l a s s SnakesAndLaddersFactory implements Factory { private Game game ; public SnakesAndLaddersFactory (Game game ) { t h i s. game = game ; public DrawingView createdrawingview ( DrawingEditor e d i t o r ) { DrawingView view = new StdViewWithBackground ( e d i t o r, " snakes and ladders background " ) ; return view ; public Drawing createdrawing ( DrawingEditor e d i t o r ) { return new BoardDrawing<Square >(new SnakesAndLaddersPieceFactory ( ), new SnakesAndLaddersPositioningStrategy ( ), new SnakesAndLaddersPropAppearanceStrategy ( game ) ) ; This required a few refactorings of all the test cases so I run them all, one after the other, to test that none of them fails. All works. And also the ShowUpdate program whenever I click the die changes face to new, random, values. Show the board and a die Make tokens into BoardFigures Make die into a Prop BoardFigure Move a token Move a token invokes the game s move method Arrange tokens on the correct square Arrange non-overlapping if on the same square Position tokens neatly on the squares Update die prop when domain die is rolled Update token when domain token is moved 2.9 Iteration 7: Update Token Figure When Domain Token Is Moved I can actually easily extend the previous update test case program by modifying the specialized tool I developed: c l a s s DomainUpdateTool extends NullTool { private Game game ; public DomainUpdateTool (Game game ) { t h i s. game = game ; i n t clickcount = 0 ; public void mousedown( MouseEvent e, i n t x, i n t y ) { switch ( clickcount ) {
19 Iteration 7: Update Token Figure When Domain Token Is Moved 19 / / move p l a y e r 0 s t o k e n from s q u a r e 1 t o 3 case 0 : game. move ( 0, new Square ( 1 ), new Square ( 3 ) ) ; break ; case 1 : game. move ( 0, new Square ( 3 ), new Square ( 1 8 ) ) ; break ; default : game. r o l l D i e ( ) ; clickcount ++; Which does not compile as there is no move() method. Again, extreme use of Fake It makes me go fast and keep focus: public c l a s s GameImpl implements Game { [... ] private Square tokensquare = new Square ( 1 ) ; public boolean move( i n t player, Square fromsquare, Square tosquare ) { System. out. p r i n t l n ( " Moving to "+tosquare. index ( ) ) ; tokensquare = tosquare ; return true ; OK, I see output in the console from the print statement but no visual action. I have to get the Observer going. public c l a s s GameImpl implements Game { [... ] private Square tokensquare = new Square ( 1 ) ; public boolean move( i n t player, Square fromsquare, Square tosquare ) { System. out. p r i n t l n ( " Moving to "+tosquare. index ( ) ) ; tokensquare = tosquare ; observer. piecemovedevent ( fromsquare, tosquare ) ; return true ; which generates an exception from boardgame that states the following: update : [ java ] Moving to 3 [ j a v a ] Exception in thread "AWT EventQueue 0" j a v a. lang. RuntimeException : B oarddrawing i n v a r i a n t not e s t a b l i s e d : The FigureFactory has not defined a l i s t of BoardFigures for l o c a t i o n snakesladders. domain. Square@169e11 Looking over the JavaDoc for FigureFactory I see that I have missed an important aspect of the multimap returned: POSTCONDITION: The multimap MUST contain a non-null list for every LOCATION on the board game, even if the list is empty! When I inspect the SnakesAndLaddersPieceFactory I see there is quite a lot of Fake It code around the proper design would be to read the starting position of the game. I note it one the test list as yet another item Generate tokens based upon domain contents, but for now I will keep faking to keep focus on my iteration goal.
20 20 Snakes and Ladders by TDD public c l a s s SnakesAndLaddersPieceFactory implements FigureFactory <Square > { public Map<Square, L i s t <BoardFigure >> generatepiecemultimap ( ) { Map<Square, L ist <BoardFigure >> m = new HashMap<Square, List <BoardFigure > >(); for ( i n t i = 0 ; i < 3 5 ; i ++ ) { Square s = new Square ( i ) ; L ist <BoardFigure > s l = new ArrayList ( ) ; m. put ( s, s l ) ; Square square1 = new Square ( 1 ) ; BoardFigure redtoken = new BoardFigure ( " game token red ", true, new MoveCommand ( ) ) ; L ist <BoardFigure > s q u a r e 1 l i s t = new ArrayList ( ) ; s q u a r e 1 l i s t. add ( redtoken ) ; m. put ( square1, s q u a r e 1 l i s t ) ; Square square20 = new Square ( 2 0 ) ; BoardFigure bluetoken = new BoardFigure ( " game token blue ", true, new MoveCommand ( ) ) ; L ist <BoardFigure > s q u a r e 2 0 l i s t = new ArrayList ( ) ; s q u a r e 2 0 l i s t. add ( bluetoken ) ; m. put ( square20, s q u a r e 2 0 l i s t ) ; return m; [... ] However, this leads to the same boarddrawing invariant exception as before? The answer lies again in the JavaDoc for FigureFactory s generatepiecemultimap method: POSTCONDITON: The LOCATION type must implement methods equals() and possibly hashcode() so lookups can be made in the returned map. After implementing these two methods in class Square, I get to Step 4: Run all tests and see them all succeed: the ShowDomainUpdate class now moves the red token nicely upon the first two mouse clicks, whereafter the die rolls.
Techniques of Java Programming
Legi-Nr.:... Techniques of Java Programming ETH Zurich Date: 9 May 008 Family name, first name:... Student number:... I confirm with my signature, that I was able to take this exam under regular circumstances
More informationExam Question Examples 2015
Exam Question Examples 2015 Henrik Bærbak Christensen November 24, 2015 1 0.1 Test-driven development. The Breakthrough game is played on a standard chess board, using 16 white and 16 black pawns that
More informationExtensibility Patterns: Extension Access
Design Patterns and Frameworks Dipl.-Medieninf. Christian Piechnick INF 2080 christian.piechnick@tu-dresden.de Exercise Sheet No. 5 Software Technology Group Institute for SMT Department of Computer Science
More informationSoftware Testing Lecture 2
Software Testing Lecture 2 Justin Pearson September 25, 2014 1 / 1 Test Driven Development Test driven development (TDD) is a way of programming where all your development is driven by tests. Write tests
More information1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;
1 Trees The next major set of data structures belongs to what s called Trees. They are called that, because if you try to visualize the structure, it kind of looks like a tree (root, branches, and leafs).
More informationSDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version
SDS developer guide Develop distributed and parallel applications in Java Nathanaël Cottin sds@ncottin.net http://sds.ncottin.net version 0.0.3 Copyright 2007 - Nathanaël Cottin Permission is granted to
More informationThe Snowball sprite contains 2 costumes, a normal costume, and one that shows which direction the snowball is facing.
Snowball Fight Introduction In this project you re going to make a game in which you have to throw snowballs at a target. You ll use the mouse pointer to angle the snowball and the spacebar to choose the
More informationExercises for Windows
Exercises for Windows CAChe User Interface for Windows Select tool Application window Document window (workspace) Style bar Tool palette Select entire molecule Select Similar Group Select Atom tool Rotate
More informationMATH 56A SPRING 2008 STOCHASTIC PROCESSES
MATH 56A SPRING 008 STOCHASTIC PROCESSES KIYOSHI IGUSA Contents 4. Optimal Stopping Time 95 4.1. Definitions 95 4.. The basic problem 95 4.3. Solutions to basic problem 97 4.4. Cost functions 101 4.5.
More informationLAB 2 - ONE DIMENSIONAL MOTION
Name Date Partners L02-1 LAB 2 - ONE DIMENSIONAL MOTION OBJECTIVES Slow and steady wins the race. Aesop s fable: The Hare and the Tortoise To learn how to use a motion detector and gain more familiarity
More informationFIT100 Spring 01. Project 2. Astrological Toys
FIT100 Spring 01 Project 2 Astrological Toys In this project you will write a series of Windows applications that look up and display astrological signs and dates. The applications that will make up the
More informationExperiment 1: The Same or Not The Same?
Experiment 1: The Same or Not The Same? Learning Goals After you finish this lab, you will be able to: 1. Use Logger Pro to collect data and calculate statistics (mean and standard deviation). 2. Explain
More informationCS-140 Fall 2018 Test 2 Version Practice Nov. 12, Name:
CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) T F : If a child overrides its parent
More informationIntroduction to Special Relativity
1 Introduction to Special Relativity PHYS 1301 F99 Prof. T.E. Coan version: 20 Oct 98 Introduction This lab introduces you to special relativity and, hopefully, gives you some intuitive understanding of
More informationUsing the Prover I: Lee Pike. June 3, NASA Langley Formal Methods Group Using the Prover I:
Basic Basic NASA Langley Formal Methods Group lee.s.pike@nasa.gov June 3, 2005 Basic Sequents Basic Sequent semantics: The conjunction of the antecedents above the turnstile implies the disjunction of
More informationTowards a formal description of models and workflows
Towards a formal description of models and workflows Heinz A Preisig Process Systems Engineering @ Chemical Engineering NTNU, Trondheim, Norway MoDeNa - FP7 ++ Computational engineering The vision that
More informationCS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018
CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) T X F : If a child overrides its parent
More informationFACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING OBJECT ORIENTED PROGRAMMING DATE 07/2014 SESSION 8:00-10:00
FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING MODULE CAMPUS CSC2A10 OBJECT ORIENTED PROGRAMMING AUCKLAND PARK CAMPUS (APK) EXAM JULY 2014 DATE 07/2014 SESSION 8:00-10:00 ASSESOR(S)
More informationCourse Announcements. John Jannotti (cs32) Scope, Collections & Generics Feb 8, / 1
Course Announcements Stars is due tomorrow. Stars grades should be out by next Monday. Javascript lab out today. How you make interactive webby GUIs. Today we re going to cover a bit of a hodge podge.
More information1 ListElement l e = f i r s t ; / / s t a r t i n g p o i n t 2 while ( l e. next!= n u l l ) 3 { l e = l e. next ; / / next step 4 } Removal
Präsenzstunden Today In the same room as in the first week Assignment 5 Felix Friedrich, Lars Widmer, Fabian Stutz TA lecture, Informatics II D-BAUG March 18, 2014 HIL E 15.2 15:00-18:00 Timon Gehr (arriving
More informationIntroduction to Computer Tools and Uncertainties
Experiment 1 Introduction to Computer Tools and Uncertainties 1.1 Objectives To become familiar with the computer programs and utilities that will be used throughout the semester. To become familiar with
More informationCS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:
CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : If a child overrides
More informationDynamics Final Report
Dynamics Final Report Sophie Li and Hannah Wilk 1 Abstract We set out to develop a n-rigid body solver in MatLab. We wanted a user to define how many rigid bodies there are, and our system creates the
More informationThe topics in this section concern with the first course objective.
1.1 Systems & Probability The topics in this section concern with the first course objective. A system is one of the most fundamental concepts and one of the most useful and powerful tools in STEM (science,
More informationVCell Tutorial. Building a Rule-Based Model
VCell Tutorial Building a Rule-Based Model We will demonstrate how to create a rule-based model of EGFR receptor interaction with two adapter proteins Grb2 and Shc. A Receptor-monomer reversibly binds
More informationHow to Make or Plot a Graph or Chart in Excel
This is a complete video tutorial on How to Make or Plot a Graph or Chart in Excel. To make complex chart like Gantt Chart, you have know the basic principles of making a chart. Though I have used Excel
More informationObject Oriented Software Design (NTU, Class Even, Spring 2009) Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20
Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20 This is a closed-book exam. Any form of cheating or lying will not be tolerated. Students can get zero scores and/or fail the class and/or
More informationSoftwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany
Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented
More informationUsing SPSS for One Way Analysis of Variance
Using SPSS for One Way Analysis of Variance This tutorial will show you how to use SPSS version 12 to perform a one-way, between- subjects analysis of variance and related post-hoc tests. This tutorial
More informationIntroduction to Algebra: The First Week
Introduction to Algebra: The First Week Background: According to the thermostat on the wall, the temperature in the classroom right now is 72 degrees Fahrenheit. I want to write to my friend in Europe,
More informationHoare Logic: Reasoning About Imperative Programs
Hoare Logic: Reasoning About Imperative Programs COMP1600 / COMP6260 Dirk Pattinson Australian National University Semester 2, 2018 Programming Paradigms Functional. (Haskell, SML, OCaml,... ) main paradigm:
More informationAnnouncements. John Jannotti (cs32) Design Patterns Feb 13, / 1
Announcements We ll code review Stars on Thursday. Volunteer your code by emailing me. Lab this week covers Ajax/Javascript. Interactive UIs. No lab (or lab hours) next week. Submit a group project idea
More informationDescription of the ED library Basic Atoms
Description of the ED library Basic Atoms Simulation Software / Description of the ED library BASIC ATOMS Enterprise Dynamics Copyright 2010 Incontrol Simulation Software B.V. All rights reserved Papendorpseweg
More informationHow To Write A Testable State Machine. Matthew Jones ACCU Conference, 26 th April 2012
How To Write A Testable State Machine Matthew Jones ACCU Conference, 26 th April 2012 State Machines Describe your nightmare state machine 1000 line file Mother of all switch() statements 10s of line per
More informationITI Introduction to Computing II
(with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 11, 2015 Please don t print these lecture notes unless you really need to!
More informationAMS 132: Discussion Section 2
Prof. David Draper Department of Applied Mathematics and Statistics University of California, Santa Cruz AMS 132: Discussion Section 2 All computer operations in this course will be described for the Windows
More informationA particle system takes small time-steps and updates each particle's location and velocity based on the forces acting on it.
A particle system is a simple physics model that deals only with point- masses and forces. That means that as opposed to rigid-body models objects in particle systems occupy no volume. Their behavior is
More informationAP Physics 1 Summer Assignment
Name: Email address (write legibly): AP Physics 1 Summer Assignment Packet 3 The assignments included here are to be brought to the first day of class to be submitted. They are: Problems from Conceptual
More informationMITOCW ocw f99-lec01_300k
MITOCW ocw-18.06-f99-lec01_300k Hi. This is the first lecture in MIT's course 18.06, linear algebra, and I'm Gilbert Strang. The text for the course is this book, Introduction to Linear Algebra. And the
More informationMITOCW watch?v=dztkqqy2jn4
MITOCW watch?v=dztkqqy2jn4 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To
More informationMAGNETITE OXIDATION EXAMPLE
HSC Chemistry 7.0 1 MAGNETITE OXIDATION EXAMPLE Pelletized magnetite (Fe 3 O 4 ) ore may be oxidized to hematite (Fe 2 O 3 ) in shaft furnace. Typical magnetite content in ore is some 95%. Oxidation is
More informationNMR Predictor. Introduction
NMR Predictor This manual gives a walk-through on how to use the NMR Predictor: Introduction NMR Predictor QuickHelp NMR Predictor Overview Chemical features GUI features Usage Menu system File menu Edit
More informationChapter 2. Mathematical Reasoning. 2.1 Mathematical Models
Contents Mathematical Reasoning 3.1 Mathematical Models........................... 3. Mathematical Proof............................ 4..1 Structure of Proofs........................ 4.. Direct Method..........................
More informationAdvanced Structural Analysis Prof. Devdas Menon Department of Civil Engineering Indian Institute of Technology, Madras
Advanced Structural Analysis Prof. Devdas Menon Department of Civil Engineering Indian Institute of Technology, Madras Module No. # 5.4 Lecture No. # 30 Matrix Analysis of Beams and Grids (Refer Slide
More informationNumerical Methods Lecture 2 Simultaneous Equations
Numerical Methods Lecture 2 Simultaneous Equations Topics: matrix operations solving systems of equations pages 58-62 are a repeat of matrix notes. New material begins on page 63. Matrix operations: Mathcad
More informationSoftwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany
Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented
More informationLeslie matrices and Markov chains.
Leslie matrices and Markov chains. Example. Suppose a certain species of insect can be divided into 2 classes, eggs and adults. 10% of eggs survive for 1 week to become adults, each adult yields an average
More informationLAB 4: FORCE AND MOTION
Lab 4 - Force & Motion 37 Name Date Partners LAB 4: FORCE AND MOTION A vulgar Mechanik can practice what he has been taught or seen done, but if he is in an error he knows not how to find it out and correct
More informationA Brief Introduction to Proofs
A Brief Introduction to Proofs William J. Turner October, 010 1 Introduction Proofs are perhaps the very heart of mathematics. Unlike the other sciences, mathematics adds a final step to the familiar scientific
More informationECE 501b Homework #4 Due: 10/22/2012
1. Game Strategy: Consider a multiplayer boardgame that takes place on the following board and with the following rules: 7 8 9 10 6 11 5 12 4 3 2 1 The board contains six squares that are property (the
More informationRecitation 4: Eventful Tactical KeYmaera X Proofs /15-624/ Logical Foundations of Cyber-Physical Systems
Recitation 4: Eventful Tactical KeYmaera X Proofs 15-424/15-624/15-824 Logical Foundations of Cyber-Physical Systems 1 Announcements Notes by: Brandon Bohrer Edits by: Yong Kiam Tan (yongkiat@cs.cmu.edu)
More informationReading 5 : Induction
CS/Math 40: Introduction to Discrete Mathematics Fall 015 Instructors: Beck Hasti and Gautam Prakriya Reading 5 : Induction In the last reading we began discussing proofs. We mentioned some proof paradigms
More informationExercise 1 (15 points)
Exam System Validation (214012) 8:45-12:15, 25-06-2010 The exercises are worth a total of 90 points. The final grade is 10+pts 10. The exam is open book: copies of slides/papers/notes/etc. are allowed.
More informationFormal Modeling with Propositional Logic
Formal Modeling with Propositional Logic Assaf Kfoury February 6, 2017 (last modified: September 3, 2018) Contents 1 The Pigeon Hole Principle 2 2 Graph Problems 3 2.1 Paths in Directed Graphs..................................
More informationA GUI FOR EVOLVE ZAMS
A GUI FOR EVOLVE ZAMS D. R. Schlegel Computer Science Department Here the early work on a new user interface for the Evolve ZAMS stellar evolution code is presented. The initial goal of this project is
More informationComp 11 Lectures. Mike Shah. July 12, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 12, / 33
Comp 11 Lectures Mike Shah Tufts University July 12, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 12, 2017 1 / 33 Please do not distribute or host these slides without prior permission. Mike
More informationCS325: Analysis of Algorithms, Fall Midterm
CS325: Analysis of Algorithms, Fall 2017 Midterm I don t know policy: you may write I don t know and nothing else to answer a question and receive 25 percent of the total points for that problem whereas
More informationLab Exercise 6 CS 2334
Lab Exercise 6 CS 2334 September 28, 2017 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces. You will implement a set of classes
More informationPRELAB IMPULSE AND MOMENTUM
Impulse Momentum and Jump PRELAB IMPULSE AND MOMENTUM. In a car collision, the driver s body must change speed from a high value to zero. This is true whether or not an airbag is used, so why use an airbag?
More informationTornado and Static Sensitivity
Tornado and Static Sensitivity www.realoptionsvaluation.com ROV Technical Papers Series: Volume 41 Theory In This Issue 1. Explore Risk Simulator s tornado analysis tool 2. Learn how to use tornado analysis
More informationFoundations of Computation
The Australian National University Semester 2, 2018 Research School of Computer Science Tutorial 1 Dirk Pattinson Foundations of Computation The tutorial contains a number of exercises designed for the
More informationWriting Bots for Maize
Writing Bots for Maize Stephen Wattam November 1, 2012 Contents 1 Introduction 2 2 World Format 2 3 Bot API 2 3.1 Bot Data Format.................................... 3 3.2 Alternative Interfaces to Bot.............................
More informationCreation and modification of a geological model Program: Stratigraphy
Engineering manual No. 39 Updated: 11/2018 Creation and modification of a geological model Program: Stratigraphy File: Demo_manual_39.gsg Introduction The aim of this engineering manual is to explain the
More informationPrelim 2[Solutions] Solutions. 1. Short Answer [18 pts]
Prelim [Solutions]. Short Answer [8 pts] (a) [3 pts] In a model/view/controller, Swing is likely to be part of (there may be more than one): i. the model ii. the view iii. the controller The view and the
More informationStatic Program Analysis
Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken s Michael D. Ernst s Sorin Lerner s A Scary Outline Type-based analysis Data-flow analysis Abstract interpretation Theorem
More informationEnrico Nardelli Logic Circuits and Computer Architecture
Enrico Nardelli Logic Circuits and Computer Architecture Appendix B The design of VS0: a very simple CPU Rev. 1.4 (2009-10) by Enrico Nardelli B - 1 Instruction set Just 4 instructions LOAD M - Copy into
More informationA Java introduction SDK, FC 15/12/2009 UMR AMAP. SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50
A Java introduction SDK, FC UMR AMAP 15/12/2009 SDK, FC (UMR AMAP) A Java introduction 15/12/2009 1 / 50 Plan 1 Introduction 2 Bases Java Application Variables & Expressions Simple Arrays Exceptions Collections
More informationDeterministic (DFA) There is a fixed number of states and we can only be in one state at a time
CS35 - Finite utomata This handout will describe finite automata, a mechanism that can be used to construct regular languages. We ll describe regular languages in an upcoming set of lecture notes. We will
More informationThomas Jefferson Invitational Open in Informatics
Thomas Jefferson Invitational Open in Informatics Sample Problems (With Solutions) Version 2.01.1 By programmers, For programmers Preface Preface Welcome to the TJ IOI Sample Problems document. Here, you
More informationIntroduction to Computing II (ITI1121) FINAL EXAMINATION
Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Identification
More information( ) P A B : Probability of A given B. Probability that A happens
A B A or B One or the other or both occurs At least one of A or B occurs Probability Review A B A and B Both A and B occur ( ) P A B : Probability of A given B. Probability that A happens given that B
More information6.041SC Probabilistic Systems Analysis and Applied Probability, Fall 2013 Transcript Tutorial:A Random Number of Coin Flips
6.041SC Probabilistic Systems Analysis and Applied Probability, Fall 2013 Transcript Tutorial:A Random Number of Coin Flips Hey, everyone. Welcome back. Today, we're going to do another fun problem that
More informationFrom Non-Negative Matrix Factorization to Deep Learning
The Math!! From Non-Negative Matrix Factorization to Deep Learning Intuitions and some Math too! luissarmento@gmailcom https://wwwlinkedincom/in/luissarmento/ October 18, 2017 The Math!! Introduction Disclaimer
More informationLists, Stacks, and Queues (plus Priority Queues)
Lists, Stacks, and Queues (plus Priority Queues) The structures lists, stacks, and queues are composed of similar elements with different operations. Likewise, with mathematics: (Z, +, 0) vs. (Z,, 1) List
More informationNewton s Wagon. Materials. friends rocks wagon balloon fishing line tape stopwatch measuring tape. Lab Time Part 1
Newton s Wagon Overview: The natural state of objects is to follow a straight line. In fact, Newton s First Law of Motion states that objects in motion will tend to stay in motion unless they are acted
More informationComp 11 Lectures. Mike Shah. July 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 26, / 40
Comp 11 Lectures Mike Shah Tufts University July 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 26, 2017 1 / 40 Please do not distribute or host these slides without prior permission. Mike
More informationScripting Languages Fast development, extensible programs
Scripting Languages Fast development, extensible programs Devert Alexandre School of Software Engineering of USTC November 30, 2012 Slide 1/60 Table of Contents 1 Introduction 2 Dynamic languages A Python
More informationEnergy is always partitioned into the maximum number of states possible.
ENTROPY Entropy is another important aspect of thermodynamics. Enthalpy has something to do with the energetic content of a system or a molecule. Entropy has something to do with how that energy is stored.
More informationCS 480: GAME AI MOVEMENT. 4/10/2012 Santiago Ontañón
CS 480: GAME AI MOVEMENT 4/10/2012 Santiago Ontañón santi@cs.drexel.edu https://www.cs.drexel.edu/~santi/teaching/2012/cs480/intro.html Reminders Check BBVista site for the course regularly Also: https://www.cs.drexel.edu/~santi/teaching/2012/cs480/intro.html
More informationPHY 221 Lab 7 Work and Energy
PHY 221 Lab 7 Work and Energy Name: Partners: Goals: Before coming to lab, please read this packet and do the prelab on page 13 of this handout. Note: originally, Lab 7 was momentum and collisions. The
More informationITI Introduction to Computing II
(with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 9, 2019 Please don t print these lecture notes unless you really need to!
More informationWeek 2: Defining Computation
Computational Complexity Theory Summer HSSP 2018 Week 2: Defining Computation Dylan Hendrickson MIT Educational Studies Program 2.1 Turing Machines Turing machines provide a simple, clearly defined way
More informationECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University
ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University Prof. Mi Lu TA: Ehsan Rohani Laboratory Exercise #4 MIPS Assembly and Simulation
More informationThe University of Birmingham School of Computer Science MSc in Advanced Computer Science. Behvaiour of Complex Systems. Termite Mound Simulator
The University of Birmingham School of Computer Science MSc in Advanced Computer Science Behvaiour of Complex Systems Termite Mound Simulator John S. Montgomery msc37jxm@cs.bham.ac.uk Lecturer: Dr L. Jankovic
More informationCS 387/680: GAME AI MOVEMENT
CS 387/680: GAME AI MOVEMENT 4/11/2017 Instructor: Santiago Ontañón so367@drexel.edu Class website: https://www.cs.drexel.edu/~santi/teaching/2017/cs387/intro.html Outline Movement Basics Aiming Jumping
More informationHoare Logic and Model Checking
Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Introduction In the
More informationMatrix Inverses. November 19, 2014
Matrix Inverses November 9, 204 22 The Inverse of a Matrix Now that we have discussed how to multiply two matrices, we can finally have a proper discussion of what we mean by the expression A for a matrix
More informationSteve Smith Tuition: Maths Notes
Maths Notes : Discrete Random Variables Version. Steve Smith Tuition: Maths Notes e iπ + = 0 a + b = c z n+ = z n + c V E + F = Discrete Random Variables Contents Intro The Distribution of Probabilities
More informationReading and Writing. Mathematical Proofs. Slides by Arthur van Goetham
Reading and Writing Mathematical Proofs Slides by Arthur van Goetham What is a proof? Why explanations are not proofs What is a proof? A method for establishing truth What establishes truth depends on
More informationA JML Specification of the Design Pattern Visitor
A JML Specification of the Design Pattern Visitor Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University Linz, Austria Wolfgang.Schreiner@risc.jku.at September
More information[Disclaimer: This is not a complete list of everything you need to know, just some of the topics that gave people difficulty.]
Math 43 Review Notes [Disclaimer: This is not a complete list of everything you need to know, just some of the topics that gave people difficulty Dot Product If v (v, v, v 3 and w (w, w, w 3, then the
More informationNondeterministic finite automata
Lecture 3 Nondeterministic finite automata This lecture is focused on the nondeterministic finite automata (NFA) model and its relationship to the DFA model. Nondeterminism is an important concept in the
More informationAssignment 4: Object creation
Assignment 4: Object creation ETH Zurich Hand-out: 13 November 2006 Due: 21 November 2006 Copyright FarWorks, Inc. Gary Larson 1 Summary Today you are going to create a stand-alone program. How to create
More information6. How Functions Work and Are Accessed. Topics: Modules and Functions More on Importing Call Frames
6. How Functions Work and Are Accessed Topics: Modules and Functions More on Importing Call Frames Let s Talk About Modules What Are They? M1.py A module is a.py file that contains Python code The name
More informationElectric Fields and Equipotentials
OBJECTIVE Electric Fields and Equipotentials To study and describe the two-dimensional electric field. To map the location of the equipotential surfaces around charged electrodes. To study the relationship
More informationTou has been released!
Tou has been released! Shoot- em-up, heavy use of collision detection Much more open-ended than previous projects Easier than previous projects if you work smart Should help those of you combating the
More informationReasoning About Imperative Programs. COS 441 Slides 10b
Reasoning About Imperative Programs COS 441 Slides 10b Last time Hoare Logic: { P } C { Q } Agenda If P is true in the initial state s. And C in state s evaluates to s. Then Q must be true in s. Program
More informationDesign and Optimization of Energy Systems Prof. C. Balaji Department of Mechanical Engineering Indian Institute of Technology, Madras
Design and Optimization of Energy Systems Prof. C. Balaji Department of Mechanical Engineering Indian Institute of Technology, Madras Lecture No. # 10 Convergence Characteristics of Newton-Raphson Method
More informationCS 387/680: GAME AI MOVEMENT
CS 387/680: GAME AI MOVEMENT 4/5/2016 Instructor: Santiago Ontañón santi@cs.drexel.edu Class website: https://www.cs.drexel.edu/~santi/teaching/2016/cs387/intro.html Reminders Check Blackboard site for
More informationTwo problems to be solved. Example Use of SITATION. Here is the main menu. First step. Now. To load the data.
Two problems to be solved Example Use of SITATION Mark S. Daskin Department of IE/MS Northwestern U. Evanston, IL 1. Minimize the demand weighted total distance (or average distance) Using 10 facilities
More information