Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code in java Part 2 (6 points) Write a program that attempts the Kright' Tour by maving a bright areund a chesboard. Yeur pregram sheuld

code in java

image text in transcribed

Part 2 (6 points) Write a program that attempts the Kright' Tour by maving a bright areund a chesboard. Yeur pregram sheuld shew the move number en eoah square wheve the knight lended. First, lat's discuss how to move a knight around a chesiboard. The board is represerted by an 88 two-dimarsional amoy af integers coled board. Each iquare is initia toded to reso. Eoch of the eight posslble moves is described by its horizontol jeft or right and verted (up or down) components. If a keright b at position |row. cokumn]. then montig increques tha ealumn and moving upderreques the oalumn. We con use two 1-Cimensiond amoys. named horizontal and vertical. to represent eoch of the eight moves: horizental |change ta rormi) \begin{tabular}{|l|l|l|l|l|l|l|l|} \hline 2 & 1 & 1 & 2 & 2 & 1 & 1 & 2 \\ \hline \end{tabular} vertical |chonge to column) \begin{tabular}{|l|l|l|l|l|l|l|l|} \hline1 & 2 & 2 & 1 & 1 & 2 & 2 & 1 \\ \hline \end{tabular} * the variables currentRou and currentcol indicote the knight's cument postion. then to make a meve of typee noveType, your progrem can use statements such as: nextColunn = currentColun + horizontal moveType ] nextfow = currentfow + vertical [ noveType I! Your program sheuld use an eccumblator to beep trock af how many moves the tour wos cble to moke. Recard the latest count in each board square the kight maves to. Bafere making a meve te a new square, be sure ta check it 1. the knight has olvecdy larded that squave, and 2. the square is actuoly on the bocrd Semple Run fer Part 2 In the sample run, the keright storted at postion |a. of and the progrom was orhr able to visit 42 acuores. The final square reoched was [0. 3]. from this square. there is no emptr qquare to move to

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions