StudentShare
Contact Us
Sign In / Sign Up for FREE
Search
Go to advanced search...
Free

Game Programming and Breadth First Search - Assignment Example

Cite this document
Summary
From the paper "Game Programming and Breadth First Search " it is clear that the input to the program is the set of vertices of all convex polygons, the initial and goal configuration of the point robot. The program returns the shortest path from the initial to the goal configuration. …
Download full paper File format: .doc, available for editing
GRAB THE BEST PAPER92.4% of users find it useful
Game Programming and Breadth First Search
Read Text Preview

Extract of sample "Game Programming and Breadth First Search"

A1. Breadth First Search (BFS) Traversal Algorithm: In BFS traversal, nodes on the same level are examined first. So, instead of going deep into thegraph, we examine the nodes across the breadth of the graph; before going to the next level. For BFS, we use a queue to pick a node to visit first, and place its unprocessed adjacent nodes in queue. Similarly, pick a node front of queue; if unvisited, we visit the node and again place its neighbors in the queue. Output of BFS traversal: a-----d-----c-----e-----f-----b A2. Depth First Search (DFS) Traversal: Contrary to BFS, DFS involves following the path in the graph as deep as possible. If there are no unvisited, adjacent nodes, then we backtrack to the previous level and start traversal again. Thus, the depths of the graph are first examined. For DFS, a stack can be maintained to keep a record of all the visited nodes, to ease the backtracking process. Output of DFS traversal: a-----d-----c-----f-----b-----e A3. The previous output in the form of a DFS tree: Answer 2.2 A* Algorithm A1. There in all 32 states corresponding to each vertex of every polygon, along with the start and end points of the navigation. The different paths towards the goal are, considering each start point and end point as 0 in the forward direction: Path 1: 0-4-1-6-3-2-0 (goal) Path 2: 0-4-1-6-2-0 (goal) Path 3: 0-4-1-7-6-3-2-0 (goal) Path 4: 0-4-1-7-3-2-0 (goal) Path 5: 0-4-7-6-3-2-0 (goal) Path 6: 0-4-7-6-2-0 (goal) Path 7: 0-4-7-3-2-0 (goal) Path 8: 0-4-6-3-2-0 (goal) Path 9: 0-4-6-2-0 (goal) Path 10: 0-5-1-6-3-2-0 (goal) Path 11: 0-5-1-6-2-0 (goal) Path 12: 0-5-1-7-6-3-2-0 (goal) Path 13: 0-5-1-7-6-2-0 (goal) Path 14: 0-5-1-7-3-2-0 (goal) Path 15: 0-5-7-6-3-2-0 (goal) Path 16: 0-5-7-6-2-0 (goal) Path 17: 0-5-7-3-2-0 (goal) Path 18: 0-5-3-2-0 (goal) A2: State Space Representation: A3. Working of A* algorithm Given a suitable problem, we represent the initial conditions of the problem with an appropriate initial state, and the goal conditions as the goal state. For each action that is performed, generate successor states to represent the effects of the action. If this continues, at some point one of the generated successor states is the goal state, then the path from the initial state to the goal state is the solution to the problem. What A* does is generate and process the successor states in a certain way. Whenever it is looking for the next state to process, A-star employs a heuristic function to try to pick the best state to process next. If heuristic function is good, not only will A-star find a solution quickly, but it can also find the best solution possible. Brief Description:: The A* algorithm maintains two sets or ordered lists OPEN and CLOSED. OPEN list keeps a track of those nodes that need to be examined. CLOSED list keeps track of those nodes that have already been examined. Initially, OPEN list contains just the initial node. Start with initial node and insert it in ordered list OPEN list. Create a list CLOSED. This is initially an empty list. Each node 'n' maintains the following: g(n) = the cost of getting from the natal node to 'n' h(n) = the estimate, according to the heuristic function, of the cost of getting from n to the goal node. f(n) = g(n) + h(n); intuitively, this is the estimate of the best solution that goes through n. If OPEN is empty, exit with failure in algorithm. Select first node on OPEN. Remove it from OPEN and put it on CLOSED. This is node 'n'. If 'n' is goal node, exit the program. The solution is obtained by treating a path backwards along arcs in the tree from the node to n. Expand node n. This will generate successors. Read the list OPEN according to heuristic and go back to step 4. Each node maintains a pointer to its parent node, so that later on the best solution if founded can be retrieved. If n is goal node then we are done with solution given by backtracking. For each successor node n, if it is already in CLOSED list and the copy there has an equal or lower 'f' estimate, we can safely discard the newly generated n and move on. Similarly if n is already in the OPEN list and the copy there has an equal or lower 'f' estimate, we can discard the newly generated n and move on. If no better version of n exists on either the CLOSED or OPEN lists, we remove the inferior copies from the two lists and set n as the parent of n. We also calculate the cost estimates for n as follows: Set g(n) to g(n) + cost of getting n to n. Set h(n) to heuristic estimate of getting from n to goal node. Set f(n) to g(n) + h(n). Lastly, add n to the OPEN list and return to the beginning of the main loop. The A* algorithm not only gives quick solution but also gives the best possible solution for a suitable problem; if good heuristic function is used. (1) Pseudo code: Data structures used are: Class Node is defined with a constructor Node (). Structure OPENlist is created to store all the non-examined nodes, to store fdash and name. While structure CLOSEDlist is created to store all the examined nodes to store pointer to the parent node and next node. Add_OPEN function is used to add successors which have been generated but not yet examined in OPEN. It's parameter is structure OP object. Input: successor which is to be added Output: none Function: Generate_succ (), to generate successors of BESTNODE. It has two argument, name[D] and class Node pointer *p[TOT]. Input: BESTNODE, input tree Output: none Calls: Add_OPEN(temp) Function: Add_CLOSED (), to add already examined nodes in CLOSED. It has one array argument, x[D]. Input: BESTNODE Output: none Calls: none Function: Delete_OPEN (), to delete node from OPEN. It does not have any parameter. Input: none Output: none Calls: none Function: Find_Optimal_Path (), to find optimal path from initial to goal state. It has one parameter, class Node pointer *p[TOT]. Input: input tree Output: none Calls: none #define MAX 15 #define TOT 47 class Node { char parent[D], child[D]; int ht, hdash; public: Node() //constructor { parent[0] = child[0] ='0'; ht = -1; hdash = -1; } typedef struct OPENlist { char name [D]; int fdash; }OP; typedef struct CLOSEDlist { char name [D]; struct CLOSEDlist *next; } CLOSED; CLOSED *prev,*first; Char BESTNODE[D]; Heuristic used to compute hdash value hdash number of positions that are not same in initial an goal state. for(j=0;jht + p[j]->hdash; Add_OPEN(temp); } } Void Add_CLOSED(char x[D]) { CLOSED *temp; If(first==NULL) { first =(CLOSED *)malloc(sizeof(CLOSED)); strcpy(first->name, x); first-name, x); temp- Read More
Cite this document
  • APA
  • MLA
  • CHICAGO
(“Game Programming Assignment Example | Topics and Well Written Essays - 2500 words”, n.d.)
Game Programming Assignment Example | Topics and Well Written Essays - 2500 words. Retrieved from https://studentshare.org/miscellaneous/1519525-game-programming
(Game Programming Assignment Example | Topics and Well Written Essays - 2500 Words)
Game Programming Assignment Example | Topics and Well Written Essays - 2500 Words. https://studentshare.org/miscellaneous/1519525-game-programming.
“Game Programming Assignment Example | Topics and Well Written Essays - 2500 Words”, n.d. https://studentshare.org/miscellaneous/1519525-game-programming.
  • Cited: 0 times

CHECK THESE SAMPLES OF Game Programming and Breadth First Search

Video Games and Artificial Intelligence

He goes onto add that a powerful application-based Chess game would have an equally powerful chess database but would know nothing about any other board game.... This paper ''Video Games and Artificial Intelligence'' tells that Jones provides us with an excellent and explicit comparison between human intelligence and animal intelligence, he states that even though animals can perform some intelligence-driven actions such as communicating and solving simpler problems....
15 Pages (3750 words) Research Paper

Entrepreneurship and Small Business Development

Before exploring his history of innovation, however, it would be more prudent to discuss what innovation is first.... The given essay "Entrepreneurship and Small Business Development" focuses on Bill Gates and on Microsoft, with emphasis to be placed on how their innovations allowed them to become the household names they are today, as well as on inspiring average or even underachieving students to hopefully follow this example....
11 Pages (2750 words) Essay

The history and development of television

Even before that, Paul Gottlieb Nipkow, a German student, had patented the first television in 1884.... Baird's endeavour took the electromechanical television through a continuous phase of technical development ranging from the first transatlantic transmission between London and New York by his company in 1928, the first transmission between shore to ship, demonstratin of the first electromechanical colour, infrared and stereoscopic television to the first live transmission, of the Epson Derby in 1931 and demonstration of the ultra short-wave television in 1932....
12 Pages (3000 words) Essay

Reality Television

he initial efforts were first applied for on-air voice shows and after their resounding success made way into the visual screen; television.... Based on featuring style, purpose and used situations, these shows can be broadly classified in categories like documentary-style, elimination game/quiz shows, self-improvement/makeover, dating shows, talk shows, hidden camera, and hoaxes2....
21 Pages (5250 words) Dissertation

Reality Television

he initial efforts were first applied for on-air voice shows and after their resounding success made way into the visual screen; television.... Based on featuring style, purpose and used situations, these shows can be broadly classified in categories like documentary-style, elimination game/quiz shows, self-improvement/makeover, dating shows, talk shows, hidden camera, and hoaxes2....
16 Pages (4000 words) Assignment

History of Programming and the Ancient Origin

Konrad Zuse, an inventor of the first mechanical computer, utilized binary numbers and punched tapes.... the reporter states that covered by this portfolio are the historical facts about programming from the time it can be logically traced up to the present.... Looking into such relevant information will provide a better understanding of its value, changes, and trends for an analysis of the future purpose and use of programming.... There has been a series of conferences trying to gather accurate knowledge about the root of each programming language....
20 Pages (5000 words) Assignment

The Sources of Googles Competitive Advantage

Since there are numerous loads of data and processing capabilities required to run a search engine, Google has acquired some custom high-performance system that is exactly cost-efficient, beating all its principal rivals in terms of costs (Hardy 2005).... The author of the paper "The Sources of Google's Competitive Advantage" argues in a well-organized manner that there are several strengths specific to Google that have allowed the company to differentiate its products from its rivals....
8 Pages (2000 words) Assignment

Enterprise Information Systems: Three Australian Medical Health Websites

Likewise, the report looks at the process of doing a search on Medibank, NIB members ' joining process, and the BUPA searching process from the systems perspective.... This case study "Enterprise Information Systems: Three Australian Medical Health Websites" compares three Australian medical health websites namely BUPA, Medibank, and NIB, excluding the log-in page with the purpose of finding out their functionality and usability....
16 Pages (4000 words) Case Study
sponsored ads
We use cookies to create the best experience for you. Keep on browsing if you are OK with that, or find out how to manage cookies.
Contact Us