In my setup, I am using the following code to create agents called "darks", and these agents are assigned to a designated set of patches (free-patches).
I am trying to have each turtle assigned to a random patch within the designated area without any of the turtles sharing a patch.
I have stumbled across code that tells a patch to sprout a specific turtle, but can I accomplish my goal without resorting to the patch sprout?
create-darks #-of-darks [
set shape "person"
set size 1
set color black
move-to one-of free-patches
]
You can just get a patch with no darks there.I would also only create a dark if there's enough space.
let n-or-remaining-spaces min (list n (count patches with [not any? darks-here]))
create-darks n-or-remaining-spaces
[
;;Your other setup code
move-to one-of patches with [not any? darks-here]
]
Related
I'm having an issue with writing a GIMP Script that applies a drop shadow. So this is how the script looks when you pull it from the console:
(script-fu-drop-shadow run-mode image drawable value value value color value toggle)
And these are the values I've entered:
(script-fu-drop-shadow 1 image layer 0 0 3 '(115.9 200.9 245.1) 1 0)
When I try to run it, I get the following error:
Execution error for 'MUA Portrait Outline - Blue Glow':
Error: <: argument 1 must be: number
I think I'm not really understanding all the values that I need to enter.
run-mode is straightforward, since it says to either use 1 or 0.
Based on prior scripts I've tried, I'm pretty sure that I leave image as image since it's just for the current image.
I'm not too sure what drawable is, but I read that drawables include layers, so I put layer. Not sure if that's accurate.
The next 3 value variables are for the x offset, y offset, and blur radius. Straightforward.
I'm not too sure if I'm entering color correctly as I've never actually used a script that asks for the color, but I think I did it correctly just based on some research I did online.
The last value variable is also straightforward, as it's the opacity of the shadow.
I have no clue what to set for toggle. It says it accepts INT32 for that, so I figured I would just put 0. I tried to do some online research, but I couldn't find anything
Any help would be greatly appreciated! I'm not well-versed in Script-fu. I've tried a few things here and there, but I don't know much formal stuff. Feel free to explain things as simply as possible :)
You have to find numbers of current image and current drawable (if you are working with multiple images, these don't have to be 1 and 3), then call it without run-mode:
> (gimp-image-list)
(1 #(1)) <-- All images, current image is one number from vector #(1)
> (gimp-image-get-active-drawable 1)
(3) <-- Current drawable of current image
> (script-fu-drop-shadow 1 3 0 0 20 '(255 0 0) 100 0)
(#t)
If you don't know meaning of some arguments, you can check Procedure Browser (Help → Procedure Browser)- toggle argument is Allow resizing and you can also use TRUE or FALSE as value, because they evaluate to 1 or 0 respectively.
EDIT: If you want run this as .scm script, follow these steps:
.scm file should look like this:
(define (script-fu-my-script image drawable)
(script-fu-drop-shadow image drawable 0 0 20 '(255 0 0) 100 0))
(script-fu-register "script-fu-my-script"
_"Add _Drop _Shadow..."
_"Add drop shadow"
"Author's name"
"Author's name"
"12/9/21"
"*"
SF-IMAGE "Input image" 0
SF-DRAWABLE "Input drawable" 0)
(script-fu-menu-register "script-fu-my-script"
"<Image>/My_Scripts/Drop")
Find correct folder for your scripts: Edit -> Preferences -> Folders -> Scripts and move your .scm file to one from these folders.
Restart GIMP or refresh your scripts: Filters -> Script-Fu -> Refresh Scripts
Right click on image, My Scripts -> Drop -> Add Drop Shadow.
It works if you drop the run-mode argument.
(script-fu-drop-shadow 1 3 3 3 3 '(115 200 245) 50 0)
Don't ask me why, I write my scripts in Python :)
For that matter most of the code in that script is handling things that mostly make sense when using it interactively. In most case your code can do it by selecting alpha, adding a layer, filling the selection, blurring it and adjusting the offset.
I am testing the RandomWaypointMobility with a constrained area minX=-3000m, maxX=3000m, minY=-3000m and maxY=3000m. The #displaystrings sets bgp=6000,6000. The result is that nodes in the negative part of the coordinate system are rendered outside the display/canvas area.
Are there some parameters I can use to tell OMNeT++/INET that origo for the coordinate system is at the center of the display/canvas? I have tried
*.visualizer.sceneVisualizer.sceneMaxX = 3000m
*.visualizer.sceneVisualizer.sceneMinX = -3000m
*.visualizer.sceneVisualizer.sceneMaxY = 3000m
*.visualizer.sceneVisualizer.sceneMinY = -3000m
*.visualizer.sceneVisualizer.sceneMaxZ = 3000m
*.visualizer.sceneVisualizer.sceneMinZ = -3000m
but it doesn't work as I hoped for.
I realize that for RandomWaypointMobility I can just use a constrained area with positive coordinates only, which would keep objects within the canvas. However, my next task is to pull in mobility traces that include negative coordinates. Do I need to manually shift all coordinates so they become positive and stay within the canvas/display, or is there a smarter way of doing things?
Any hints appreciated!
Thanks,
Dragos
What you set is in fact bgb=6000,6000 which sets the size of the module. There were indeed plans to add a tag called bgp directly into OMNeT++ which would introduce an offset, but at the end it was not implemented. The reason is that once you go down into that rabbit hole, you want to implement also scaling and then rotation etc. So the default display string based visualization left as simple as possible and all these transformation stuff was left for the model code.
So indeed, SceneCanvasVisualizer in INET has a viewScale and viewTranslation parameter that can be used for these purposes.
I'm stuck at this part of my code.
I want to move my turtle under my control. I mean when it first reached a house, it must turn and move to another house.
In this code, it will move -10 5 which red patch and house shape here.
Now, how can I tell this turtle ''you are here and you must go there'' !?
(I use a red patch because I tried to move the turtle depending on patch but can't find any solution.)
breed [cities city]
breed [flag person]
to setup
clear-all
set-default-shape cities "house"
create-flag 1
[ set SIZE 6 set shape "by" setxy -5 3 set HEADING 0 ]
create-flag 1
[ set SIZE 6 set shape "sel" setxy 12 5 set HEADING 0 ]
create-cities 1
[set color yellow set SIZE 2 setxy 8 2]
create-cities 1
[ set color yellow set SIZE 2 setxy -10 5]
ask patch -10 5 [set pcolor red]
end
to go
ask flag with [ shape = "by" ] [ facexy -10 5 forward 1 set HEADING 0 ]
end
Update
I understand and tried this code from #jenB's answer and it's yet not moving as I want. Thank you for your interest, but there are two problems here that I tried to explain with this picture.
I've started a new question about this here:
Turtles, patches and their moving sequentially from one patch to the next
Look up turtles-on in the NetLogo dictionary. From your other question, I know that you are trying to make your flags move sequentially from one house to the next. One way to do that is to have the flag store its target and simply change the target when it reaches one. Something like this (this will not work as it is incomplete)
breed [cities city]
breed [flag person]
flag-own
[ target
]
to setup
clear-all
create-flag 1
[ set size 6
set shape "by"
setxy -5 3
set target patch -10 5
face target
]
< other commands >
end
to go
ask flag-on patch -10 5
[ set target patch <next place you want it to go>
face target
]
ask flag with [ shape = "by" ]
[ forward 1 ]
end
I also got rid of all your set heading commands. The command face turns the turtle so that forward is towards whatever the turtle is facing. The command set heading turns the turtle so that forward is in the direction given by the heading (for example set heading 90 will make it move to the right if told to go forward).
Take a look at Move Towards Target Example, in the Code Examples section of NetLogo's Models Library. It does exactly this, if I understand your question correctly.
The time extensions seems to update the tick counter in the interface view, but not for the plots? I am using the MousetrapDiscreteEvents.nlogo file in the Examples folder of the the time extension.
Plotting graphs via right clicking the plot and adding the following line doesn't work:
plot count patches with [pcolor = yellow]
However, if written in code it does work, like the authoer of the time extensions demonstrates:
set-current-plot "Untriggered traps"
plotxy ticks count patches with [pcolor = yellow]
But why doesn't the first one work?
Perhaps the extension is doing the equivalent of tick-advance (dictionary entry), which does not trigger plot updates? If so, you might report it as a bug to the extension author.
But anyway, you can work around it by calling update-plots (dictionary entry) yourself at the appropriate points in your code.
In Windows 7 and Windows XP you can find the "Window Color and Appearance" dialog under "Control Panel\Appearance and Personalization\Personalization".
Changing "Color1" of item "3D-Border" will result in a change of the following entries in the registry key
[HKEY_CURRENT_USER\Control Panel\Colors]
containing the resulting rgb-values:
Group1 (same values):
InactiveTitle, AppWorkspace, ButtonShadow, Graytext
Group2 (same values, different to those of group1):
Scrollbar, ButtonHilight
Does anyone know how these value are being calculated from the given rgb-values of "Color1"?
After searching the web without results and playing around with many values I did not happen to find a plausible way of how to do this.
Does anyone know the rules for this?
Any help would be appreciated.
I uploaded some demo values, systematically dealing with values in the lower parts. Also a text file comparing the affected registry key [HKEY_CURRENT_USER\Control Panel\Colors] after change of Color to Red (255 0 0).
When you set the "3D Border" color to red, it changed the "Button Face" color to red and interpolated this color to generate various lighter and darker shades of red, which were used to set some related color values.
The point is to create a consistent-looking theme with minimal effort. All you need to do is set the "base" color for 3D objects, and all of the other colors are automatically calculated to ensure that objects have the appropriate 3D appearance.
Some of these values, like the highlight and shadow colors used for 3D objects, are not directly configurable from the control panel applet. However, they can be set manually in the registry, and you can call the SetSysColors function to update currently running applications.
Why do you think you need to know the actual algorithm that Windows is using? What problem are you trying to solve? What are you going to use this information to do?
I do not imagine that the exact algorithm is documented anywhere. The code has been part of the OS since at least Windows 95.