Mistake in the node class given in project2 spec

3 views
Skip to first unread message

Nithin Uppalapati

unread,
Feb 27, 2014, 4:07:28 PM2/27/14
to cs...@googlegroups.com
class Node:
  end   = "."
  start = "!"

  def __init__(self,g,id,name,stop=False,start=False):
      self.id = id
      self.graph = g          # where do i live?
      self.name = name        # what is my name?
      self.description = ""   # tell me about myself
      self.stop = stop        # am i a stop node?
      self.start = start      # am i a start node?
      self.out = []           # where do i connect to

  def also(self,txt):
      "adds text to description"
      sep = "\n" if self.description else ""
      self.description += sep + txt

  def __repr__(self):
      return "N( :id " + str(self.id) + \
             "\n   :name " + self.name + \
             "\n   :about '" + self.description + "'" + \
             "\n   :out " + str(self.out) + ") "
I guess it has to be self.end=stop

Matthew McCoy

unread,
Feb 27, 2014, 4:29:28 PM2/27/14
to cs...@googlegroups.com
I believe it is suppose to be a boolean variable. If self.stop is True then that node is the stop node. If it is false then it is not the stop node.



--
You received this message because you are subscribed to the Google Groups "cs310" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cs310+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Daniel Luplow

unread,
Feb 27, 2014, 4:30:02 PM2/27/14
to cs...@googlegroups.com

Can you specify why? My python IDE checks for shadowing of built in types, self.stop = stop should work. On node construction it is forced to "False", and then after you isolate the end node with your matrix you should explicitly set it as an end node "True" inside the node and set that node to self.stop inside of graph. Also, are you using python 2.7? Loudify Ubuntu like what we set up in class has python 3.3, 2.7 and others installed side by side, though I think 2.7 is supposed to be the default terminal python.

Not saying you're wrong, just asking you to clarify I suppose.

--

Nithin Uppalapati

unread,
Feb 27, 2014, 4:33:53 PM2/27/14
to cs...@googlegroups.com
It has to be

self.end = stop

because in the graph class, when we are adding nodes into the graph,we are using:

tmp.end   = Node.end   in name

Matthew McCoy

unread,
Feb 27, 2014, 4:39:29 PM2/27/14
to cs...@googlegroups.com

I am using python 2.7 and when loading the graph I found my end node and set it to True for that node. Then when playing the game I used it to determine when to stop playing the game. By making sure my current node wasn't the end node.

Matthew McCoy

unread,
Feb 27, 2014, 4:51:41 PM2/27/14
to cs...@googlegroups.com

"Node.end in name" returns a boolean value. Because it tests if a "." Is in the node name.

Daniel Luplow

unread,
Feb 27, 2014, 5:01:45 PM2/27/14
to cs...@googlegroups.com
That raises another very interesting question that Dr. Menzies has yet to explicitly answer us on. Do we explicitly declare start and end nodes in the STAGETEXT by placing ! in front of a start node's name and '.' in front of an end node's name or not. 

Somebody correct me if I'm wrong 
`tmp.start = Node.start in name` appears to search for a "!" in the name for start or `tmp.end = Node.end in name` searches for a "." in the name for a stop node on creation of the node. 

The problem is the constructor explicitly overwrites START with False and STOP with False on creation, so it will never find a start node, and if it finds an end node it is only because of this typo that you found which prevents end from being overwritten with False on the creation of a Node.

This is interesting, removing the explicit settings of start and stop to False, the code is set up to handle ! and '.' start and stop nodes. Cheyenne has implied that you do not need to do this (possibly why they are included by set to false on Node's initiation, so that it doesn't work unless the student enables it?) because the watchdogs for islands ensure only one end node, which we can identify (and are doing anyways) so we might as well just use this to assign the end, and the start is identified by an empty column as noted in the watchdogs, which we also have to do anyways.

In my opinion it is strange that Menzies would include this, disable it, and then not elaborate more on it in the project 2 directions. Which leads to the feeling I get about this assignment serving other purposes. Firstly, as long as we defend our choices with the written portion of the assignment some of the inner workings of our program are left to our own discretion, and secondly, the lack of help has simply been intentional so as to get us to use the googlegroups to talk to one another in preparation for the next project.


Daniel Luplow

unread,
Feb 27, 2014, 5:08:46 PM2/27/14
to cs...@googlegroups.com
Forgive me, Node.end is different from Node().end in regards to the fact that it's reaching inside the constructor to get the variables without initializing the Node first, so searching for ! and . in the name should work as it is written. Why not just 
        tmp.start = "!" in name
        tmp.end = "." in name

though?
Why would you declare these False in the init, when you could just set them to false from the start, and then store True there if and when necessary and use a string literal instead of a variable reference as the search parameter?

Benjamin Waechter

unread,
Feb 28, 2014, 12:27:05 AM2/28/14
to cs...@googlegroups.com

Jumping in a little late on this issue of the end node issue.  If you change the line of code that reads

tmp.end = Node.end in name

To be:

tmp.end = Node.end in name

It fixed the stop node recognition issue,  it was simply a type-o. I could not tell if you all already reached this solution and figured I would throw this out there; as this caused me a few hours of head aches when debugging

Reply all
Reply to author
Forward
0 new messages