加勒比久久综合,国产精品伦一区二区,66精品视频在线观看,一区二区电影

合肥生活安徽新聞合肥交通合肥房產(chǎn)生活服務(wù)合肥教育合肥招聘合肥旅游文化藝術(shù)合肥美食合肥地圖合肥社保合肥醫(yī)院企業(yè)服務(wù)合肥法律

代做Data Structures 2D real-time strategy game

時(shí)間:2023-12-29  來(lái)源:合肥網(wǎng)hfw.cc  作者:hfw.cc 我要糾錯(cuò)


 

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

請(qǐng)加QQ:99515681 或郵箱:99515681@qq.com   WX:codehelp

 

 

掃一掃在手機(jī)打開當(dāng)前頁(yè)
  • 上一篇:MA2605代做、代寫MATLAB編程語(yǔ)言
  • 下一篇:莆田鞋一般多少錢一雙,莆田鞋零售價(jià)格一覽表
  • 無(wú)相關(guān)信息
    合肥生活資訊

    合肥圖文信息
    2025年10月份更新拼多多改銷助手小象助手多多出評(píng)軟件
    2025年10月份更新拼多多改銷助手小象助手多
    有限元分析 CAE仿真分析服務(wù)-企業(yè)/產(chǎn)品研發(fā)/客戶要求/設(shè)計(jì)優(yōu)化
    有限元分析 CAE仿真分析服務(wù)-企業(yè)/產(chǎn)品研發(fā)
    急尋熱仿真分析?代做熱仿真服務(wù)+熱設(shè)計(jì)優(yōu)化
    急尋熱仿真分析?代做熱仿真服務(wù)+熱設(shè)計(jì)優(yōu)化
    出評(píng) 開團(tuán)工具
    出評(píng) 開團(tuán)工具
    挖掘機(jī)濾芯提升發(fā)動(dòng)機(jī)性能
    挖掘機(jī)濾芯提升發(fā)動(dòng)機(jī)性能
    海信羅馬假日洗衣機(jī)亮相AWE  復(fù)古美學(xué)與現(xiàn)代科技完美結(jié)合
    海信羅馬假日洗衣機(jī)亮相AWE 復(fù)古美學(xué)與現(xiàn)代
    合肥機(jī)場(chǎng)巴士4號(hào)線
    合肥機(jī)場(chǎng)巴士4號(hào)線
    合肥機(jī)場(chǎng)巴士3號(hào)線
    合肥機(jī)場(chǎng)巴士3號(hào)線
  • 短信驗(yàn)證碼 目錄網(wǎng) 排行網(wǎng)

    關(guān)于我們 | 打賞支持 | 廣告服務(wù) | 聯(lián)系我們 | 網(wǎng)站地圖 | 免責(zé)聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網(wǎng) 版權(quán)所有
    ICP備06013414號(hào)-3 公安備 42010502001045

    日韩欧美一区二区三区在线视频| 久久男女视频| 嫩草伊人久久精品少妇av杨幂| 91精品一区二区三区综合| 中文字幕av亚洲精品一部二部| 日韩aaaa| av一区二区高清| 日韩有吗在线观看| 国产精品v日韩精品v欧美精品网站| 日韩精品一卡二卡三卡四卡无卡| 精品久久97| 国产欧美日韩免费观看| 成人午夜在线| а√天堂8资源在线| 免费久久久久久久久| 一区三区自拍| 亚洲欧洲一二区| 色综合久久久| 国产精品精品| 一本色道久久| 久久国产亚洲精品| 秋霞午夜一区二区三区视频| 一区二区三区网站| 美女精品一区二区| 日韩一区精品| 日韩一区电影| 91亚洲成人| 免费看欧美女人艹b| 亚洲精品小说| 久久精品高清| 精品资源在线| 国产精品网址| 精品视频在线播放一区二区三区| 亚洲毛片在线| 亚洲三级观看| 免费亚洲视频| 色999久久久精品人人澡69| 亚洲黄色免费看| 成人一区不卡| 欧美mv日韩| 色婷婷亚洲mv天堂mv在影片| 一本色道久久综合亚洲精品不| 欧美~级网站不卡| 国产99亚洲| 久久国产日本精品| 色哟哟精品丝袜一区二区| 欧美三区视频| 在线精品国产亚洲| 9l亚洲国产成人精品一区二三| 日韩av三区| 婷婷综合一区| 日韩欧美中文字幕在线视频 | 一区二区电影| 欧美人成在线| 日本欧美大码aⅴ在线播放| 久久精品一区二区三区中文字幕| 欧美91在线|欧美| 日韩国产欧美视频| 亚洲精选久久| 成人黄色91| 欧美精品福利| 亚洲黄页在线观看| 免费观看亚洲天堂| 综合激情五月婷婷| 久久精品亚洲成在人线av网址| 国产一区丝袜| 国产精品av一区二区| 黄色av一区| 葵司免费一区二区三区四区五区| 视频在线观看一区| 中文字幕在线看片| 亚洲成人1区| 另类欧美日韩国产在线| 国产一区二区在线观| 日韩二区三区在线观看| 999久久久精品一区二区| 成人午夜av| 99亚洲一区二区| 久久久久久久尹人综合网亚洲| 日本在线高清| 久久精品女人| 国产最新精品| 麻豆精品少妇| 91超碰国产精品| 色偷偷综合网| 日韩综合小视频| 日韩最新在线| 欧美一区2区| 蜜桃久久精品一区二区| 日韩中文在线电影| 久久久免费毛片| 超碰精品在线| 国产精品毛片一区二区三区| 正在播放日韩精品| 日韩精品免费视频人成| 欧美女优在线视频| 久久天堂精品| 国产精品久久天天影视| 国产精品久久久久久模特| 国产一区99| 男女视频一区二区| 五月婷婷亚洲| 日本三级一区| 国产精品一级在线观看| 日韩最新av| 在线一级成人| 三级一区在线视频先锋| 99精品免费网| 国产成人视屏| 欧美五码在线| 裸体素人女欧美日韩| 热久久国产精品| 九色成人搞黄网站| www久久久| 欧美激情15p| 午夜在线视频观看日韩17c| 中国女人久久久| 成人小电影网站| 日本欧美一区二区三区乱码| 日韩精品一级| 黄色成人91| 国产成人久久精品麻豆二区| 白嫩亚洲一区二区三区| 日韩三级av高清片| 免费人成黄页网站在线一区二区| 成人在线高清| 一区中文字幕| 久久福利毛片| 另类欧美日韩国产在线| 99热国内精品| 国产h片在线观看| 99re8精品视频在线观看| 日本韩国欧美超级黄在线观看| 媚黑女一区二区| 美女视频一区二区三区| 中文无码日韩欧| 嫩草成人www欧美| 麻豆一区二区三区| 精品日韩一区| 色婷婷色综合| 中文字幕乱码亚洲无线精品一区| 久久久人人人| 亚洲十八**毛片| 日本免费一区二区视频| 日韩中文字幕亚洲一区二区va在线| 国产福利91精品一区二区| 日本亚州欧洲精品不卡| 亚洲制服少妇| 欧美日韩一区二区三区四区在线观看 | 清纯唯美亚洲综合一区| 美国毛片一区二区三区| 欧美激情 亚洲a∨综合| 不卡在线一区| 国产美女久久| 国产精品一区二区三区美女| 欧美3p在线观看| 精品入口麻豆88视频| 成人一区二区| 欧美日本一区| 伊人精品久久| 噜噜噜久久亚洲精品国产品小说| 日一区二区三区| 成人交换视频| 日韩一二三区| 天堂av中文在线观看| 日韩高清在线观看一区二区| 久久久久久美女精品| 麻豆极品一区二区三区| 91精品久久久久久久久久不卡| 国产成人77亚洲精品www| 欧美调教在线| 亚洲一二三四| 香蕉久久99| 日韩精品高清不卡| 日韩一级欧洲| 国产免费久久| 日韩高清不卡| 在线视频观看日韩| 一区二区三区精品视频在线观看| 极品日韩av| 51一区二区三区| 激情91久久| 国产一区二区三区日韩精品| 三级影片在线观看欧美日韩一区二区 | av在线国产精品| 亚洲女色av| 久久久久99| 91九色成人| 岛国av在线播放| 欧美福利影院| 国产日产一区| 日韩免费在线| 欧美福利一区| 日韩精品中文字幕吗一区二区| 日韩电影免费在线观看| 久久狠狠婷婷| 中文字幕成人| 自拍偷拍欧美专区| 伊人久久亚洲| 日本不卡视频一二三区|