itsnotluketime Posted March 12, 2017 Share Posted March 12, 2017 I decided to make a cloud generator, something that makes random blobs that somewhat represent clouds for an upcoming game I've been developing (university project). To test out some functions I used MS paint and made my code click on random points within a rectangle, using a simple algorithm to make a sort of wispy blob shape. Anyway, this is what always happens no matter what I do to the code (and I've spent hours changing it): I mean I'm just using this for testing, it's not a big deal, but the curiosity is killing me. Why the hell would a grid be formed here??? I just don't get it, does anyone know why this is happening? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 12, 2017 Moderators Share Posted March 12, 2017 itsnotluketime, It is obviously the recursive call to the _CloudGenerate function that is causing the problem. ... Seriously, if you want some help, please post the code you use. The random number generator used by AutoIt is pretty good, so it must be something in your algorithm that is causing the effect. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
itsnotluketime Posted March 12, 2017 Author Share Posted March 12, 2017 (edited) Here's the function I have so far: expandcollapse popup$midx = $tlpos[0] + (($brpos[0] - $tlpos[0]) / 2) $midy = $tlpos[1] + (($brpos[1] - $tlpos[1]) / 2) $specialmidx = $midx $specialmidy = $midy Func click($tl, $br) $temprandnum = Random(1, 10, 1) If ($temprandnum >= 7) Then If $specialmidx > $midx Then $specialmidx += Random(0 - ($specialmidx - $midx), 2, 1) ElseIf $specialmidx <= $midx Then $specialmidx += Random(-2,($midx - $specialmidx), 1) EndIf If $specialmidy > $midy Then $specialmidy += Random(0 - ($specialmidy - $midy), 2, 1) ElseIf $specialmidy <= $midy Then $specialmidy += Random(-2, ($midy - $specialmidy), 1) EndIf EndIf If ($temprandnum <= 6) Then $specialmidx += Random(-1, 1, 1) $specialmidy += Random(-1, 1, 1) EndIf If $specialmidx >= $br[0] Then $Specialmidx -= Random(1, 2, 1) EndIf If $specialmidx <= $tl[0] Then $Specialmidx += Random(1, 2, 1) EndIf If $specialmidy >= $br[1] Then $Specialmidy -= Random(1, 2, 1) EndIf If $specialmidy <= $tl[1] Then $Specialmidy += Random(1, 2, 1) EndIf MouseMove($specialmidx, $specialmidy, 10) MouseDown( "left" ) MouseUp( "left" ) EndFunc $tlpos and $brpos are defined earlier on in the script, for the top right and bottom right corners of the triangle. The code is super crude, it clicks the same places over and over, but like I said I'm just testing things out. And for now it only works for smaller triangles EDIT*: Perhaps my program thinks my screen is smaller than it really is, so when it moves to each pixel it's actually moving like 1.2 pixels on the screen, meaning every now and then it will skip a pixel. I agree with you Melba23 about the random functions, I've used them a lot and they've never failed me. Edited March 12, 2017 by itsnotluketime Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 12, 2017 Moderators Share Posted March 12, 2017 itsnotluketime, Using that algorithm I get nothing like your "grid" pattern - and as expected each pass produces a different pattern: expandcollapse popup#include <Array.au3> HotKeySet("{ESC}", "_Exit") Global $tlpos[2] = [10, 10], $brpos[2] = [110, 110] $midx = $tlpos[0] + (($brpos[0] - $tlpos[0]) / 2) $midy = $tlpos[1] + (($brpos[1] - $tlpos[1]) / 2) $specialmidx = $midx $specialmidy = $midy While 1 Global $aPos[30][30] For $i = 1 To 100 click($tlpos, $brpos) Next _ArrayDisplay($aPos, "", Default, 8) WEnd Func click($tl, $br) $temprandnum = Random(1, 10, 1) If ($temprandnum >= 7) Then If $specialmidx > $midx Then $specialmidx += Random(0 - ($specialmidx - $midx), 2, 1) ElseIf $specialmidx <= $midx Then $specialmidx += Random(-2,($midx - $specialmidx), 1) EndIf If $specialmidy > $midy Then $specialmidy += Random(0 - ($specialmidy - $midy), 2, 1) ElseIf $specialmidy <= $midy Then $specialmidy += Random(-2, ($midy - $specialmidy), 1) EndIf EndIf If ($temprandnum <= 6) Then $specialmidx += Random(-1, 1, 1) $specialmidy += Random(-1, 1, 1) EndIf If $specialmidx >= $br[0] Then $Specialmidx -= Random(1, 2, 1) EndIf If $specialmidx <= $tl[0] Then $Specialmidx += Random(1, 2, 1) EndIf If $specialmidy >= $br[1] Then $Specialmidy -= Random(1, 2, 1) EndIf If $specialmidy <= $tl[1] Then $Specialmidy += Random(1, 2, 1) EndIf $aPos[$specialmidx - 45][$specialmidy - 45] &= "X" EndFunc Func _Exit() Exit EndFunc M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
itsnotluketime Posted March 12, 2017 Author Share Posted March 12, 2017 (edited) Wow thanks for doing that. I guess it's just a problem with paint then. I'll try changing my resolution and tweaking other settings until I can get this to work, thanks for the help. I didn't even know you could display an array like that, ill definitely use that in the future :). Edited March 12, 2017 by itsnotluketime error in phrasing Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now