Python I need the pseudocode of the following code: import pygame, sys from pyga
ID: 3854677 • Letter: P
Question
Python
I need the pseudocode of the following code:
import pygame, sys from pygame·locals import * import numpy as np def inRangeAndEmpty(posx,posy,board,N): return (posx = 0 and posy = 0 and board [pos [posy]-0) def getAccessibility(x,y,moves,board,N): accessibility -0 for i in range(8): if inRangeAndEmpty(x+moves i][Ø],y+moves [i][1],board,N): accessibility 1 return accessibility def getNextMoves (move,moves,board,N): positionx move [0] positionymove [1] accessibility-8 fori in range(8): newx - positionx + moves [i][0] newypositiony + moves [i][1] newacc = getAccessibility(newx , newy , moves , board , N) if inRangeAndEmpty(newx, newy, board,N) and newaccExplanation / Answer
Pseudocode
Ask user to enter N
Ask user to enter positionx
Ask user to enter positiony
assign positionx value x
assign positiony value y
set movenumber as 2
set list of values for both move and moves
Initialise board value
set initial borad value is 1
create an empty list of L
for i in range(N*N)
Find the axis to apply wansdorff
Find axis to the next move of it till N number of times.
Check whether the solution is ok
if sol is true then
Assign axis to L and print the result of board
else
reset all values of moves, board, positionx, positiony, L and set movenumber as 2.
Do the same thing again for each value till an N number of times reached
and then check finded solution is ok
if SO is true then
Assign axis to L and print the result of board
If there is no axis point has found then
print didn't find the solution.
In order to find axis to the next move,
assgin MOVE of 0 index value to positionx
assgin MOVE of 1 index value to positiony
set accessibility as 8
for i in range(accessibility)
set addiotion of 2 values like positionx+moves[i][0] to newx
set addiotion of 2 values like positiony+moves[i][1] to newy
Find the accessibility for these points and assign it to newacc
if these points are in rang and newacc is less than accessibility
set new points are move points and return newacc
In order to check the points are in range,
check posx is less than N and posx is greater than or equal to zero and posy is less than N and posy is greater than or equal to zero and borad value is equal to zero.
If so
return true
else
return false
In order to check accessibility of the points,
initialize accessibility value as zero
for i in range(8)
if these points are in range and is not empty
add accessibility value by 1
return accessibility value.
if N <= 32 and sol is true
Print the result on window with graphic effects
To display the result on window
load knight image
initialize game
set window size
set caption
load and set background image
set font size
while true
set the background
check events on window
if event is quit
quit the game and exit
elseif event is key down
if event key is 27
quit the game and exit
display the result on window
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.