corrected the mentioned issues
This commit is contained in:
+7
-5
@@ -5,12 +5,14 @@ def main():
|
||||
prog='Knight',
|
||||
description='',
|
||||
epilog='')
|
||||
parser.add_argument('-x', '--x_pose', help='Destination X between 0 and 8', type=int, required=True)
|
||||
parser.add_argument('-y', '--y_pose', help='Destination Y between 0 and 8', type=int, required=True)
|
||||
parser.add_argument('-n', '--image_name', help='Destination Y between 0 and 8', type=str, required=True)
|
||||
parser.add_argument('-ix', '--x_init', help='Initial X between 0 and 7', type=int, required=True)
|
||||
parser.add_argument('-iy', '--y_init', help='Initial Y between 0 and 7', type=int, required=True)
|
||||
parser.add_argument('-fx', '--x_des', help='Destination X between 0 and 7', type=int, required=True)
|
||||
parser.add_argument('-fy', '--y_des', help='Destination Y between 0 and 7', type=int, required=True)
|
||||
parser.add_argument('-n', '--image_name', help='the name of the output file', type=str, required=True)
|
||||
args = parser.parse_args()
|
||||
player = Player()
|
||||
player.find_paths(destination=(args.x_pose,args.y_pose))
|
||||
player = Player(pose=(args.x_init, args.y_init))
|
||||
player.find_paths(destination=(args.x_des,args.y_des))
|
||||
player.plot_paths(name=args.image_name)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+3
-3
@@ -3,8 +3,8 @@ import logging
|
||||
from graphviz import Digraph, render
|
||||
|
||||
class Player(Cell):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
def __init__(self, **kwargs) -> None:
|
||||
super().__init__(**kwargs)
|
||||
self.destination = None
|
||||
self.paths = []
|
||||
self.depth = 0
|
||||
@@ -21,7 +21,7 @@ class Player(Cell):
|
||||
def find_paths(self, destination: tuple = (0, 0)):
|
||||
self.destination = Cell(pose=destination)
|
||||
if self.destination.pose[0] < 0 or self.destination.pose[1] > 8 or self.destination.pose[0] < 0 or self.destination.pose[1] > 8:
|
||||
logging.error("Invalid destination position: it should be between 0 and 8")
|
||||
logging.error("Invalid destination position: it should be between 0 and 7")
|
||||
return
|
||||
while len(self.paths) < 1:
|
||||
self.depth += 1
|
||||
|
||||
@@ -3,4 +3,4 @@ if [ $1 == "build" ]; then
|
||||
docker build -f Dockerfile -t knight:0.0 .
|
||||
fi
|
||||
echo "Run Knight ...";
|
||||
docker run -t -v ${PWD}:/app:rw --name knight knight:0.0 knight -x $2 -y $3 -n $4
|
||||
docker run --rm -t -v ${PWD}:/app:rw --name knight knight:0.0 knight -ix $2 -iy $3 -fx $4 -fy $5 -n $6
|
||||
Reference in New Issue
Block a user