Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98083
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-11-01 21:30 -0800 |
| Message-ID | <24e4a4ca-59d1-433e-a0ed-fa04fc23041d@googlegroups.com> (permalink) |
| Subject | Problem in implementing Romania Map using Paython Script |
| From | amnaee@gmail.com |
Dear all;
I want to code algorithm in Python for driving from Arad to Bucharest as quickly as possible.
I formulated the problem in python as following :
1- States : Various cities.
2- Actions : Drive distances between different cities.
3- Goal : To be in Bucharest.
class Problem:
def __init__(self, initial, goal=None):
self.initial = initial
self.goal = goal
def goalTest(self, state):
return state == self.goal
But the problem now is with Roaming and Node classifications :
class RoamingProblem(Problem):
def successors(self, state):
Q1 : How I can complete the class RoamingProblem (Problem) and include action costs.
I think its related in some how in using a new city map ????...
And how I can return the cost next state ????...
list of tuples [(action1,[(action1, successor-state1, cost1, action2, successor-state2, cost2 ...)]
Q2 : For the class node
class Node:
def __init__(self, state, parent=None, action=None, pathCost=0):
self.state = state
self.parent = parent
self.action = action
self.pathCost = pathCost
update(state,parent,action,pathcost,depth)
def expand(self, problem):
return [Node(next,self,action,problem,....].
THE last line How I can return : list of Node objects, one for each successor state, parent of the created nodes is self ????....
I need a help in completing the Class Roaming problem using Euclidean function , Completing the Class Node .....
And def treesearch and graph search problem ?????
Waiting for reply ????
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Problem in implementing Romania Map using Paython Script amnaee@gmail.com - 2015-11-01 21:30 -0800 Re: Problem in implementing Romania Map using Paython Script Ben Finney <ben+python@benfinney.id.au> - 2015-11-02 16:45 +1100 Re: Problem in implementing Romania Map using Paython Script Christian Gollwitzer <auriocus@gmx.de> - 2015-11-02 07:45 +0100 Re: Problem in implementing Romania Map using Paython Script Terry Reedy <tjreedy@udel.edu> - 2015-11-02 06:08 -0500
csiph-web