{"id":427257,"date":"2018-09-29T20:25:02","date_gmt":"2018-09-29T20:25:02","guid":{"rendered":"https:\/\/acemystudy.com\/?p=4970"},"modified":"2018-10-24T08:45:36","modified_gmt":"2018-10-24T08:45:36","slug":"programming-java-2","status":"publish","type":"post","link":"https:\/\/www.benedictsol.com\/blogs\/programming-java-2\/","title":{"rendered":"Programming java"},"content":{"rendered":"<p>Programming java<\/p>\n<p>see the pdf file<\/p>\n<p>also need to write one page paper on it.<\/p>\n<p>Project 1<\/p>\n<p>CSC 2053 &#8211; Platform Based Computing<\/p>\n<p>Grading: 150 points<\/p>\n<p>Due Date: Oct. 3, 2018<\/p>\n<p>Part 1 &#8211; Solve Puzzle using Breadth First Search (100 points)<\/p>\n<p>Graphs and trees have can represent a multitude of problems. We will create a game tree that<\/p>\n<p>solves the \u201csliding block\u201d problem and traverse this tree using a breadth-first search. This project<\/p>\n<p>is meant to reinforce the basic data structures, variables, and methods that you have learned as<\/p>\n<p>well as complex notions of queues, trees, graphs, and lists. Use the following template code below<\/p>\n<p>as a starting point.<\/p>\n<p>File: Play.java<\/p>\n<p>import java.util.*;<\/p>\n<p>public class Play{<\/p>\n<p>public static List&lt;GameState&gt; explored; \/\/explored stores our marked vertices<\/p>\n<p>public static Deque&lt;GameState&gt; frontier; \/\/frontier is our queue for BFS<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>int[][] tArr = {{1,5,2},{3,4,0},{6,8,7}}; \/\/start state, i.e. tree root<\/p>\n<p>GameState start = new GameState(tArr,null); \/\/ state with tArr state, null parent<\/p>\n<p>explored = new ArrayList&lt;GameState&gt;();<\/p>\n<p>frontier = new ArrayDeque&lt;GameState&gt;();<\/p>\n<p>\/\/Perform a Breadth First Search here<\/p>\n<p>\/\/Note: We will not create the graph or enumerate the edges<\/p>\n<p>\/\/The graph is too large to store in memory<\/p>\n<p>\/\/We will create the vertices of the graph and edge connections on the fly<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>File: GameState.java<\/p>\n<p>import java.util.*;<\/p>\n<p>public class GameState{<\/p>\n<p>public int[][] state; \/\/state of the puzzle<\/p>\n<p>public GameState parent; \/\/parent in the game tree<\/p>\n<p>public GameState() {<\/p>\n<p>\/\/initialize state to zeros, parent to null<\/p>\n<p>}<\/p>\n<p>public GameState(int[][] state) {<\/p>\n<p>\/\/initialize this.state to state, parent to null<\/p>\n<p>}<\/p>\n<p>public GameState(int[][] state, GameState parent) {<\/p>\n<p>\/\/initialize this.state to state, this.parent to parent<\/p>\n<p>}<\/p>\n<p>public GameState swapRight(GameState s, int row, int col) {<\/p>\n<p>\/\/helper function to swap blank space with right block<\/p>\n<p>}<\/p>\n<p>public GameState swapLeft(GameState s, int row, int col) {<\/p>\n<p>\/\/helper function to swap blank space with left block<\/p>\n<p>}<\/p>\n<p>public GameState swapUp(GameState s, int row, int col) {<\/p>\n<p>\/\/helper function to swap blank space with up block<\/p>\n<p>}<\/p>\n<p>public GameState swapDown(GameState s, int row, int col) {<\/p>\n<p>\/\/helper function to swap blank space with down block<\/p>\n<p>}<\/p>\n<p>public boolean isEnd() {<\/p>\n<p>\/\/helper function to check if the GameState is the end state e.g.<\/p>\n<p>\/\/0 1 2<\/p>\n<p>\/\/3 4 5<\/p>\n<p>\/\/6 7 8<\/p>\n<p>}<\/p>\n<p>public ArrayList&lt;GameState&gt; getAdjacent() {<\/p>\n<p>\/\/Use the swap functions to generate the new vertices of the tree<\/p>\n<p>\/\/Beware of the boundary conditions, i.e. don\u2019t swap left when you are<\/p>\n<p>\/\/already on the left edge<\/p>\n<p>}<\/p>\n<p>@Override<\/p>\n<p>public boolean equals(Object o) {<\/p>\n<p>\/\/test that 2 GameStates are equal<\/p>\n<p>}<\/p>\n<p>@Override<\/p>\n<p>public String toString() {<\/p>\n<p>\/\/ print out the int[][] array in a 3&#215;3 block e.g.<\/p>\n<p>\/\/0 1 2<\/p>\n<p>\/\/3 4 5<\/p>\n<p>\/\/6 7 8<\/p>\n<p>}<\/p>\n<p>Part 2 &#8211; PDF write up (50 points) Create a 1-2 page write up that summarizes the interesting<\/p>\n<p>parts of your program. Include any problems or insights that you encountered.<\/p>\n<p>Sample solution of the given problem. Your program should output the solution in a similar<\/p>\n<p>fashion.<\/p>\n<p>0 1 2<\/p>\n<p>3 4 5<\/p>\n<p>6 7 8<\/p>\n<p>3 1 2<\/p>\n<p>0 4 5<\/p>\n<p>6 7 8<\/p>\n<p>3 1 2<\/p>\n<p>6 4 5<\/p>\n<p>0 7 8<\/p>\n<p>3 1 2<\/p>\n<p>6 4 5<\/p>\n<p>7 0 8<\/p>\n<p>3 1 2<\/p>\n<p>6 0 5<\/p>\n<p>7 4 8<\/p>\n<p>3 1 2<\/p>\n<p>6 5 0<\/p>\n<p>7 4 8<\/p>\n<p>3 1 2<\/p>\n<p>6 5 8<\/p>\n<p>7 4 0<\/p>\n<p>3 1 2<\/p>\n<p>6 5 8<\/p>\n<p>7 0 4<\/p>\n<p>3 1 2<\/p>\n<p>6 5 8<\/p>\n<p>0 7 4<\/p>\n<p>3 1 2<\/p>\n<p>0 5 8<\/p>\n<p>6 7 4<\/p>\n<p>0 1 2<\/p>\n<p>3 5 8<\/p>\n<p>6 7 4<\/p>\n<p>1 0 2<\/p>\n<p>3 5 8<\/p>\n<p>6 7 4<\/p>\n<p>1 5 2<\/p>\n<p>3 0 8<\/p>\n<p>6 7 4<\/p>\n<p>1 5 2<\/p>\n<p>3 8 0<\/p>\n<p>6 7 4<\/p>\n<p>1 5 2<\/p>\n<p>3 8 4<\/p>\n<p>6 7 0<\/p>\n<p>1 5 2<\/p>\n<p>3 8 4<\/p>\n<p>6 0 7<\/p>\n<p>1 5 2<\/p>\n<p>3 0 4<\/p>\n<p>6 8 7<\/p>\n<p>1 5 2<\/p>\n<p>3 4 0<\/p>\n<p>6 8 7<\/p>\n<p>Deliverables: Submit on Blackboard.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Programming java see the pdf file also need to write one page paper on it. Project 1 CSC 2053 &#8211; Platform Based Computing Grading: 150 points Due Date: Oct. 3, 2018 Part 1 &#8211; Solve Puzzle using Breadth First Search <a href=\"https:\/\/www.benedictsol.com\/blogs\/programming-java-2\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-427257","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts\/427257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/comments?post=427257"}],"version-history":[{"count":0,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts\/427257\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/media?parent=427257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/categories?post=427257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/tags?post=427257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}