Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

How to Randomize X, Y Coordinates in Visual Logic When using Move To c


  • Please log in to reply

#1
ThisisDandy

ThisisDandy

    New Member

  • Member
  • Pip
  • 5 posts
First: I am not working on an assignment. I am preparing for an assignment that I know is going to be coming and I don't want any issues when I get to it.

Before i am told to go check the Visual Logic tutorials--they skip over graphical randomization; I was able to get the house graphic to work after I fixed one of the variables that was misprinted in the book. That is the closest I have gotten to graphical randomization and it isn't quite where I need it to be.

Okay, here's the problem: I can get randomization in one of the four quadrants of the grid using
x: random(num) - num
y: random(num) + num or vice versa.
Is it possible for it to randomize using all four quadrants (positive x, y; negative x, y postive x, negative y; positive y, negative x.)

I would upload a vl file for someone to play around with and try and figure out but its not allowed. IDK. I've about exhausted my resources and I know this is going to be needed on my final project, which hasn't been received yet. And i Know it can be done because I've seen it done and the book shows it being able to be done but it just doesn't explain it. Nor does the video tutorial or FAQ!

Any help would be nice guys and gals.
  • 1

Advertisements


#2
Ehsanit

Ehsanit

    Member

  • Member
  • PipPipPip
  • 163 posts
I don't know the syntax of that language, but in general programming terms I could probably make a suggestion.Generate a random number between 0 and double the maximum value. Then subtract the real maximum.
If I understand it correctly

y: random(num*2) - num
should generate a random value between positive and negative num.
  • 0

#3
ThisisDandy

ThisisDandy

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
I'll give it a try. Visual Logic, sadly, is not a real programming language. It uses the logic behind the higher languages, (If, for, while, do while, assignment, procedures, etc) without requiring actual coding. Its a great tool for learning the logic behind coding, but it lacks a lot of instructive content which is direly needed (you hearing me Visual Logic!!!!?????) Anyone else have a solution?

Any Visual Logic students out there that have been fighting with the same issue?

Just to refresh: I need to be able to randomize the generation of graphics within all four quadrants of the X,Y grid and thus far I have only been able to get it to work in one of the four quadrants at a time. Furthermore, after some more putzing around I was able to come up with this. call procedures are in brackets

input sides
input Build

for 1 to Build step 1

Move to: X: random(100) - 100
Y: random(100) + 100
[BuildShape(Build)]
Move to: X: random(100) + 100
Y: random(100) + 100
[BuildShape(Build)]
Move to: X: random(100) + 100
Y: random(100) - 100
[BuildShape(Build)]
Move to: X: random(100) - 100
Y: random(100) - 100
[BuildShape(Build)]
end for

and the [BuildShape(Build) procedure would roughly look like this

[BuildShape(sides)] Argument: sides = Build1 (Sets Build1 = to the Input sides outside of procedure)

for 1 to Build1
pen color : Pink
Forward: 50
Turn Right: 360 / Build1
end for

For 3, 4, 5 the shapes produced will be pink and a triangle, a square, and a pentagon. I know what I'm doing, I just can't figure out this DUMB [bleep] part about randomization. I'm a lil tipsy, been at work for twelve hours, and i just want this to be done.


Now that will build four shapes in the four quadrants (possibly) but it still is not completely random because procedure [BuildShape] is limited to the location set by the move to.

Again, let me reiterate: I know I am PROBABLY going to be using this on my final project BUTTT BUTT BUTTTT!!!!!: I have yet to receive my project so this question is not based on any specific problem I have received for homework or class work.

Note: If you look down the forum list there is a paycheck problem that is necro and no one replied to it. I didn't reply either but I was really bored so I opened up VL and went to work a total of 3.5 minutes and I solved the problem. Taxes on 400 dollars at 15% is 60 dollars, not 45. It required three inputs, one assignment, an if, and a nested if statement, and one output. Only had one error and that was because I didn't have enough white space. Silly beginners. If people take five minutes to work on a problem they will see that the solution is soooo easy.

unless of course you are trying to figure out the randomization of X, Y coordinates.

Edited by ThisisDandy, 14 November 2010 - 03:26 AM.

  • 0

#4
ThisisDandy

ThisisDandy

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
Fixed. The problem was impatience.

random(650) - 650 Size of the field through the lowest possible allowance. That's why networking is so beautiful.

Thanks for the help. :-D
  • 0

#5
Ehsanit

Ehsanit

    Member

  • Member
  • PipPipPip
  • 163 posts
I'm now confused. Surely that just gives you a number between -650 and 0, nothing that transverses the boundary between the quadrants. I would expect random(1301) - 650 to give a value that could be either side of 0. However I suppose I just misunderstood what you were after.
  • 0

#6
ThisisDandy

ThisisDandy

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
No you really didn't misunderstand. And I'm not certain as to why it wouldn't provide only a number between 0 and 650 aswell, but it still does.

This stuff is so messed up. right now I'm trying to figure out how to make my rotating rectangles look like the final project diagrams rotating rectangles.

Usually, to get something to rotate around a center point in vl it looks like :

Turn right: 360 / NumofThingsCreated and it will give you equal angles for the things created. What I mean is
For 1 to NumofThingsCreated step 1
Forward 50
Back 50
Turn Right 360 / NumofThingsCreated

if you input 4 for NumofThingsCreated you will get a +

That's normally.

But with a rectangle the angles are not proportionate because they take up more area than a single ray? idk. You guys can't help me with this one because its my final project. I'm just talking now. Trying to figure it out.
  • 0

#7
ThisisDandy

ThisisDandy

    New Member

  • Topic Starter
  • Member
  • Pip
  • 5 posts
I was facing the wrong direction. I had to turn Ninety degrees to the right. There's the second 100.


But the random one isn't fixed yet now. I'm pretty stumped. I'll ask my friend tomorrow I think he figured something out with it. But 2 /3 a month before they're do is not a bad thing. :-D

Edited by ThisisDandy, 15 November 2010 - 06:20 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP