Assignment Task
Java Assignment Details
The assignment is to implement a system which produces a game of traffic simulation as described above. and present the model using a UML class diagram. Ideally, the design you created for Assignment 1 will form the basis of your implementation. In this case, the complete and correct UML Class diagram for the game is provided.
Note that there are many feasible implementations and that you will be evaluated based on the merits of your code. Therefore, your code does not necessarily need to be perfect; it is OK to re-evaluate your design during implementation, but it must demonstrate that you have thought out and planned the overall design of the system using object-oriented principles. Also, keep in mind that you will actually be implementing the system later; thus, a well-planned design will be beneficial in the future. Your design should facilitate, at minimum, the following behaviours:
Looking – the player should be able to request information about its vehicle’s surroundings
Moving – the player should select a decision about next moving decision: changing lanes (left, right), turning in intersections, or keeping straight.
Asserting – the decision of the player should be verified so that the decision means a consistent state. A problem could trying to enter a road segment in the wrong way or that is full of vehicles.
Gambling – together with asserting, it allows the player to take chances. It gives risky opportunities to the player. Thus, by rolling dices, it infers if the player was lucky or not. For instance, the player decides to turn into a road segment that is full but there is a chance that, in next turn, the segment will vacant a spot.
The provided class diagram is not fully complete and should give hints about the relationships among classes in the code. The diagram is supposed to cover the minimum requirements of the needed funcionalities (Looking, Moving, Asserting, and Gambling) at the design level. The class diagram does not represent all setters and getters needed for guaranteeing access and object encapsulation.
Movement Decisions
Several situations in the simulation trigger moving objects/entities for decisions that might force them to change their direction or allow them to keep the same moving trend there were following. Such situations maybe be clustered in two major occasions, spatially represented on the simulation Map: intersections and middle of lanes (lane changing). The following aspects should be taken in consideration when designing your simulator:
1. Intersection Decision. When at an intersection, the vehicle may opt for moving straight ahead, turn to the left or turning to the right. The decisions need to follow the physical constraints of the map: vehicles are not allowed to turn left a some intersections.
2. Lane Changing. Vehicles while moving in a road segment, they will have the chance to be change lanes in case there is too much traffic ahead slowing its movement. In case there is a traffic jam, the player will have the chance to change lanes several times while it has not covered the whole road segment yet. I some other situations, the player will be prompted for intersection decisions in case there is low traffic density and the player’s vehicle can cover the road segment really fast.
3. Challenge. Vehicles at the intersection will compete for their right to go straight or turn. A player may feel lucky and try to move without caring about other vehicles. This action will be lead to a Challenge, which is somehow Gambling, and the Game Engine will roll dices and tell how is the winner in the Challenge.
4. Reputation. Each vehicle has an overall reputation in the game. It grows as right, conservatives decisions are made. It decreases as the player looses Challenges or when it gambles. All vehicles controlled by the Game Engine may present the same Reputation during all the simulation; they may only take conservative decisions all times. The Reputation can range from predefined MIN to a MAX values.
5. Reputation Value. With higher Reputation, a player has a better chance to win Challenges and win when Gambling.
6. Damage. Any movement decision may lead to an accident, which necessarily will damage the vehicle. The damage may be determined probabilistically (rolling dices) and according to several factors: status of vehicle, speed of vehicle, movement situation, etc.