I'm trying to make the input maze of Astar algorithm(alogorithm to find the shortest path between start and destination and there can be some blockages within the maze, which takes input a maze representing blockages only, as shown below). From the GUI using the Click1 command in each button, I intend to get an output like this(where I inserted a blockage at [3][2]). 1 represents blockage which is to avoided to find the path from start to end. [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] but I get a output as following,I can't understand why it's blocking the same column of each and every row [[0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0]] I created the maze in the init(): of class App() using this: def __init__(self, master,dimension,indexes):    self.maze=[[0]*self.dimension]*self.dimension  this entire thing is within a class App(): for creating the grid of buttons, and storing their reference         self.gid = []         for i in range(self.dimension):             row = []             Grid.rowconfigure(self.frame1, i + 1, weight=3)             for j in range(self.dimension):                 Grid.columnconfigure(self.frame1, j + 1, weight=3)                 btn=Button(self.frame1,command=lambda i=i, j=j: self.Click1(i, j))                 btn.grid(sticky=N+S+E+W,padx=2,pady=2,ipadx=1,ipady=1)                 row.append(btn)                 row[-1].grid(row=i + 1, column=j+1)             self.gid.append(row)    the Click1 method/Command that also within this class:     def Click1(self, i, j):         self.indxes.append((i,j))         if len(self.indxes)==1:             self.gid[i][j][&quot;bg&quot;]=&quot;blue&quot; #indicates start         elif len(self.indxes)==2:             self.gid[i][j][&quot;bg&quot;]=&quot;green&quot; #indicates destinations         else:             self.gid[i][j][&quot;bg&quot;] = &quot;black&quot;             self.maze[i][j] = 1  #how I insert blockage within the maze
410
I needed to create a list of lists in Python, so I typed the following: my_list = [[1] * 4] * 3  The list looked like this: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]    Then I changed one of the innermost values: my_list[0][0] = 5  Now my list looks like this: [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]]    which is not what I wanted or expected. Can someone please explain what's going on, and how to get around it?
70957
I have the following TikZ code which draws a grid and shows the coordinates.  To display the coordinates I am using the loop foreach.  \documentclass[12pt]{article} \usepackage{tikz}  \begin{document} \begin{tikzpicture} \draw[help lines,step=.2] (-2,-2) grid (7,4); \draw[help lines,line width=.6pt,step=1] (-2,-2) grid (7,4); \foreach \x in {-2,-1,0,1,2,3,4,5,6,7}  \node[anchor=north] at (\x,-2) {\x}; \foreach \y in {-2,-1,0,1,2,3,4}  \node[anchor=east] at (-2,\y) {\y}; \end{tikzpicture} \end{document}   Is there a way do simplify the code in this way that I have a key like show coordinates (maybe step coordinates/.initial=step ):  \draw[help lines,step=.2,show coordinates=true] (-2,-2) grid (7,4);   Or a modification of the command grid like  \draw[help lines,step=.5] (-2,-2) gridwithcoordinates (7,4);     By using pstricks it is very simple with the command \psgrid  \documentclass[12pt]{article} \usepackage{pstricks}  \begin{document} \begin{pspicture}(-2,-2)(7,4) \psgrid \end{pspicture} \end{document}   Bonus: How can I set a larger line width for the help lines at the integer coordinates (see picture above)?  (I don't know the correct words ;-) )
60777
If I start building my scene from scratch using GUI (read: clicking buttons), will I be able to automatically obtain the equivalent Python code that achieves the same end results?  This is a really cool feature that sounds definitely doable, but not sure how to do it.
38568
Just wanted to share a nice problem.I have given my method below.More answers are welcome.  Consider a rectangular integral grid of size $m*n$.A person has to travel from one end say $(0,0)$ to the diagonally opposite end $(m,n)$.He moves one step at a time towards the east or towards the north(that is,never moves towards the west or south at any time).How many distinct paths exist from the point A to the point C ?
111183
What is the purpose of the colon before a block in Python?  Example:  if n == 0:     print "The end"
119693
I'm trying to create a fine flowchart that is a bit complicated. Therefore I need a block for a predefined process and a connector block as well as a data block. Can someone help me? In comment is what I'd like to see in my code to keep my code nicely arranged. The rest of the code is a simple example for the Tikz site.  \documentclass{article}  \usepackage[latin1]{inputenc} \usepackage{tikz} \usetikzlibrary{shapes,arrows} \begin{document} \pagestyle{empty}   % Define block styles \tikzstyle{decision} = [diamond, draw, fill=blue!20,      text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt] \tikzstyle{block} = [rectangle, draw, fill=blue!20,      text width=5em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, -latex'] \tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,     minimum height=2em]  %\tikzstyle{subroutine} = [draw,rectangle split, rectangle split         horizontal,rectangle split parts=3,minimum height=1cm]  %\tikzstyle{connector} = [draw,circle,...] %\tikzstyle{data} = [draw, trapezium, ...]  \begin{tikzpicture}[node distance = 2cm, auto]     % Place nodes     \node [block] (init) {initialize model};     \node [cloud, left of=init] (expert) {expert};     \node [cloud, right of=init] (system) {system};     \node [block, below of=init] (identify) {identify candidate models};     \node [block, below of=identify] (evaluate) {evaluate candidate models};     \node [block, left of=evaluate, node distance=3cm] (update) {update     model};     \node [decision, below of=evaluate] (decide) {is best candidate     better?};     \node [block, below of=decide, node distance=3cm] (stop) {stop};     % Draw edges     \path [line] (init) -- (identify);     \path [line] (identify) -- (evaluate);     \path [line] (evaluate) -- (decide);     \path [line] (decide) -| node [near start] {yes} (update);     \path [line] (update) |- (identify);     \path [line] (decide) -- node {no}(stop);     \path [line,dashed] (expert) -- (init);     \path [line,dashed] (system) -- (init);     \path [line,dashed] (system) |- (evaluate); \end{tikzpicture}   \end{document}
90595
I have created some TikZ code to produce the diagram below (slightly simplified). This is my first real shot at TikZ and its taken me about 8 hours now to get this far. But I don't really begrudge the time, time spent learning is time well spent.  It is loosely based on .  I would like to have a different (variable) number of nodes in each layer, and would like to maintain the connection.  My current idea was to have a list of lists like {{1..3},{1..5},{1..7},{1..4},{1..3}} then I guesss i could use a nested for-each off the index. But that has 2 problems: I would lose my layer number, which I could get around by using count. Secondly, more majorly, I don't seen a good way of knowing how big the next layer is (to make the connections).     \documentclass{article} \usepackage{mathptmx} \usepackage{tikz} \usetikzlibrary{arrows} \usetikzlibrary{calc} \begin{document}   \def\layersep{3.5cm} \def\topnum{5} %\font\nullfont=cmr10 \begin{tikzpicture}[shorten &gt;=1pt,-&gt;,draw=black!50, node distance=\layersep]     \tikzstyle{neuron}=[circle,draw,fill=white!25,minimum size=25pt,inner sep=0pt]     \tikzstyle{bias neuron}=[neuron,dashed]       \foreach \y in {2,...,4}                 \foreach \x in {1,...,5}             \path   node[neuron] (L_\y_\x) at (\x cm,\y*\layersep) {$\sigma(\cdot)$};   %      \foreach  \x in {1,...,5}             \path  node[neuron] (L_1_\x) at (\x cm,1*\layersep) {$x_\x$};      \foreach  \x in {1,...,5}             \path  node[neuron] (L_5_\x) at (\x cm,5*\layersep) {$s_{m}(\cdot)$};       %Add Biases     \foreach \y in {1,...,4}     {         \path node[bias neuron] (B_\y) at (6 cm, 0.55*\layersep+\y*\layersep) {1};         \pgfmathtruncatemacro\nextlayer{\y+1}         \foreach \dest in {1,...,5}             \path (B_\y) edge[dashed] (L_\nextlayer_\dest.south);     }       % Connect every node in the input layer with every node in the     % hidden layer.     \foreach \layer in {1,...,4}         \pgfmathtruncatemacro\nextlayer{\layer+1}         \foreach \source in {1,...,5}             \foreach \dest in {1,...,5}                 \path (L_\layer_\source) edge (L_\nextlayer_\dest);   \end{tikzpicture} \end{document}
53161
I'm trying to do something similar to this epsilon-delta graph I've found.  Specifically, I'd like to copy the placements and arrows, like the L+e and L-e coming out of L. Same thing with the x0 + d and x0-d coming out of the x0. Can someone help me with this? This is what I have so far.    \begin{tikzpicture} \begin{axis}[ ,         legend pos=north east,         axis x line=middle,         axis y line=middle,         x tick label style={/pgf/number format/fixed,                             /pgf/number format/fixed zerofill,                             /pgf/number format/precision=1},         y tick label style={/pgf/number format/fixed,                             /pgf/number format/fixed zerofill,                             /pgf/number format/precision=1},         grid = major,         width=8cm,           height=6cm,         grid style={dashed, gray!30},         xmin=0   ,     % start the diagram at this x-coordinate         xmax= 4,    % end   the diagram at this x-coordinate         ymin= 0,     % start the diagram at this y-coordinate         ymax= 11,   % end   the diagram at this y-coordinate %axis background/.style={fill=white},         xlabel=$x$,         ylabel=$f(x)$,         tick align=outside,         enlargelimits=false] % plot the stirling-formulae %\addplot[domain=0:200, red, ultra thick,samples=100] {K/(1 +    ((K-X0)/X0) * exp(r*x))    }; \addplot[domain=0:200, red, ultra thick,samples=100] {3*x-1 };  \addplot[line width=1pt, dashed, mark=none, black] coordinates {(0,8) (3,8)}; \addplot[line width=1pt, dashed, mark=none, black] coordinates {(3,0) (3,8)}; \addplot[line width=1pt, dashed, mark=none, blue] coordinates {(3.33,0) (3.333,9)}; \addplot[line width=1pt, dashed, mark=none, blue] coordinates {(2.666,7) (2.666,0)}; \addplot[line width=1pt, dashed, mark=none, blue] coordinates {(2.666,7) (0,7)}; \addplot[line width=1pt, solid, mark=none, blue] coordinates {(3.333,9) (0,9)}; \addplot[holdot] coordinates{(60,8.66)};  % 1\addlegendentry{$f(x) = 10 \sin (x)$}  \end{axis}   \end{tikzpicture}   which gives
96097
I am trying to implement this Block Diagram:   Forget about the math, I can do it. I just want to implement the diagram. I used the example ; it is nice, but whenever I remove the "measurement" block, the feedback path cannot be obtained unless directly (-180 deg). Also, I am still unable to get more than one box on top of each other.    MWE:  \documentclass{article}  \usepackage{tikz} \usetikzlibrary{shapes,arrows} \begin{document}  \tikzstyle{block} = [draw, fill=white, rectangle,      minimum height=3em, minimum width=6em] \tikzstyle{sum} = [draw, fill=white, circle, node distance=1cm] \tikzstyle{input} = [coordinate] \tikzstyle{output} = [coordinate] \tikzstyle{pinstyle} = [pin edge={to-,thin,black}]  \begin{tikzpicture}[auto, node distance=2cm,&gt;=latex']      \node [input, name=input] {};     \node [sum, right of=input] (sum) {};     \node [block, right of=sum] (controller) {Controller};     \node [block, right of=controller, pin={[pinstyle]above:D},             node distance=3cm] (system) {System};      \draw [-&gt;] (controller) -- node[name=u] {$u$} (system);     \node [output, right of=system] (output) {};     \node [block, below of=u] (measurements) {Measurements};      \draw [draw,-&gt;] (input) -- node {$r$} (sum);     \draw [-&gt;] (sum) -- node {$e$} (controller);     \draw [-&gt;] (system) -- node [name=y] {$y$}(output);     \draw [-&gt;] (y) |- (measurements);     \draw [-&gt;] (measurements) -| node[pos=0.99] {$-$}          node [near end] {$y_m$} (sum); \end{tikzpicture} \end{document}
10391
It is easy to produce a path between two nodes consisting of a single horizontal and a single vertical line (from the manual):  \begin{tikzpicture}   \draw (0,0) node(a) [draw] {A}  (1,1) node(b) [draw] {B};   \draw (a.north) |- (b.west);   \draw[color=red] (a.east) -| (2,1.5) -| (b.north); \end{tikzpicture}   However, what if I wanted the same short syntax to produce a path between (a) and (b) using a horizontal line, a vertical line, and a second horizontal line. It isn't to difficult to calculate the intermediate points, but how could the following syntax be defined?  \begin{tikzpicture}   \draw (0,0) node(a) [draw] {A}  (3,1) node(b) [draw] {B};   \draw (a.east) -|- (b.west); \end{tikzpicture}
58547
I plan on building a game where enemies are randomly generated throughout the game. I plan on using an empty to run a Python script where it will add a predefined object at a given position (using random.randint to place them randomly around the map).  Is there a specific Python command where I can say something like "Create this object at this given x,y,z position"?  If so, can you please tell me what it is and how to use it?  Also, what is the difference between a Module and a Script in the Python controller?  Thanks so much for your help!  Alternatively, is there a Python function that sets an object's X,Y,Z coordinates?  If so, the empty can jump around randomly dropping enemies off at it's position.
52368
I'm looking for a good algorithms for the following problem: Given a 3D grid of voxels (which may be either empty or filled), if I pick two non-adjacent voxels, I want to know if they are connected to each other by other voxels.  For example (to illustrate the situation in 2D), where # is a filled square:    1 2 3 a # # # b # # c # # #   If I pick a3 and c3, I want to determine as quickly as possible if they they are connected; if there is a path between a3 and c3 through filled pixels. (The real situation is in a 3D voxel grid, of course.)  I've looked at floodfill algorithms and path finding algorithms, but I'm not sure which to choose. Both do unneccesary work: Flood fill tries to fill all voxels, but this is not needed. Path-finding algorithms are usually concerned with finding the shortest path, which is also not necessary. I only need to know if there is a path.  What algorithm should I be using?  Edit: based on the comments, I think should add the following: the content of the voxels are not known in advance, and also, the algorithm is needed to detect if removal (emptying) of a voxel would cause the group of voxels to break into two or more smaller groups.
100133
Please don't mark this as a duplicate of my previous question which was asked anonymously. this is a reattempt because i cannot edit the first attempt.  What I have so far is:  - randomly generated tile set with items on SOME tiles - one creature spawner that spawns up to 5 creatures which can be controlled by the player - the ability for creatures to pick up items and bring them back to the spawn and store them for later use  What I am noticing is when i launch the game, it doesnt always show all the sprites. Sometimes the spawner is missing, or the creatures, or the GUI. ANd when things DO appear, if i tell the creatures to pick up anything, other items on the ground randomly appear and disappear. even the spawn sometimes disappears! what I do notice is that when i have multiple creatures, some will disappear when crossing invisible lines but not all of them. i forced two creatures to go east at the same speed and time, and one vanished and the other didnt.  If you have any ideas as to what might be causing this, please let me know. if you have any questions, i'll try to edit to appease you.  thanks for reading!  I have my draw method like this:  GraphicsDevice.Clear(Color.CornflowerBlue);  // TODO: Add your drawing code here  spriteBatch.Begin(SpriteSortMode.BackToFront,           null, null, null, null, null,           camera.GetTransformation());            worldEntity.Draw(spriteBatch);  guiManager.DrawGUI(spriteBatch);  spriteBatch.End();  base.Draw(gameTime);   for the world entity...  its draw method systematically goes through each tile in the world and calls its draw method. the tile draws itself using  Vector2 topLeftOfSprite = new Vector2(this.X, this.Y); Color tintColor = Color.White; spriteBatch.Draw(tileTexture, topLeftOfSprite, tintColor);   and then proceeds to call the draw method of any items on it.  creatures and items have very similar draw methods.  the gui also draws itself in a similar fashion.  what i DO notice is that ive NEVER seen ground tiles vanish, only the items on them or creatures in the world. Could it be their Z isn't set appropriately?
2921
I am in the process of developing a plugin for QGIS using Python. Note that this is my first plugin, so the query could be quite basic...   I have used  to create the basic plugin, and (quite surprisingly found it easy) created the plugin files.   I am stuck at a very basic concept. Previously, while using Python IDLE, using   QtCore.QObject.connect(self.Input, QtCore.SIGNAL("clicked()"), self.OpenBrowse)   to signal a click and writing a function OpenBrowse      def OpenBrowse(self):         self.Input_TB.setText(filename1)   I was able to open the Windows File Browse window on click and set the File location to an adjoining text box.   How do I do this while developing the plugin in the Python file that is created by Plugin Builder.? I am very confused about where should the code be written? Because if I place the 'clicked()' actions, etc. in the Python file generated from the UI file, it is not recognizing the variables as they are not global (obviously).   I am using QGIS 2.4, on a Windows 32-bit system.
96687
I want to draw a cuboid in another transparent cuboid with TikZ. Therefore I've created a \newcommand to draw a cuboid.  \documentclass[11pt, halfparskip]{scrartcl} \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{tikz}  \begin{document} \newcommand{\cuboid}[7]{     % bottom     \draw[#7] (#1, #2, #3) -- ++(#4, 0, 0) -- ++(0, 0, #6) -- ++(-#4, 0, 0) -- cycle;     % back     \draw[#7] (#1, #2, #3) -- ++(#4, 0, 0) -- ++(0, #5, 0) -- ++(-#4, 0, 0) -- cycle;     % left     \draw[#7] (#1, #2, #3) -- ++(0, 0, #6) -- ++(0, #5, 0) -- ++(0, 0, -#6) -- cycle;     % right     \draw[#7] (#1+#4, #2, #3) -- ++(0, 0, #6) -- ++(0, #5, 0) -- ++(0, 0, -#6) -- cycle;     % front     \draw[#7] (#1, #2, #3+#6) -- ++(#4, 0, 0) -- ++(0, #5, 0) -- ++(-#4, 0, 0) -- cycle;     % top     \draw[#7] (#1, #2+#5, #3) -- ++(#4, 0, 0) -- ++(0, 0, #6) -- ++(-#4, 0, 0) -- cycle; } \begin{tikzpicture}   \tikzstyle{bottomfill} = [thick, fill=lightgray, fill opacity=.5] \tikzstyle{camerafill} = [thick, fill=blue!20]  \cuboid{0}{0}{0}{4}{4}{4}{bottomfill} \cuboid{1}{1}{1}{1}{1}{1}{camerafill}  \draw[-&gt;, thick] (2, 1.5, 1.5) -- ++(4, 0, 0);  \end{tikzpicture} \end{document}   But the result looks strange (The inner cuboid seems to be outside the transparent cuboid; compare the cuboid and and the arrow of the second image)    The result looks right if I'm adding the planes in the right z-order (but that's exhausting)  \documentclass[11pt, halfparskip]{scrartcl} \usepackage{ucs} \usepackage[utf8x]{inputenc} \usepackage{tikz}  \begin{document} \begin{tikzpicture} \tikzstyle{bottomfill} = [thick, fill=lightgray, fill opacity=.5] \tikzstyle{camerafill} = [thick, fill=blue!20]  % 1 bottom \draw[bottomfill] (0, 0, 0) -- ++(4, 0, 0) -- ++(0, 0, 4) -- ++(-4, 0, 0) -- cycle; % 1 back \draw[bottomfill] (0, 0, 0) -- ++(4, 0, 0) -- ++(0, 4, 0) -- ++(-4, 0, 0) -- cycle; % 1 left \draw[bottomfill] (0, 0, 0) -- ++(0, 0, 4) -- ++(0, 4, 0) -- ++(0, 0, -4) -- cycle;  % 2 bottom \draw[camerafill] (1, 1, 1) -- ++(1, 0, 0) -- ++(0, 0, 1) -- ++(-1, 0, 0) -- cycle; % 2 back \draw[camerafill] (1, 1, 1) -- ++(1, 0, 0) -- ++(0, 1, 0) -- ++(-1, 0, 0) -- cycle; % 2 left \draw[camerafill] (1, 1, 1) -- ++(0, 0, 1) -- ++(0, 1, 0) -- ++(0, 0, -1) -- cycle; % 2 right \draw[camerafill] (1+1, 1, 1) -- ++(0, 0, 1) -- ++(0, 1, 0) -- ++(0, 0, -1) -- cycle; % 2 front \draw[camerafill] (1, 1, 1+1) -- ++(1, 0, 0) -- ++(0, 1, 0) -- ++(-1, 0, 0) -- cycle; % 2 top \draw[camerafill] (1, 1+1, 1) -- ++(1, 0, 0) -- ++(0, 0, 1) -- ++(-1, 0, 0) -- cycle;  \draw[thick] (2, 1.5, 1.5) -- ++(2, 0, 0);  % 1 right \draw[bottomfill] (0+4, 0, 0) -- ++(0, 0, 4) -- ++(0, 4, 0) -- ++(0, 0, -4) -- cycle; % 1 front \draw[bottomfill] (0, 0, 0+4) -- ++(4, 0, 0) -- ++(0, 4, 0) -- ++(-4, 0, 0) -- cycle; % 1 top \draw[bottomfill] (0, 0+4, 0) -- ++(4, 0, 0) -- ++(0, 0, 4) -- ++(-4, 0, 0) -- cycle;  \draw[-&gt;, thick] (4, 1.5, 1.5) -- ++(2, 0, 0); \end{tikzpicture} \end{document}   With the result    My question: is there a possibility in TikZ to draw an object in a transparent object with without adding the shapes in the right z-order?
8155
Hey I want to connect the bottom loop with the top loop so that it forms a solid.  I have tried selecting multiple vertices and pressing F but that just creates a large face which I do not want. I have tried using grid fill bu that doesn't work either. The solution that seems to work is by selecting four vertices and pressing F and then selecting the next 4 and pressing F and on and on. That just takes too long.
113389
I'm a beginner. I need to place a grid on my map in Unity and would like to access it to place a simple object on mouse click. How can I achieve this ?  I am unable to understand the grid functionality, should I have to write code for a 2D array or is there something in Unity that I can access, and what is basically the grid like something when I click my background image ?