Presentation is loading. Please wait.

Presentation is loading. Please wait.

GTECH 731 Lab Session 9 11/2/10 Lab 7 – Geotools Review Lab 8 – Simple Agent Model Semester Project.

Similar presentations


Presentation on theme: "GTECH 731 Lab Session 9 11/2/10 Lab 7 – Geotools Review Lab 8 – Simple Agent Model Semester Project."— Presentation transcript:

1 GTECH 731 Lab Session 9 11/2/10 Lab 7 – Geotools Review Lab 8 – Simple Agent Model Semester Project

2 Lab 7 – Geotools Created simple drawing package to create Points, Lines and Polygons Used Geotools geometry library instead of creating your own Used predefined classes to hold state of geometries Point, LineString, LinearRing and Polygon objects “GeometryFactory” to Instantiate objects Used predefined methods lstGeometries[i].GetGeometryType().Equals(“Point”) to determine current object in geometries list lstGeometries[i].GetNumPoints() to set size of temporary “draw” array lstGeometries[i].GetCoordinates() to return current set of coordinates for object curDrawGeometry.GetCoordinate().X to return current object coordinate

3 Lab 7 – Geotools Objects Don’t Draw Themselves Draw geometries using System.Graphics methods DrawEllipse, DrawLines, FillPolygon, DrawPolygon Methods take “System.Drawing” objects or X Y coordinate values as parameters – needed to convert from Geotools objects to “System.Drawing.Point” or X, Y coordinate values e.Graphics.DrawEllipse curDrawGeometry.GetCoordinate().X curDrawGeometry.GetCoordinate().Y e.Graphics.DrawLines, e.Graphics.FillPolygon and e.Graphics.DrawPolygon Take lists of System.Drawing.Point[] objects Looped through lists of “Geotools.Geometries.Geometry” assigning X, Y values to parallel lists of “System.Drawing.Point”

4 Lab 8 – Simple Agent Model Create simple Agent model Add “Pedestrian”, “Obstacle” and “Goal” objects to scene “Pedestrians” will move towards closest “Goal” “Obstacles” in scene block paths to goal Pedestrian object can detect when it hits an object Geotools objects used to hold state of Objects in scene Point – Goals and Pedestrians Polygon – Obstacles Useful functions in Pedestrian “Move” method.Distance() – to determine which goal is closest.Contains() – to detect object collision.Intersects() – to compare Pedestrian location to previous location

5 Lab 8 – Pseudo-Code Way to outline or design logical steps of program at higher more abstract level Independent of any programming language using human language to describe general algorithm or process to perform a task Leave out details not essential for human understanding of algorithm such as syntax or variables Focus on high level logic of program rather than language specifics or specific subroutines needed to carry out tasks Abstract example of “Drink Glass of Water Algorithm” 1.Pick-up glass 2.Lift glass to mouth 3.Drink from glass 4.Put glass down

6 Lab 8 – Pseudo-Code A bit more specific “Drink Glass of Water Algorithm” 1.Pick-up glass 1.Reach for glass 2.Clasp the glass 2.Lift glass to mouth 1.Rotate shoulder and wrist 2.Bend elbow 3.Drink from glass 1.Touch glass to lips and open mouth 2.Tilt glass and pour liquid into mouth 3.Un-tilt glass and close mouth 4.Swallow liquid 4.Put glass down 1.Un-rotate shoulder 2.Un-bend elbow 3.Un-clasp glass

7 Lab 8 – Pseudo-Code for Simple Agent Model 1.For each “time step” 1.Move each “Pedestrian” a single step Basic logic for the “Move” method is... 1.If there are goals and a goal has not been reached 1.Find the closest goal 2.Determine direction to that goal 3.While in old position 1.Move one step in selected direction 2.If object is hit 1.Move back to old position 2.Change selected direction

8 Lab 8 – Pseudo-Code More specific logic for the “Move” method is... 1.If there are goals and a goal has not been reached 1.Find the closest goal 1.Look at all of the goals and select the closest one 2.Determine direction to that goal 1.Calculate two component directions (vertical or horizontal) to the goal and select the longer of the 2 directions 3.While in old position 1.Move one step in selected direction 2.If object is hit 1.Move back to old position 2.Change selected direction 1.If moving North, move East 2.If moving East, move South 3.If moving South, move West 4.If moving West, move North

9 Lab 8 – Pseudo-Code Basic logic might not be sophisticated enough to negotiate obstacles 1.If there are goals and a goal has not been reached 1.Find the closest goal 2.Determine direction to that goal 1.Calculate angular route based on straight line to goal 3.While in old position 1.Move one step in selected direction 2.If object is hit 1.Move back to old position 2.Change selected direction 1.Move 90 degrees from last move? or 2.Move opposite 1 step and move 90 degrees from last move? or 3.Detect edge of object and move around? Don’t know what objects will look like, what angle of approach etc. Try to keep general enough to negotiate all possibilities

10 Semester Project Ideas For next week, write proposal of what you want to do for your semester project Build on what you have done Agent based model (ala Lab 8) Traffic pattern of people walking in an area but avoiding each other on their way to destination? Pigeons flying and clustering around their coops? More extensive drawing package Add/delete select/unselect any number of objects Give individual objects their own color and line thicknesses Move, scale rotate objects Intersect, union or other operation ???


Download ppt "GTECH 731 Lab Session 9 11/2/10 Lab 7 – Geotools Review Lab 8 – Simple Agent Model Semester Project."

Similar presentations


Ads by Google