Develop a basic flocking simulation

Assignment Help Other Subject
Reference no: EM132494767

COMP.6211 Algorithms and Data Structures - Toi Ohomai Institute of Technology

Assignment

Learning outcome 1: Use and develop abstract data types.
Learning outcome 2: Implement common data structures and algorithms.

Instructions:

The assignment must be a product of your own work, except for the use of resources supplied with the course, discussions conducted with the lecturers, and other assistance shown as acceptable in the section Assistance to Other Students below.

Project Requirements

Part 1

You are to develop a basic flocking simulation.

Utilise appropriate data types and algorithms to produce a solution to the problem.

Suggested algorithms are:
• Move - Relative to user input
• Move - Automatically
• Lock - To a domain
• Follow - Move to a target
• Runaway - Move from a target
• Collide - Basic collision of objects
• Randomize - Add a random element

Part 2
You are to implement a simple system to generate a ‘Lucky Dip' Lottery Ticket.

The following Class diagram describes the relationship between the classes.

Tasks

The Lotto class should provide the following functionality:
• Initialize an array of 6 integers.
• Set the array to zero.
• Generates 6 random numbers in a range 1 to 49 in the array.
• Sort the numbers in the array in ascending order (utilise a bubble sort or relevant sort algorithm of your choice).
• Format and display the numbers (number output in the range 1 to 9 should be preceded by a blank space) in the array.

The Program class should provide the following functionality:
• Instantiate a Lotto class object.
• Construct a Lottery Ticket that allows the customer to have as many (between 1 and 20) randomly generated Lucky Dips as they require on the same ticket.
• Display the ticket and ‘Lucky Dip' numbers to the screen in the correct format.

Array Exercise 1 - Fortune Predictor
Let's look at some examples of using arrays.
First make a new project called Predictor, then......
Create an array of strings called timeArray with the following data:
• thirty minutes
• an hour
• eight hours
• twelve hours
• a day
• a week
• a month
• a year
• a decade

Create an array of strings called aspectArray with the following data:
• finances
• love life
• career prospects
• travel plans
• relationships

Create an array of strings called effectArray with the following data:
• fall apart
• exceed your expectation
• become awkward in an unexpected way
• become manageable
• become spectacular
• come to a positive outcome

Create an array of strings called personaArray with the following data:
• man
• boy
• woman
• girl
• dog
• bird
• hedgehog
• singer
• relative

Create an array of strings called featureArray with the following data:
• pink hair
• a broken goldenchain
• scary eyes
• long blond nose hair
• very red lips
• silver feet
Create an array of strings called consequenceArray with the following data:
• avoid looking at directly
• sing a sad song with
• stop and talk to
• dance with
• tell a secret
• buy a coffee

Create a Button click event and a TextBlock for output.


In the click event use a random number to select an element randomly from each of the strings, as the following example illustrates timeArray[number.Next(0, timeArray.Length)].


In the click event, add the arrays to the following string to build a basic fortune predictor (use theTextBlock to output the string):

Over a period of timeArray your aspectArray will effectArray.
This will come to pass after you meet a personaArray with featureArray who for some reason you find yourself obliged to consequenceArray.

Use the TextBlock string to also output the prediction as a text-to-talk message.

Now add an image to your application.

Finally... change the message and the content of the arrays to develop your own version of the application...


Array Exercise 2-Flocking and Arrays

Let's look at some examples of using arrays in our flocking algorithms.

Try utilizing the following code in your flocking algorithms.

Make a copy of your flocking project and try implementing the following code:

Image[] myImageArray = new Image[10];

myImageArray[0] = testImage1;

myImageArray[1] = testImage2;
myImageArray[2] = testImage3;
myImageArray[3] = testImage4;
myImageArray[4] = testImage5;
myImageArray[5] = testImage6;
myImageArray[6] = testImage7;
myImageArray[7] = testImage8;
myImageArray[8] = testImage9;
myImageArray[9] = testImage10;


Utils.Move_Lock_To_Grid(myImageArray[0],
TestGrid,
(10 / (double)number.Next(1, 20)) + 2,
ref testFlag1X, ref testFlag1Y);

for (int loop = 1; loop < myImageArray.Length; loop++)
{
Utils.Basic_Follow(myImageArray[loop],
myImageArray[0],
(10 / (double)number.Next(1,21)) + 1);
}

You can add more images to the array as needed.................

Array Exercises: Part 1

First let's make a project called LottoTicket a class called Lotto.
Let's start by implementing the following:
• Create a new project called LottoTicket.

• Create a Class called Lotto and implement the following (see code below):
o Create an array of typeint with6 elements as a field.
o Create a private Random randomNumber field.
o Initialize both the fields in your Constructor.
o Create a method calledGenerateNumbersand use it to fill the array with random numbers 1 to 49.
o Create a method calledPrintNumbers and use it to display each value in the array to the screen.

• In your Program class implement the following (see code below)::
o Call your lotto class (row).
o Start to build the ticket text.
o Call the GenerateNumbers method.
o Call the PrintNumbers method.
o Finish building the ticket text.

• Your interface should display the following:
o Window size locked to height 605 and width 422.
o TextBlock displaying "Enter number of rows (1 to 20)"
o TextBox called TextBoxTickets
o Button called ButtonSelect
o TextBlock called TextBlockTickets, height 504, width 365, font Courier New, FontSize 16 and bold
o Add an image and set opacity to get your interface looking like the example shown

Array Exercises: Part 2
Update the following in your Lotto Class.

In the GenerateNumbers()method uses a loop to add a random number to each of the 6 array elements.

In thePrintNumbers(TextBlockOutputTextBlock)use a loop toprint the 6 random numbers from the array.

Run your application and look at the output.

Now comment your code, to explain what is happening.

Array Exercises: Part 3

Add the following to your application in the Lotto Class.

Add a method called SetNumbersToZero()that loops through the numbers array and sets the six numbers to zero.
Add a call to the SetNumbersToZeromethod (row.GenerateNumbers();).

Array Exercises: Part 4

Add the following to your application in the Lotto Class.

Update the PrintNumbers method so that number output in the range 1 to 9 should be preceded by a blank space.
You will need to use an if...else statement and two output strings here to achieve this.
Add to the MainWindow.xaml.cs file.

publicvoidPrintNumbers(TextBlockOutputTextBlock)
{
// Format and displays 6 numbers to the screen
for (int loop = 0; loop < 6; loop++)
{
// IF ELSE statement here
}
}

Run your application and look at the output.

Now comment your code, to explain what is happening.

Array Exercises: Part 5

Now look at how the ticket should be displayed and change the code in the MainWindowfile to produce this output.

Run your application and look at the output.

Now comment your code, to explain what is happening.

Array Exercises: Part 6
Now let's get some input from the user so we can generate as many lines of numbers as we require.
Add the following to your MainWindow:
• A variable of type integer called Lucky Dips.
• Get the number from the user.
• Limit the selection to between 1 and 20
• Loop through that number of Lucky Dips

Array Exercises: Part 7
Now in the Lotto Classimplement the public void GenerateNumbers() method fully, so that it loops through the numbers array and randomly generates six unique numbers between 1 and 49.

Array Exercises: Part 8
Now in the Lotto Classimplement the public void SortNumbers() method, so that it loops through the numbers array and sorts the numbers in ascending order.
Add a call to this method in your MainWindowfile.

Run your application and look at the output.

Attachment:- algorithms assignment.rar

Reference no: EM132494767

Questions Cloud

Determining the annual dividend-stana inc : Stana, Inc., has preferred stock outstanding that sells for $103.57 per share. If the required return is 4.17 percent, what is the annual dividend?
What fixed vs variable costs for a healthcare organization : Explain the difference between fixed and variable costs for a healthcare organization. Provide and discuss at least one example of a fixed cost in health care
What will be the par value of your holdings : What will be the par value of your holdings in the 20-year coupon bond?
Calculate the present value of total outflows : Calculate the present value of total outflows. (Do not round intermediate calculations. Enter the answers in whole dollars, not in millions)
Develop a basic flocking simulation : Algorithms and Data Structures - develop abstract data types - Implement common data structures and algorithms - develop a basic flocking simulation
What is an appropriate cost of capital for division : What is an appropriate cost of capital for division A if the market risk premium is 9.5 percent? Miller Sisters has an overall beta of 0.79 and a cost of equity
Solve basic and diluted earnings per share : Calculate basic and diluted earnings per share for 2020. Show all calculations for possible part marks. Arrange your answer as per the method used.
Why the term current and short term are used interchangeably : Which of the following explains why the terms current and short term are used interchangeably when discussing assets and liabilities?
Calculate appropriate capitalization rate on general borrow : Kingbird Company, Calculate the appropriate capitalization rate on general borrowings that would be used for capitalization of borrowing costs.

Reviews

Write a Review

Other Subject Questions & Answers

  What are thought on role national nursing organizations play

What are your thoughts on the role national nursing organizations play in shaping regulations and laws related to nursing practice and/or licensure?

  Write a critical analysis of the ethical issues

Choose one of the following companies (or any company that has been in the press) and write a 2 page, APA style critical analysis of the ethical issues involved in the case.

  Explain the facts or statistics that you think would make

Explain the facts or statistics that you think would make this country a good place to build and staff your factory. Your company wants to put a ball-bearing.

  Discuss murder charges against the corporations

Your paper should be no more than one page in length, not including your references page. Your paper should not exceed two pages in length.

  Do you find any special worthwhile need from social health

Care managers have assisted enrollees in obtaining non-covered services and benefits, such as Social Security entitlements, legal aid, and housing.

  What did you learn about surveys

What did you learn about surveys? What are the advantages and disadvantages of mail, telephone interviews, and in-person interviews?

  Campaign and electoral reform

Campaign and Electoral Reform

  What traditional and contemporary philosophies affect

EDU7200- What traditional and contemporary philosophies affect your educational community? How important is this philosophy to developing curriculum and how does it shape various aspects of curriculum?

  Entity in different rows of database table

Different accounting names exist for an entity in different rows of a database table.

  Review the health administration leadership competency model

The history, definition, and use of Leadership Competency Models were addressed this week in Chapter 2 of your course text. The Health Administration Leadership

  Describe verbal communication between you and a close friend

In two pages describe verbal communication between you and a close friend or romantic partner of the other sex. Analyze the extent to which you and the other person follow patterns typical of women and men in general.

  Collecting survey data

Compare and contrast the different methods available for collecting survey data and include examples that are different from what is used in the textbook.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd