Lab 1 : Set up, building with ant
PhilippeCollet
Introduction
In this Lab we will go over some of the basics of the Eclipse IDE and the Apache Ant build tool.
We will also introduce the running example application that will be used through the course.
Prerequisites
- Installed Java SDK
- Installed Eclipse
- Installed Ant
Exercise: Getting started with the creature simulator
The initial code is provided in the
http://deptinfo.unice.fr/twiki/pub/Minfo/SeLab1/tp1-resources.zip archive.
This code contains an application that creates an little framework for simulating creatures. A creature is basically just an object that has some properties (like position, direction, speed, color, ...) and behavior. It can act - change its properties and it knows how to render itself on a graphical canvas. In this lab version, a creature has also a vision. It can see other creatures within certain field of view and a certain distance.
The framework is built on the top of Java Swing library.
Starting with the creature simulator
- Create a new Java project in Eclipse
- Correctly place the given source files
- Make sure you have no errors in the Problems view
- Go over the classes to get the notion about how it works
Ant in Eclipse
Ant in Command Line
Exercise: Refactor manifest creation in ant
The way how the manifest is made in the build.xml is rather complicated. There is actually a
http://ant.apache.org/manual/Tasks/manifest.html? in Ant so you should rewrite the appropriate code to you this one instead. Think also about the lifecycle of the manifest during the build and that perhaps you should modify other targets. Lastly, when checking whether it works, make sure you first delete all the
META-INF
and
MANIFEST.MF
files.
Exercise: Smart creature
The goal of this exercise is to create a new kind of creature is a bit smarter than the stupid one.
It should have following behavior:
- It should try to align its speed with the speed of the creatures around.
- It should go in the same direction as the creatures around.
- It should maintain some minimal distance from the creatures around.
Exercise: Code analysis of the creature simulator
The given code is not well written. Now you will play a role of a
senior software developer whose task is to review a code that has been produce by some
junior. Try to come up with as many improvements as possible. For example:
- What to do with some of the utility functions?
- What to do with the fact that logic of the Environment and the visualization are kept together?
- ...
Appendix
Coordinates and Angles
Overview of the coordinate system. We use the common Euclidian two-dimensional geometry with the coordinate system origin in the middle of the plane.
Method directionFromAPoint()
in AbstractCreature
Explanation of the
directionFromAPoint()
method.
Method: creaturesAround()
in Environment
What is considered to be a creature near by.
Method: act()
in SmartCreature
The position change based on computed speed and direction.
--
KrikavaFilip - 09 Oct 2012
to top