Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use First-Order-Logic (FOL) to create an AI agent that can navigate the world, a

ID: 3836820 • Letter: U

Question

Use First-Order-Logic (FOL) to create an AI agent that can navigate the world, avoiding pits, collecting gold, and shooting any and all Wampuses it sees.As an additional objective, the agent wants to make it to the top right corner of the world, after starting in the left bottom corner.
The world:The world is a 100 by 100 board of cells.A cell can contain either a pit, a wampus, or gold.All cells adjacent to a cell with a pit have breeze.All cells adjacent to a cell with a wampus have stench.A cell with gold has glitter.
The agent:
The agent shoots in the direction it's facing, killing the wampus in the next cell. Assume the agent can't shoot unless it knows 100% that there's a wampus in the next cell.
The agent perceives the following percepts: smell, breeze, and glitterAdditionally, the agent is capable of the following actions: Turn NorthTurn WestTurn SouthTurn EastForwardShootGrab
Assume the agent has infinite arrows.

The assignment is to create a FOL Knowledge Base in Prolog and use it to update the Knowledge Base, and make correct actions.

Explanation / Answer

import java.awt.*; // Uses AWT's Layout Managers
import java.awt.event.*; // Uses AWT's Event Handlers
import javax.swing.*; // Uses Swing's Container/Components

/**
* The Sudoku game.
* to unravel the quantity puzzle, each row, every column, and every of the
* 9 3×3 sub-grids shall contain all of the digits from one to nine
*/
public category Sudoku extends JFrame the sport properties
public static final int GRID_SIZE = 9; // Size of the board
public static final int SUBGRID_SIZE = 3; // Size of the sub-grid

// Name-constants for UI management (sizes, colours and fonts)
public static final int CELL_SIZE = 60; // Cell width/height in pixels
public static final int CANVAS_WIDTH = CELL_SIZE * GRID_SIZE;
public static final int CANVAS_HEIGHT = CELL_SIZE * GRID_SIZE;
// Board width/height in pixels
public static final Color OPEN_CELL_BGCOLOR = Color.YELLOW;
public static final Color OPEN_CELL_TEXT_YES = new Color(0, 255, 0); // RGB
public static final Color OPEN_CELL_TEXT_NO = Color.RED;
public static final Color CLOSED_CELL_BGCOLOR = new Color(240, 240, 240); // RGB
public static final Color CLOSED_CELL_TEXT = Color.BLACK;
public static final Font FONT_NUMBERS = new Font("Monospaced", Font.BOLD, 20);

// the sport board composes of 9x9 JTextFields,
// every containing String "1" to "9", or empty String
personal JTextField[][] tfCells = new JTextField[GRID_SIZE][GRID_SIZE];

// Puzzle to be resolved and also the mask (which is accustomed management the
// issue level).
// Hardcoded here. further credit for automatic puzzle generation
// with varied issue levels.
personal int[][] puzzle =
,
,
,
,
,
,
,
,
};
// For testing, open solely a pair of cells.
personal boolean[][] masks =
,
,
,
,
,
,
,
,
};

/**
* creator to setup the sport and also the UI parts
*/
public Sudoku() instrumentality cp = getContentPane();
cp.setLayout(new GridLayout(GRID_SIZE, GRID_SIZE)); // 9x9 GridLayout

// allot a typical auditor because the ActionEvent auditor for all the
// JTextFields
// ... [TODO 3] (Later) ....

// Construct 9x9 JTextFields and augment the content-pane
for (int row = 0; row < GRID_SIZE; ++row) mountain pass = 0; mountain pass < GRID_SIZE; ++col) {
tfCells[row][col] = new JTextField(); // allot part of array
cp.add(tfCells[row][col]); // ContentPane adds JTextField
if (masks[row][col]) {
tfCells[row][col].setText(""); // set to empty string
tfCells[row][col].setEditable(true);
tfCells[row][col].setBackground(OPEN_CELL_BGCOLOR);

// Add ActionEvent auditor to method the input
// ... [TODO 4] (Later) ...
} else guide on a way to run the creator
.......
}

// outline the auditor Inner category
// ... [TODO 2] (Later) ...
}
3. Event Handling
Next, we have a tendency to shall program the event handling.
We shall use a typical instance of a Named Inner category (called InputListener) because the ActionEvent auditor for "all" the editable JTextFields. Hence, within the actionPerformed(), we want to spot the actual JTextField (in terms of row and col) that trigger the event. you'll use the ActionEvent.getSource() methodology to retrieve the supply object that has dismissed the event and compare the article with all the 9×9 JTextFields.
Place the inner category at [TODO 2].
// [TODO 2]
// Inner category to be used as ActionEvent auditor for ALL JTextFields
personal category InputListener implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
// All the 9*9 JTextFileds invoke this handler. we want to work out
// that JTextField (which row and column) is that the supply for this invocation.
int rowSelected = -1;
int colSelected = -1;

// Get the supply object that dismissed the event
JTextField supply = (JTextField)e.getSource();
// Scan JTextFileds for all rows and columns, and match with the supply object
Boolean found = false;
for (int row = 0; row < GRID_SIZE && !found; ++row) {
for (int mountain pass = 0; mountain pass < GRID_SIZE && !found; ++col)
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote