Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

Ict221 Java Programming- Artificial Intelligence Assessment Answers

  62 Download     📄   5 Pages / 1177 Words

As soon as you start work on your game project, you need to create a Git repository to track all your changes.  You will use BitBucket.org to keep a master copy of your game project, and it is your BitBucket.org Git repository that you will use to submit your game project for marking.  After you have created your Eclipse project, follow these steps to set everything up:

  1. Go to organd create a free account ('Get started for free').  Then create a 'private' Git repository in that account (this is the URL that you will submit to Blackboard for marking).

  2. Then, in Eclipse, right-click on your whole project and use Team / Share Project / Git / Next / Createto create a new local repository.
  3. Commit all your project source files into your local Git repository: (Team / Commit).  You should add all the *.java files, the .project and .classpath files, and ALLother image files or data files that are needed to compile and run your game.  Do NOT add binary output files such as *.class files.  Enter a meaningful commit message (e.g. "First version of game"), and press Commit.
  4. Push your project up into your BitBucket repository: (Team / Remote / Push, and then paste in the URI of your BitBucket repository from Step 1).  You will need to tell Eclipse your BitBucket.org password.   Set the 'Source Ref'to 'Master[branch]' and press the 'Add spec' button, then press Finish.
  5. Go back to BitBucket.org and refresh your repository there, and you should see that some files have been created.  You should create a README file too, with a couple of sentences to explain your project.
  6. Important!Finally, click the 'Send invitation' button and invite your tutor (Mark [email protected], or Amol [email protected]) to be able to share your repository (READ permission will suffice).  Then invite the Course Coordinator ([email protected]) as well.  If you don't do this, we will not be able to mark your assignment.

Now you have joined the world of professional software developers, who use version control to manage their source code safely.  Every day after you have made some changes to your game (and tested them of course!), you should use the Team / Commit / Commit and Push command in Eclipse to save a record of your changes into your local repository, and also push a copy of those changes up to your BitBucket repository, where they will be safely backed up, and where we will be able to access them for marking.  

You can even use this feature to keep your home and University computers synchronised with the latest version of your game, if you:

  • do a 'Team / Commit / Commit and Push' after you make changes.
  • do a 'Team / Pull'each time you arrive at a new computer, to pull the latest version of your game down to this computer.

Start by developing a simple first version of the 2D board in your core game engine.  You could look at the TicTacToe game for an example of how to do this.  

  1. Think carefully about whether each cell in your board should be a primitive value (like a boolean, an integer, or an enumerated value), or should it be an object?  Using objects is more flexible, since it allows you to use Java subtyping to make different cells have different behaviour.  But many of the games suggested above do not require the cells to have fancy behaviour, so a primitive value might be sufficient for your game.
  2. If you have a multi-player game, think carefully about whether the players should just be numbered, or do you want to be able to switch between computer players and human players?  If the latter, then a nice way of doing this is to have a Playersuperclass (or interface), with one subclass for a human player (which prompts the user and reads their response), and another subclass for a computer player (which implements a simple playing strategy such as choosing a random move).
  3. To get high marks, your engine needs to include several classes, with some association/composition relationships between them, and if possible, some inheritance relationships.  Think about where you can best use these Java features.

Here are two suggestions for how you can develop your game engine in small iterations, so that you check that each new feature is working correctly.  I suggest that each iteration should take at most 10-30 minutes, so that you are doing lots of small iterations, adding one feature at a time.

  1. Use TDD to develop your unit tests and game engine at the same time.

Write a simple textual user interface first, and use that to test the game engine manually each time you add a new feature.  (Hint: to make sure you have not broken any old features, you can also rerun previous tests by recording the input in a text file, and redirecting that file into your program using input redirection.  Eg. java -jar game.jar <in.txt >out.txt).

Answer:

Eight Queens problem is one of the famous brain exercise problem. In this, 8 queens are placed on an 8 x 8 chessboard in such a way that no particular queen can attack any other queen on the chessboard, i.e. all the queens are safe. A queen can attack any other piece on the chessboard which is horizontally, vertically or diagonally aligned with the queen. Due to such different available moves of the queen, it is difficult to place 8 queens in non-attacking positions.

This problem is vastly used to solve different artificial intelligence problems. In an 8 x 8 chessboard, there are a total of 4,426,165,368 arrangements to place 8 queens on the board (64C8). In these more than 4 billion arrangements, only 92 arrangements are the solution to the 8 queen problem.

In the game developed, every row is associated with a number from 0 – 7 and every column is associated with a letter a – h. Player is asked to select any available square from the chessboard to place the queen over it. If it is available then the queen is placed on it and the corresponding row, column, and diagonals are marked as attack to not allow the player to place any new queen over it. Player is asked to place the queens again and again till the board is either fully attack or the queens are placed.

If all 8 queens are placed correctly, then the player wins else he loses.

These are the sample GUI Sketch created in Microsoft PowerPoint presentation.

Reflection

The game developed lets the player play the 8 queen game while placing the queens at different squares. The main difficulty in the game is to detect and store what all positions are invalid to place the queen and the conditions at which the player loses game.

If I were to do it again, I would add some feature in the game to let the player also remove the queen from any position if he feels like losing a game and can backtrack the moves.

Copyright © 2009-2023 UrgentHomework.com, All right reserved.