netlogo 3D similar keyword to random-float in 2D?
I'm currently working on adapting "The Game of Life" code in 3D for a final in my CS class for high school, and I'm looking for a keyword similar to "random-float" that will have the same effect in netlogo. For reference, here is the link to the netlogo manual for the "random-float" keyword: http://ccl.northwestern.edu/netlogo/docs/dict/random-float.html
if anyone could help me out, it would be very much appreciated.
netlogo
add a comment |
I'm currently working on adapting "The Game of Life" code in 3D for a final in my CS class for high school, and I'm looking for a keyword similar to "random-float" that will have the same effect in netlogo. For reference, here is the link to the netlogo manual for the "random-float" keyword: http://ccl.northwestern.edu/netlogo/docs/dict/random-float.html
if anyone could help me out, it would be very much appreciated.
netlogo
I'm a bit confused on the question because it could be asking about the other "random" functions found in the NetLogo dictionary. Are you trying to find an integer based random, a random with a different probability distribution, or a random that allows you to specify the range?
– javylow
Nov 14 '18 at 15:43
So what have you tried?
– cweitat
Nov 14 '18 at 15:48
So, in the original "Game of Life" model in the model library, one of the lines that determines the density of the patches, which is "random-float". I look it up in the netlogo dictionary, and admittedly, I don't entirely understand it. I tried writing it as is in 3D, but it will always create patches at the same density. I think what I'm looking for is a probability distribution, in order for it to work.
– Aaron H.
Nov 14 '18 at 18:15
When you say create patches are you referring to coloring them or some other operation, making them invisible? Could you add a code snippet of your latest version that creates the patch with varying density?
– javylow
Nov 14 '18 at 20:18
add a comment |
I'm currently working on adapting "The Game of Life" code in 3D for a final in my CS class for high school, and I'm looking for a keyword similar to "random-float" that will have the same effect in netlogo. For reference, here is the link to the netlogo manual for the "random-float" keyword: http://ccl.northwestern.edu/netlogo/docs/dict/random-float.html
if anyone could help me out, it would be very much appreciated.
netlogo
I'm currently working on adapting "The Game of Life" code in 3D for a final in my CS class for high school, and I'm looking for a keyword similar to "random-float" that will have the same effect in netlogo. For reference, here is the link to the netlogo manual for the "random-float" keyword: http://ccl.northwestern.edu/netlogo/docs/dict/random-float.html
if anyone could help me out, it would be very much appreciated.
netlogo
netlogo
asked Nov 14 '18 at 14:54
Aaron H.Aaron H.
1
1
I'm a bit confused on the question because it could be asking about the other "random" functions found in the NetLogo dictionary. Are you trying to find an integer based random, a random with a different probability distribution, or a random that allows you to specify the range?
– javylow
Nov 14 '18 at 15:43
So what have you tried?
– cweitat
Nov 14 '18 at 15:48
So, in the original "Game of Life" model in the model library, one of the lines that determines the density of the patches, which is "random-float". I look it up in the netlogo dictionary, and admittedly, I don't entirely understand it. I tried writing it as is in 3D, but it will always create patches at the same density. I think what I'm looking for is a probability distribution, in order for it to work.
– Aaron H.
Nov 14 '18 at 18:15
When you say create patches are you referring to coloring them or some other operation, making them invisible? Could you add a code snippet of your latest version that creates the patch with varying density?
– javylow
Nov 14 '18 at 20:18
add a comment |
I'm a bit confused on the question because it could be asking about the other "random" functions found in the NetLogo dictionary. Are you trying to find an integer based random, a random with a different probability distribution, or a random that allows you to specify the range?
– javylow
Nov 14 '18 at 15:43
So what have you tried?
– cweitat
Nov 14 '18 at 15:48
So, in the original "Game of Life" model in the model library, one of the lines that determines the density of the patches, which is "random-float". I look it up in the netlogo dictionary, and admittedly, I don't entirely understand it. I tried writing it as is in 3D, but it will always create patches at the same density. I think what I'm looking for is a probability distribution, in order for it to work.
– Aaron H.
Nov 14 '18 at 18:15
When you say create patches are you referring to coloring them or some other operation, making them invisible? Could you add a code snippet of your latest version that creates the patch with varying density?
– javylow
Nov 14 '18 at 20:18
I'm a bit confused on the question because it could be asking about the other "random" functions found in the NetLogo dictionary. Are you trying to find an integer based random, a random with a different probability distribution, or a random that allows you to specify the range?
– javylow
Nov 14 '18 at 15:43
I'm a bit confused on the question because it could be asking about the other "random" functions found in the NetLogo dictionary. Are you trying to find an integer based random, a random with a different probability distribution, or a random that allows you to specify the range?
– javylow
Nov 14 '18 at 15:43
So what have you tried?
– cweitat
Nov 14 '18 at 15:48
So what have you tried?
– cweitat
Nov 14 '18 at 15:48
So, in the original "Game of Life" model in the model library, one of the lines that determines the density of the patches, which is "random-float". I look it up in the netlogo dictionary, and admittedly, I don't entirely understand it. I tried writing it as is in 3D, but it will always create patches at the same density. I think what I'm looking for is a probability distribution, in order for it to work.
– Aaron H.
Nov 14 '18 at 18:15
So, in the original "Game of Life" model in the model library, one of the lines that determines the density of the patches, which is "random-float". I look it up in the netlogo dictionary, and admittedly, I don't entirely understand it. I tried writing it as is in 3D, but it will always create patches at the same density. I think what I'm looking for is a probability distribution, in order for it to work.
– Aaron H.
Nov 14 '18 at 18:15
When you say create patches are you referring to coloring them or some other operation, making them invisible? Could you add a code snippet of your latest version that creates the patch with varying density?
– javylow
Nov 14 '18 at 20:18
When you say create patches are you referring to coloring them or some other operation, making them invisible? Could you add a code snippet of your latest version that creates the patch with varying density?
– javylow
Nov 14 '18 at 20:18
add a comment |
1 Answer
1
active
oldest
votes
I think you're okay to convert this more or less directly to 3D without using a different primitive- random-float
or random
should still do the trick. Essentially, in the 2D version the density is determined by getting each cell to randomly draw a number between 0 and 100, and compare that to the value in the initial-density
slider. If the number drawn is less than the initial-density
, the cell is "born." So, you can basically do the same thing in 3D- with this simplified setup:
to setup
ca
ask patches [
; if a random number between 0 and 100 is less than
; 5, become a "live" cell. Otherwise, become a dead cell.
ifelse random-float 100 < 5
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
to cell-birth
set pcolor green
end
to cell-death
set pcolor black
end
That gives something like:
So, to get the density to vary you can just modify the 5
(or add a slider as was done in the original 2D life. If I instead do 50:
to setup
ca
ask patches [
ifelse random-float 100 < 50
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
I get a much denser 3D world:
I hope that helps!
Thank you so much! It helped out a lot. I realized after a short while trying this that I was using a greater than, instead of a less than, so that was a problem, but this works flawlessly!
– Aaron H.
Nov 15 '18 at 14:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303004%2fnetlogo-3d-similar-keyword-to-random-float-in-2d%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you're okay to convert this more or less directly to 3D without using a different primitive- random-float
or random
should still do the trick. Essentially, in the 2D version the density is determined by getting each cell to randomly draw a number between 0 and 100, and compare that to the value in the initial-density
slider. If the number drawn is less than the initial-density
, the cell is "born." So, you can basically do the same thing in 3D- with this simplified setup:
to setup
ca
ask patches [
; if a random number between 0 and 100 is less than
; 5, become a "live" cell. Otherwise, become a dead cell.
ifelse random-float 100 < 5
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
to cell-birth
set pcolor green
end
to cell-death
set pcolor black
end
That gives something like:
So, to get the density to vary you can just modify the 5
(or add a slider as was done in the original 2D life. If I instead do 50:
to setup
ca
ask patches [
ifelse random-float 100 < 50
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
I get a much denser 3D world:
I hope that helps!
Thank you so much! It helped out a lot. I realized after a short while trying this that I was using a greater than, instead of a less than, so that was a problem, but this works flawlessly!
– Aaron H.
Nov 15 '18 at 14:40
add a comment |
I think you're okay to convert this more or less directly to 3D without using a different primitive- random-float
or random
should still do the trick. Essentially, in the 2D version the density is determined by getting each cell to randomly draw a number between 0 and 100, and compare that to the value in the initial-density
slider. If the number drawn is less than the initial-density
, the cell is "born." So, you can basically do the same thing in 3D- with this simplified setup:
to setup
ca
ask patches [
; if a random number between 0 and 100 is less than
; 5, become a "live" cell. Otherwise, become a dead cell.
ifelse random-float 100 < 5
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
to cell-birth
set pcolor green
end
to cell-death
set pcolor black
end
That gives something like:
So, to get the density to vary you can just modify the 5
(or add a slider as was done in the original 2D life. If I instead do 50:
to setup
ca
ask patches [
ifelse random-float 100 < 50
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
I get a much denser 3D world:
I hope that helps!
Thank you so much! It helped out a lot. I realized after a short while trying this that I was using a greater than, instead of a less than, so that was a problem, but this works flawlessly!
– Aaron H.
Nov 15 '18 at 14:40
add a comment |
I think you're okay to convert this more or less directly to 3D without using a different primitive- random-float
or random
should still do the trick. Essentially, in the 2D version the density is determined by getting each cell to randomly draw a number between 0 and 100, and compare that to the value in the initial-density
slider. If the number drawn is less than the initial-density
, the cell is "born." So, you can basically do the same thing in 3D- with this simplified setup:
to setup
ca
ask patches [
; if a random number between 0 and 100 is less than
; 5, become a "live" cell. Otherwise, become a dead cell.
ifelse random-float 100 < 5
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
to cell-birth
set pcolor green
end
to cell-death
set pcolor black
end
That gives something like:
So, to get the density to vary you can just modify the 5
(or add a slider as was done in the original 2D life. If I instead do 50:
to setup
ca
ask patches [
ifelse random-float 100 < 50
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
I get a much denser 3D world:
I hope that helps!
I think you're okay to convert this more or less directly to 3D without using a different primitive- random-float
or random
should still do the trick. Essentially, in the 2D version the density is determined by getting each cell to randomly draw a number between 0 and 100, and compare that to the value in the initial-density
slider. If the number drawn is less than the initial-density
, the cell is "born." So, you can basically do the same thing in 3D- with this simplified setup:
to setup
ca
ask patches [
; if a random number between 0 and 100 is less than
; 5, become a "live" cell. Otherwise, become a dead cell.
ifelse random-float 100 < 5
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
to cell-birth
set pcolor green
end
to cell-death
set pcolor black
end
That gives something like:
So, to get the density to vary you can just modify the 5
(or add a slider as was done in the original 2D life. If I instead do 50:
to setup
ca
ask patches [
ifelse random-float 100 < 50
[ cell-birth ]
[ cell-death ]
]
reset-ticks
end
I get a much denser 3D world:
I hope that helps!
answered Nov 14 '18 at 21:51
Luke CLuke C
6,6621815
6,6621815
Thank you so much! It helped out a lot. I realized after a short while trying this that I was using a greater than, instead of a less than, so that was a problem, but this works flawlessly!
– Aaron H.
Nov 15 '18 at 14:40
add a comment |
Thank you so much! It helped out a lot. I realized after a short while trying this that I was using a greater than, instead of a less than, so that was a problem, but this works flawlessly!
– Aaron H.
Nov 15 '18 at 14:40
Thank you so much! It helped out a lot. I realized after a short while trying this that I was using a greater than, instead of a less than, so that was a problem, but this works flawlessly!
– Aaron H.
Nov 15 '18 at 14:40
Thank you so much! It helped out a lot. I realized after a short while trying this that I was using a greater than, instead of a less than, so that was a problem, but this works flawlessly!
– Aaron H.
Nov 15 '18 at 14:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303004%2fnetlogo-3d-similar-keyword-to-random-float-in-2d%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'm a bit confused on the question because it could be asking about the other "random" functions found in the NetLogo dictionary. Are you trying to find an integer based random, a random with a different probability distribution, or a random that allows you to specify the range?
– javylow
Nov 14 '18 at 15:43
So what have you tried?
– cweitat
Nov 14 '18 at 15:48
So, in the original "Game of Life" model in the model library, one of the lines that determines the density of the patches, which is "random-float". I look it up in the netlogo dictionary, and admittedly, I don't entirely understand it. I tried writing it as is in 3D, but it will always create patches at the same density. I think what I'm looking for is a probability distribution, in order for it to work.
– Aaron H.
Nov 14 '18 at 18:15
When you say create patches are you referring to coloring them or some other operation, making them invisible? Could you add a code snippet of your latest version that creates the patch with varying density?
– javylow
Nov 14 '18 at 20:18