国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

代做Data Structures 2D real-time strategy game

時間:2023-12-29  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯


 

Data Structures: Assignment 3

Pathfinding

SP2, 2017

James Baumeister

May 2017

1 Introduction

As a game designer you want to develop your first 2D real-time strategy game.

You envision a game where a player is in a procedurally generated terrain map,

performing tasks with non-player characters and defending against attacks from

enemies. The type of map you want to use will feature several biomes, ranging

from deserts to lush rainforests. Each of these biomes will have different characteristics and moving through the different biomes will have different difficulty

levels. As this is your first foray into game development, you want to start with

a very simple map—a 10 × 10 square grid where the player can move north,

south, east, west, north-east, south-east, north-west, south-west. With these

criteria in mind, you decide that a graph is the perfect data structure in which

to store all the possible biomes and their connections to each other.

In this assignment we will build an undirected graph structure. A node, or

vertex, in this graph will represent a terrain biome with its position in the graph

being the centre of a 1x1 square. Each node contains information about the

node’s position in the map, as well as its terrain features, including the biome,

elevation and other locale- and weather-based characteristics. Each node can

have up to eight connections, or edges, to other nodes, depending on its position

in the map. These edges are what allow travel from one node to another.

This assignment consists of two parts. In part A you will complete a number

of helper methods that will be useful when implementing search algorithms in

the next part. In part B you will generate all the edges between each of the

nodes to form them into the 10 × 10 grid. You will also implement a number

of different search algorithms. Depth- and breadth-first searches can both find

a path from one node to another, but do it in different ways and can have

very different results. They also do not take into account the weight of the

edge or, in other words, the difficulty of travelling over particular biomes. The

Dijkstra’s and A* search algorithms both take into account the weight and so

1

more accurately provide a path that is both short and least costly, or difficult

to travel.

This assignment provides two means by which you can test your code. Running GraphGUI will provide a graphical user interface (GUI) that visualises the

graph, the terrains, the nodes and the edges. It also animates the player node,

showing the path that your search method calculates. You can use this GUI to

view the outcome of your algorithm implementations and troubleshoot1

. There

are also unit tests that will give you an idea of the accuracy of your implementations. The tests are not exhaustive and the mark should only be viewed

as a guide. Alternative tests will be run by the markers to ensure that your

answers are not hard-coded to the tests. Many exception cases are not tested,

so you should write your own testing methods. It is suggested that you complete the assignment in the order outlined in the following sections. The later

steps rely on the correct implementation of the earlier steps, particularly the

connectNodes method.

Figure 1: Importing the project through File → Import

1See Appendix A to learn how to control the GUI

2

1.1 Importing into eclipse

The assignment has been provided as an eclipse project. You just need to import

the project into an existing workspace. See Figure 1 for a visual guide. Make

sure that your Java JDK has been set, as well as the two jar files that you need

for junit to function. This can be found in Project → Properties → Java Build

Path → Libraries. The jar files have been provided within the project; there

is no need to download any other version and doing so may impact the testing

environment.

2 Part A

In this section you will complete some methods that are necessary for building

and utilising the graph structure that you will build in section 3.

2.1 Edge

The Edge class represents a connection from one node to up to eight others. An

Edge object has three class variables:

private Node node1;

private Node node2;

private double weight;

2.1.1 void calculateWeight()

The weight of an Edge should be calculated using the calculateWeight()

method upon creation of the Edge. The weight is calculated as the Euclidean

distance between the two nodes multiplied by the average biome weight between

the two nodes. This can be represented mathematically as follows:

w(e) = d(p, q) × ((b1 + b2)/2)

where b1 is the biome value of the source node, and b2 is the biome value of the

target node. d is a function that calculates the Euclidean distance between two

2D points, p and q.

2.2 EdgeTest

EdgeTest will assign marks as shown in Table 1.

2.3 Vector2

The Vector2 class represents a 2D point in space and contains an x (horizontal)

and a y (vertical) coordinate. For this assignment we are only concerned with

finding the distance between two 2D points. A Vector2 object has two class

variables:

3

Table 1: EdgeTest mark allocation

Test Marks

constructor 5

calculateWeight 5

Total: 10

public double x;

public double y;

2.3.1 public double distance(Vector2 v2)

This method should calculate the Euclidean distance between two points. The

method should be called on one Vector2 object, and passed the second Vector2

object as the parameter. The distance should be returned as a double. The

algorithm for calculating the Euclidean distance is as follows:

d(p, q) = p

(q1 − p1)2 + (q2 − p2)2

2.4 VectorTest

VectorTest will assign marks as shown in Table 2.

Table 2: VectorTest mark allocation

Test Marks

distance 5

Total: 5

3 Part B

In this section you will implement a number of methods in the Graph class.

First, you will create edges between a given set of vertices. Next, you will

implement some helper methods for navigating the graph. Lastly, you will

implement several graph searching algorithms.

4

3.1 Graph

The graph structure that you must build in this assignment forms a 10×10 grid,

with all edges between the nodes being undirected. Due to the way in which

our graph is built, node pairs have mirrored edges—node 1 has an edge to node

2, node 2 has an edge to node 1. The Graph class has no class variables.

3.1.1 void connectNodes(Node[] nodes)

This method connects all nodes in a given array to form a 10 × 10 grid-shaped

graph. This method must be successfully completed before attempting any other

graph searching methods! The provided GUI can help you visualise how well

your implementation is functioning. Before completing connectNodes, the GUI

should display as shown in Figure 2. Once all of the edges have been correctly

created, the GUI will display as shown in Figure 3. Every node in the graph

can have up to eight edges, depending on its position. Central nodes will use all

eight to connect to all their surrounding neighbours. Think about how many

neighbours corner and edge nodes have and how many edges you need to create.

In order to develop an algorithm there are some simple constants that you may

utilise:

• The top-left corner of the graph has the 2D coordinate (0, 0).

• The bottom-right corner of the graph has the 2D coordinate (9, 9).

• A node’s position is the exact centre of a biome square.

• In the provided Node[], for every node(i) such that

i mod 10 = 0

node(i) is on the left edge.

It is very important to adhere to the order of the mappings shown in Table 3 when populating a node’s edge list. Note that a node does not need

a list containing eight edges if it only requires three, but the order must be

maintained—for example, east before south, north before south-east.

3.1.2 Edge getEdge(Node source, Node destination)

This methods takes as arguments two Node objects. It should search each node’s

list of Edge objects for one that connects the two nodes and return the source

node’s edge. If there is none found, the method should return null.

3.1.3 double calculateCost(Node[] vertices)

This method should calculate the total cost of travelling from one node

(Node[0]) to a target node (Node[length-1]). The total value should be returned. If the starting and target nodes are the same, the method should return

0.

5

Table 3: Edge list index–direction mappings

Edge list index Direction of connected node

0 East

1 West

2 South

3 North

4 North-east

5 South-east

6 North-west

7 South-west

3.1.4 Node[] breadthFirstSearch(Node start, Node target)

The breadthFirstSearch method takes as arguments two Node objects—a

starting node and a target node, respectively. You must implement a breadthfirst search algorithm to find the shortest path from start to target and return that path as a Node array, ordered from start (index 0) to target (index

length−1). This method should not take into account edge weights.

3.1.5 Node[] depthFirstSearch(Node start, Node target)

The depthFirstSearch method takes as arguments two Node objects—a starting node and a target node, respectively. Unlike the breadth-first search, depthfirst searching will likely not find the shortest path, so you should see drastically

different paths being generated. depthFirstSearch should return the path as

a Node array, ordered from start (index 0) to target (index length−1). This

method should not take into account edge weights.

3.1.6 Node[] dijkstrasSearch(Node start, Node target)

The method should use Dijkstra’s algorithm to search the graph for the shortest

path from start to target while taking into account the cost of travel (i.e. edge

weight). Visualising this algorithm should show that sometimes the path may

not be the most direct route. Rather, it should be the least costly. Your

implementation should be a true implementation of the algorithm2

. Your code

will be inspected to ensure that an alternative algorithm has not been used.

2Closely follow the textbook example. Subtle differences in algorithms could impact your

performance against the tests

6

Figure 2: The GUI before completing the connectNodes method

dijkstrasSearch should return the path as a Node array, ordered from start

(index 0) to target (index length−1).

3.1.7 Node[] aStarSearch(Node start, Node target

This method should use the A* algorithm, similar to Dijkstra’s algorithm, to

search the graph for the least costly path. Unlike Dijkstra’s, which searches

in all directions, the A* algorithm uses a heuristic to predict the direction of

search. The heuristic you should use should be shortest distance, using the

distance algorithm you implemented earlier. Your implementation should be

a true implementation of the algorithm3

. Your code will be inspected to ensure

that an alternative algorithm has not been used. aStarSearch should return a

Node array containing the path, ordered from start (index 0) to target (index

length−1).

3.2 GraphTest

GraphTest will assign marks as shown in Table 4.

3This is a research task, but this website should be very helpful: http://www.

redblobgames.com/pathfinding/a-star/introduction.html

7

Figure 3: The GUI after completing the connectNodes method

A Using the GUI

A GUI has been provided to aid understanding how your graph searching algorithm implementations are functioning. The window contains a graphical

representation of the graph on the left, and three buttons on the right (see

Figure 3. The buttons labelled ‘Biomes’ and ‘Polygons’ are essentially toggles

for displaying an outline of the node squares (shown in Figure 4. ‘Biomes’ is

activated by default. The button labelled ‘Nodes’ controls whether or not the

red node circles and pink edge lines are shown—click to toggle between the two.

The blue player node will render at the nominated start node and its position

will update if a path is provided.

As the GUI operates independently to the testing suite, there are some

aspects that you must manually control in order to show the desired information.

The GraphRender class has the following constants:

private final int START_NODE = 0;

private final int TARGET_NODE = 9;

private final int ANIMATION_DELAY = 500;

private final String METHOD = "breadthFirstSearch";

You may modify these values. As an example, if you were testing your Dijkstra’s

algorithm implementation and wanted to match one of the unit tests, you could

change START_NODE to 8, TARGET_NODE to 0 and METHOD to "dijkstrasSearch".

ANIMATION_DELAY represents the delay for the blue player circle to jump along

8

Table 4: GraphTest mark allocation

Test Marks

connectNodes 10

getEdge 5

calculateCost 5

breadthFirstSearch 20

depthFirstSearch 15

dijkstrasSearch 20

aStarSearch 10

Total: 85

nodes in the path, in milliseconds; increase to slow the animation, decrease to

請加QQ:99515681 或郵箱:99515681@qq.com   WX:codehelp

 

 

掃一掃在手機打開當前頁
  • 上一篇:MA2605代做、代寫MATLAB編程語言
  • 下一篇:莆田鞋一般多少錢一雙,莆田鞋零售價格一覽表
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    流體仿真外包多少錢_專業CFD分析代做_友商科技CAE仿真
    流體仿真外包多少錢_專業CFD分析代做_友商科
    CAE仿真分析代做公司 CFD流體仿真服務 管路流場仿真外包
    CAE仿真分析代做公司 CFD流體仿真服務 管路
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真技術服務
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲勞振動
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲
    流體cfd仿真分析服務 7類仿真分析代做服務40個行業
    流體cfd仿真分析服務 7類仿真分析代做服務4
    超全面的拼多多電商運營技巧,多多開團助手,多多出評軟件徽y1698861
    超全面的拼多多電商運營技巧,多多開團助手
    CAE有限元仿真分析團隊,2026仿真代做咨詢服務平臺
    CAE有限元仿真分析團隊,2026仿真代做咨詢服
    釘釘簽到打卡位置修改神器,2026怎么修改定位在范圍內
    釘釘簽到打卡位置修改神器,2026怎么修改定
  • 短信驗證碼 寵物飼養 十大衛浴品牌排行 suno 豆包網頁版入口 目錄網 排行網

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看
    国产精品91久久久久久| 国产精品高潮呻吟久久av黑人| 日本不卡一二三区| 中文字幕在线亚洲精品| 欧美成人精品在线播放| 国产精品久久中文| 国产精品免费区二区三区观看| 日韩在线视频国产| 久久精品久久精品国产大片| 国产二级片在线观看| 91精品国产沙发| www污在线观看| 99精彩视频| 久久久综合av| 久久久久久免费看| 久久久久久噜噜噜久久久精品| 色婷婷综合成人| 久久精品99久久久久久久久 | 久久久久久久久久国产精品| 久久99精品久久久久久久久久| 国产激情久久久| 久久国产手机看片| 日韩中文字幕在线精品| 国产精品乱码| 欧美激情乱人伦| 亚洲国产日韩美| 日本一区二区久久精品| 丁香六月激情网| 日韩免费高清在线| 激情五月宗合网| 成人av在线网址| 91传媒久久久| 视频在线观看99| 久久五月情影视| 亚洲精品免费网站| 午夜精品在线观看| 日韩欧美一区二区三区四区| 欧美精品欧美精品| 国产欧美日韩最新| 久久综合中文色婷婷| 久久天天躁狠狠躁夜夜躁| 精品国产一区二区三区四区vr| 亚洲97在线观看| 欧美激情国产精品日韩| 国产免费黄色小视频| 国产精品99久久免费黑人人妻| 精品国产拍在线观看| 欧美日产国产成人免费图片| 日日摸日日碰夜夜爽无码| 国内精品中文字幕| 国产精品永久免费在线| 久久国产午夜精品理论片最新版本 | 国产精品久久久久久久久久久久久| 中文字幕一区二区三区有限公司 | 苍井空浴缸大战猛男120分钟| 国产极品在线视频| 久久精品91久久香蕉加勒比| 宅男av一区二区三区| 欧美 日韩 国产 激情| 91高清免费视频| 久热精品视频在线观看| 日本精品一区二区三区不卡无字幕| 国产深夜男女无套内射| 日韩中文字幕在线观看| 亚洲一区二区三区色| 国内精品久久久久久久| 国产福利精品视频| 在线国产99| 国产资源第一页| 久久九九免费视频| 色之综合天天综合色天天棕色| 国产又黄又大又粗视频| 精品国产一区二区三区久久狼5月| 亚洲三区在线观看| 国产三级精品网站| 国产成人啪精品视频免费网| 午夜精品久久久久久久久久久久 | 国产精品美女在线播放| 午夜精品一区二区三区四区| 国产伦精品一区二区三区视频免费 | 日韩精品伦理第一区| www.欧美黄色| 九九精品视频在线观看| 精品日产一区2区三区黄免费| 久久本道综合色狠狠五月| 亚洲精品无人区| 超碰成人在线免费观看| 国产精品沙发午睡系列| 亚洲一区二区久久久久久| 国内少妇毛片视频| 九九九九九精品| 亚洲 高清 成人 动漫| 国产午夜大地久久| 国产精品成人国产乱一区| 欧美日本韩国在线| 久久精品xxx| 欧美一级免费在线观看| 777国产偷窥盗摄精品视频| 一区二区三区电影| 成人精品久久一区二区三区| 亚洲一区精品电影| 国产乱码一区| 一本久道久久综合| 91av在线国产| 日韩视频在线视频| 国产成人生活片| 明星裸体视频一区二区| 国产精品福利观看| 国产午夜精品一区| 一区二区视频在线免费| 91久久夜色精品国产网站| 婷婷精品国产一区二区三区日韩| 91国产视频在线播放| 日本视频久久久| 久久久久久国产三级电影| 欧美久久久久久久久久久久久久| 国产成人女人毛片视频在线| 国产综合视频在线观看| 亚洲最大av网| 国产成人精品免费看在线播放| 日韩欧美精品在线不卡| 国产精品免费电影| 国产美女精品视频免费观看| 亚洲第一在线综合在线| 国产成人精品免费视频大全最热 | 欧美精品在线第一页| 国产主播在线一区| 亚洲精品一品区二品区三品区| 国产成人极品视频| 极品校花啪啪激情久久| 亚洲综合色激情五月| 久久99欧美| 国产一区国产精品| 少妇高清精品毛片在线视频 | 日日摸夜夜添一区| 国产日韩精品入口| 日韩中文不卡| 国产精品免费视频一区二区| www.日本在线视频| 日韩欧美亚洲v片| 久久伊人免费视频| 久久综合伊人77777麻豆| 加勒比成人在线| 亚洲成人第一| 国产精品久久电影观看| 国产精品99久久久久久人| 免费看国产一级片| 日本中文不卡| 精品久久久久久无码国产| 国产成人高清激情视频在线观看| 国产一区二区色| 人人做人人澡人人爽欧美| 精品九九九九| 国产成人无码a区在线观看视频| 成人精品在线观看| 欧美日韩黄色一级片| 午夜欧美大片免费观看| 国产精品久久久久9999爆乳| 国产成人在线一区二区| 国产女大学生av| 欧美性受xxxx黑人猛交88| 亚洲精品天堂成人片av在线播放| 国产精品久久久久av| 久久精品国产第一区二区三区最新章节 | 欧美一区二视频在线免费观看| 尤物一区二区三区| 国产精品美女免费看| 91精品国产乱码久久久久久久久| 国产一区二区视频在线免费观看| 欧美中文字幕在线视频| 色之综合天天综合色天天棕色| 欧美极品欧美精品欧美视频| 国产精品久久久久久av福利 | 欧美精品做受xxx性少妇| 久久国产精品99久久久久久丝袜| www.中文字幕在线| 国产日韩欧美大片| 免费看日b视频| 人人澡人人澡人人看欧美| 中国成人亚色综合网站| 国产精品精品视频一区二区三区 | 日韩精彩视频| 少妇人妻无码专区视频| 亚洲欧洲免费无码| 宅男一区二区三区| 欧美日本黄视频| 不卡av电影院| 国产精品久久一| 久久久www成人免费精品张筱雨| 久久久久五月天| 日韩亚洲一区二区| 久久久久亚洲精品国产| 久久精品xxx| 久草热视频在线观看| 久久久久久久有限公司| 久久av免费观看| 色妞欧美日韩在线| 久久久国产精彩视频美女艺术照福利| 日韩一区av在线| 国产精品视频男人的天堂|