代写辅导接单-Games and Artificial Intelligence Techniques - COSC2527/2528 Assignment 1

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

Games and Artificial Intelligence Techniques - COSC2527/2528

Assignment 1

Assessment Type Individual assignment.

Submit online via GitHub Classroom. The last commit prior to the assignment

deadline will be graded. Marks awarded for meeting requirements as closely as

possible. Clarifications/updates may be made via announcements/relevant

discussion forums.

Due Date Tuesday 2nd April, 2024, 11:59pm

Marks 30.

1 Overview

The purpose of this assignment is to give you practice implementing steering behaviours and finite

state machines, as covered in Weeks 2 and 3 of class. There is also a component that focuses on

game development in Unity, requiring you to add some new features to an existing game.

Starter code for the assignment is provided on GitHub Classroom (see Canvas for instructions on

how to create your repo). It provides a shell for a basic predator-prey game, where the player

controls a frog whose aim is to eat flies, whilst avoiding snakes that hunt the frog.

Sprites, animations, and skeleton code are provided for you, but the logic governing the characters’

movement is missing. Your job is to implement the missing pieces!

Figure 1: A screenshot of the game you’ll be building.

2 Learning Outcomes

This assessment relates to the following learning outcomes:

• [CLO1]: Apply various AI techniques and tools in the context of games programming.

• [CLO2]: Design and develop a gaming application, based on existing games engines or

platforms.

3 Specification

The assignment comprises three parts: steering behaviours, finite state machines, and further game

development, as detailed below.

Part 1: Steering Behaviours (10 marks)

Implementing arrive (1 mark)

For this task, open the ArriveTest scene in the starter code. In this scene, the player controls a frog

by right-clicking on the screen. In the starter project, the frog overshoots the clicked position, since

the BasicArrive() method in Scripts/Steering.cs has not been implemented properly (it just calls a

seek method). Your task is to implement it properly, scaling the desired velocity down as the

character approaches the target, following the logic explained in the Week 2 slides.

Figure 2: Illustration of overshooting in the starter game.

Boids flocking (3 marks, 1 for each method)

For this task, open the FlockingTest scene. A flock of flies has been set up for you, and each fly has

a script attached (Scripts/Fly.cs) that computes the overall flocking force by summing the

separation, cohesion and alignment components. An “anchor” force has also been added to keep the

flies within the game arena; please do not remove this.

In the starter code, the GetSeparation(), GetCohesion() and GetAlignment() methods all return

Vector2.zero. Your task is to implement them properly, using the exact maths shown in class.

To judge whether you have implemented flocking correctly, compare the behaviour of your flies to

the demo video on the Assignment 1 Canvas page.

Flee (1 mark)

After implementing boids flocking, the flies in the FullGame scene should flock when they are far

away from the frog. However, they are set up to transition to a “Fleeing” state when they get scared

by the frog. In the starter project, they will freeze in this state, since BasicFlee() just returns

Vector2.zero. Your task is to implement flee properly.

Obstacle avoidance (5 marks)

In starter game, the snakes do not use obstacle avoidance, so they crash straight into objects when

chasing the frog. There are many ways of implementing obstacle avoidance, but for this assignment

you are expected to follow the approach described in Week 2.

Figure 3 provides a visual illustration of this method. The snake first performs a direct circle cast to

the frog (indicated by the black line) to see if there are any obstacles blocking the path. In this case,

the path is blocked, so the snake performs additional circle casts to find the minimum deviation it

needs to make. The additional circle casts are sent both clockwise and anti-clockwise at an

incrementally increasing angle until a free path (green line) is found. The red lines indicate circle

casts that failed to find a free path. Note that although some of the red lines appear to miss the trees,

the circle casts are actually wider than the lines shown, as governed by the radius parameter.

Figure 3: A screenshot from Michael’s solution, with visual debugging via Debug.DrawLine().

Adding visual debugging is optional, but highly recommended!

Skeleton code for the approach is already set up in the starter game. The SeekAndAvoid() method

in Scripts/Steering.cs calls GetAvoidanceTarget(), which receives the character’s position, its

target position, and some additional parameters, avoidParams. The method is *supposed* to return

an updated target position if the direct path to the target is blocked, but in the starter code it just

returns the original target. A correct implementation would return the endpoint of the green line in

Figure 3, so that the snake will steer to the left of the trees.

The avoidParams argument contains two parameters by default: a boolean that indicates whether

obstacle avoidance is enabled, and the layer mask to use for the circle cast. However, you are free

to add extra parameters to avoidParams as you see fit, e.g., you might want to add a float that

controls the angle increment of the circle casts.

We don’t expect your implementation to match Michael’s solution exactly, but to achieve full

marks your approach should perform to a similar level. A video demo of Michael’s solution is

provided on the Assignment 1 Canvas page. Think carefully about subtle issues, such as what could

happen if the circle casts are too long.

Part 2: Finite State Machines (10 marks)

Drawing the fly FSM (4 marks)

The starter game includes a complete finite state machine for the flies; see Scripts/Fly.cs. The states

and events are defined near the top of the file, and the transition logic is implemented further down.

Your task is to read the code, figure out how it works, and draw an FSM diagram for the flies.

• We recommend using draw.io to create the diagram.

• Please place your diagram in the top-level directory of your GitHub Classroom repo, and

name it “FSM_fly”. You can use any appropriate image format (png, jpg, etc.)

• For full marks, you should use hierarchy such that the “CaughtByFrog” event only

appears once. See the Week 3 slides for an example of a hierarchical FSM.

• Pay attention to small details, and ensure that you draw a formal FSM, not a flowchart.

Implementing the snake FSM (6 marks)

In the starter game, the snakes continually chase the player, which isn’t ideal from gameplay

standpoint. To make their behaviour more interesting, you will implement a finite state machine for

the snakes, following the diagram in Figure 4.

The snakes’ FSM should be implemented similarly to the flies’ FSM. You should use enums to

define the states and events, and you should follow a modular approach, i.e., the state transitions

should be managed via an event-handling method, but the snakes’ actual behaviour in each state

should be coded elsewhere.

Figure 4: The finite state machine (FSM) to be implemented for the snakes.

State descriptions

• PatrolAway: In this state, the snake should move towards a pre-defined “patrol point”

,

using the arrive steering behaviour. The patrol point is already set up in the FullGame scene

and referenced in Scripts/Snake.cs by the variable PatrolPoint. Please use the pre-defined

steering parameters and arrival radius declared at the top of the file.

• PatrolHome: Same behaviour as in PatrolAway, except that the snake should move towards

its “home” position, which is defined in Scripts/Snake.cs by the variable _home.

• Aggro: In this state, the snake should chase the frog via the seek steering behaviour.

• Harmless: In this state, the snake should move towards its “home” position via the arrive

steering behaviour.

Event descriptions

• FrogInRange: The frog moved within AggroRange of the snake. Note:

o AggroRange is already defined in Scripts/Snake.cs.

o You can choose to send this event at every frame when the frog is in range, or only

when it comes in range after previously being out of range. This choice should not

make a difference to the snakes’ behaviour if the FSM is set up correctly.

• FrogOutOfRange: The frog moved farther than DeAggroRange from the snake.

• HitFrog: The snake collided with the frog and is now pacified.

• ReachedTarget: The snake moved within Constants.TARGET_REACHED_TOLERANCE from its

target, which is state-dependent:

o In PatrolAway, the snake’s target is PatrolPoint.position.

o In PatrolHome and Harmless, the snake’s target is _home.

Additional notes

In all of the snake’s states, it should be possible to turn obstacle avoidance on/off via the toggle in

the inspector:

It is recommended (but optional) to give the snakes different colours in different states to make the

transitions more visually obvious. For example, you can use:

_sr.color = new Color(1.0f, 0.7f, 0.7f);

to give the snakes a reddish tinge when they are aggroed.

Part 3: Further Game Development (10 marks)

Bubble mechanic (6 marks)

Extend the control system, making it so that the player can shoot bubbles by pressing the spacebar.

• A bubble prefab has been provided for you, although you may find that you need to add

some components to it.

• The bubble should shoot in the direction that the frog is facing. The launch speed is up to

you; just pick a sensible-looking value. Try to tweak the spawn position of the bubble so

that it appears to come out of the frog’s mouth, not its body.

• Bubbles should burst (get destroyed) after 2 seconds, or if they collide with a snake or

anything on the Obstacle layer.

• If a bubble collides with a snake that is aggroed, it should cause the snake to transition to

the Harmless state. (You’ll need to update the snake’s FSM accordingly.)

• If a bubble collides with a snake that isn’t aggroed, it should just burst without having any

effect on the snake.

Additionally, make it so that bubbles alert the flies to the frog:

• If a bubble comes within BubbleFleeRange of a fly (defined in Scripts/Fly.cs), it should

trigger a ScaredByBubble event (not yet defined). This event should have the same effect on

the fly as ScaredByFrog, i.e., it should cause the fly to flee the frog, not the bubble.

• Restrict the triggering of the EscapedFrog event to only occur once the fly is outside

StopFleeingRange of the frog and all bubbles.

Health bar and fly counter (2 marks)

Modify the overlay at the top-left of the screen to display the player’s health and fly count properly.

• The player should start with 3 health and lose 1 health each time the frog collides with an

aggroed snake. (Colliding with a non-aggroed snake should have no effect.)

• The fly counter should start at zero and increment each time the player catches a fly.

Handling Game Over (2 marks)

Add a game over screen that indicates whether the player has won or lost, and allows the game to

be restarted.

• This is easiest to understand by seeing the demo video on the Assignment 1 Canvas page.

• The solution in the demo is adapted from: https://gt3000.medium.com/game-over-man-

creating-a-game-over-screen-in-unity-90e1be71cd85

• If the player runs out of health, the screen should read “You died!” (see Figure 5).

• If the player’s fly count reaches 10, the game should end with the message “You won!”.

• The game should pause on the game over screen, and the player should be able to restart the

game by pressing ‘R’.

• A suitable panel has already been created in the FullGame scene (named

“GameOverPanel”) but it is deactivated and none of the functionality has been written.

Figure 5: Illustration of how the game over screen should look when the player dies.

4 Submission

You do not need to submit anything on Canvas for this assignment; we will just grade your most

recent commit on GitHub Classroom. Please note:

• As explained on Canvas, please use Unity LTS Release 2022.3.19f1. We will deduct one

mark if you submit your project with a different Unity version.

• Please fill in your student number in README.md, especially if you are using a non-RMIT

GitHub account.

• Late submissions will incur a penalty of 10% of the total score possible per calendar day.

• If you do submit late, please let us know so that we download the correct version of your

assignment.

• Information on applying for special consideration is available here:

https://www.rmit.edu.au/students/my-course/assessment-results/special-consideration-

extensions/special-consideration

5 Academic integrity and plagiarism (standard warning)

Academic integrity is about honest presentation of your academic work. It means acknowledging

the work of others while developing your own insights, knowledge and ideas. You should take

extreme care that you have:

• Acknowledged words, data, diagrams, models, frameworks and/or ideas of others you have quoted

(i.e. directly copied), summarised, paraphrased, discussed or mentioned in your assessment through

the appropriate referencing methods.

• Provided a reference list of the publication details so your reader can locate the source if

necessary. This includes material taken from Internet sites. If you do not acknowledge the sources

of your material, you may be accused of plagiarism because you have passed off the work and ideas

of another person without appropriate referencing, as if they were your own.

RMIT University treats plagiarism as a very serious offence constituting misconduct. Plagiarism

covers a variety of inappropriate behaviours, including:

• Failure to properly document a source.

• Copyright material from the internet or databases.

• Collusion between students.

For further information on our policies and procedures, please refer to the following:

https://www.rmit.edu.au/students/student-essentials/rights-and-responsibilities/academic-integrity.

We will run code similarity checks.

6 Marking Guide

The rubric used for marking will be provided on Canvas at the bottom of the assignment page.

 

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468