当前位置:天才代写 > C++/C代写,c语言代写代考-100%安全,包过 > CS game代写 Introduction to Computer and Programming

CS game代写 Introduction to Computer and Programming

2018-10-08 08:00 星期一 所属: C++/C代写,c语言代写代考-100%安全,包过 浏览:1139

CS game代写 2 Tasks Cross road traffic game Write a simple function that initialises all the parameters. user for the number of cars

VG101 — Introduction to Computer and Programming

Project 1

Manuel — UM-JI (Fall 2018)


 

• Include simple comments in the code

 

• If applicable, split the code over several functions

 

• Extensively test your code and impove it

 

• Write a single README file per assignment

 

• Zip all the files and upload the archive on Canvas

 

 

Project setup

At a cross road cars are either moving if the light is green or waiting if it is red. A road is composed of two lanes, for cars going in opposite directions while the light is located on the right hand side of the cars, before the cross. Moving cars are all going at a same constant speed of one unit every second.

A snapshot of the scenario at a time t is shown on Figure 1. On the picture three cars are going from top to bottom but are waiting as the traffic light is red. In the meantime five cars going from right to left are crossing, while two other cars are coming from the opposite direction. The two last cars can be seen coming from the bottom but have not yet arrived at the cross road.

Requirement for the above scenario:


The user inputs n, the total number of cars, w the width of the road, and p the proba- bility that a cars does not stop at the red light;

• The number of cars on each line is randomly decided with respect to n;

• 




The color cycle of a traffic light is green for g s, orange for o s, and red for r s; The user sets the value of the variables g , o, and r ;

• Lights in the diagonal of the cross road have a same color;

• Each time a light changes from green to orange the cars before the light stop and the ones which have already passed it finish crossing; e.g. on Fig. 1 if the green light be-

comes orange then the two cars in the middle of the cross should finish crossing the road;

CS game代写
CS game代写

• Cars should appear at the beginning of the road with respect to where they come from; e.g. a car coming from the right should start from the right most edge of the figure;

• Every second all the non-waiting cars move by one unit;

 

The goal is to animate the displacement of the cars with respect to the traffic lights. The choice of the user will impact the risk for a car crash to happen. The animation stops as soon a crash occurs and the player loses. If all the cars have gone through without any problem the player wins.

 

Tasks

Ex. 1 — Cross road traffic game

1. Write a simple function that initialises all the parameters, i.e. prompts the user for the number of cars, the time for each light color, randomly generates how many cars go in each direction, etc..

2. Write a function that draws the cross road.

3. Write a clear and precise algorithm describing the motion of the cars as well as the change of color of the traffic lights. Justify your choices. The algorithm should describe the whole animation of the cross road.

4. Write several functions to plot the cars and animates the whole scenario of the game.

Each of the following questions is optional and will bring a bonus on the project grade if properly solved.

5. Design more realistic cars of various sizes.

6. Allow the cars to randomly turn left or right.

7. Allow cars to adjust their speed within a range specified by the user. They can in turn use this information to prevent a crash.

8. Allow the player to choose a difficulty level and automatically adjust all the parameters accordingly,

e.g. number of cars, width of the road, right and left turns allowed, etc..

9. Add more lanes to the road.

Note: other adjustments are welcome and encouraged, however first discuss them with the teaching team to check their validity and suitability for the project.

Ex. 2 — Registration plates

Each car features a registration plate composed one letter followed by a mix of five letters and digits,

e.g. B 34HB0. We want to generate a random plate for each of the car and return the plates of all the cars which do not stop at the cross road.

1. Random permutations.

a) Write a recursive algorithm that takes as input a set of elements and an integer l , and returns all their permutations of length l .

b) Adjust the previous algorithm to return a random subset of all the permutations containing

n elements.

Hint: generating all the permutations and selecting n of them afterwards in not a good idea.

2. Implement the generation of the registration plates in MATLAB, and assign a unique plate to each car.

3. At the end of the game display the plate of all the cars that did not stop at the traffic light.

 

Milestones

In order to smoothen the progress and provide hints on how to get organised when working on the project we defined three milestones. For each milestone students must submit their current code with all the usual relevant files attached as well as with a short Changelog file that describes the progress done on the project. Expected implementation for each milestone:

1. Crossroad and traffic light: October 2nd;

 

2. Car related functions (e.g. input, direction, drawing, output, plate, etc.): October 7th;

3. Whole animation: October 14th;

 

FAQ

This section lists all the Frequently Asked Questions (FAQ).

1. I do not understand a question. What should I do?

Use a monolingual dictionary to ensure you fully understand all the words appearing in the question. Then discuss with other students to know how they understand it. Only discuss the question, not its solution. If several opinions appear to be valid determine which ones is the best and most reasonable. Document your choices in the README file. Alternatively contact the teaching team through project 1 discussion on Piazza. To ensure everybody benefits from the question and its answer no question will be answered if not asked on the project discussion;

2. What is w the width of the road?

The width of the road is how large the road is. It can be expressed in pixels or in term of time unit,

e.g. a width of 4 time units means that a car needs 4 time units to cross the cross road. Ensure the user knows what unit is used when he is prompted for w .

3. The optional question requirements do not match the original scenario. What should I do?

The optional requirement overwrites the original one. For instance in the original scenario the speed is uniform while in ex. 1 question 7 a car can change its speed. In that case the speed can be freely adjusted.

4. Can I skip base questions and do optional ones instead?

No, a submission that does not implement the basic questions will not receive any bonus.

5. Can I make use of the Automated Driving System Toolbox?

The project must be completed with the help of any “advanced toolbox”. Completing two versions, with and without, can bring bonus.

6. I have not read the ci.pdf file, can it impact my grade?

Yes, much information on the code quality appears in this file. No applying some of the rules can bring large deductions on the project grade.

7. I cannot meet a milestone, how bad is it?

Deductions will be applied if functions from previous milestones are not fully working in the final submission. Besides, no answer will be provided to questions on a previous milestone.

最先出自天才代写 cs代写 作业代写 代写c
合作:幽灵代写
 

天才代写-代写联系方式