Help - Search - Members - Calendar
Full Version: Lowering the # of choices for randomizing
AC Tools Everything Macro > AC Tool Macros > Macro Development
nowhere
How would one lower the choices for picks when constants that eliminate a possible random choice become true?


Current code (which at times will continue to Pick bad choices and require subsequent "repicks"):
QUOTE
PROCEDURE PROC_BeltWarp_Player1
Call PROC_RandomBeltPick_Player1
Call PROC_MousePosOfBeltsAndWarp_P1
END

PROCEDURE PROC_RandomBeltPick_Player1
Compute BeltPick_P1 = Ceil(Random(1) * $Player1_NumberOfAsteriodBelts)
END

PROCEDURE PROC_MousePosOfBeltsAndWarp_P1
Delay 500
MousePos 261, 128
Delay 500
LeftClick
Delay 500
IF $BeltPick_P1 = 1
IF $BeltPick_P1_Remove1 = 0
MousePos 265, 186
Delay 1 sec
RightClick
Delay 500
MousePos 300, 196
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 2
IF $BeltPick_P1_Remove2 = 0
MousePos 265, 205
Delay 1 sec
RightClick
Delay 500
MousePos 300, 215
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 3
IF $BeltPick_P1_Remove3 = 0
MousePos 265, 224
Delay 1 sec
RightClick
Delay 500
MousePos 300, 234
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 4
IF $BeltPick_P1_Remove4 = 0
MousePos 265, 243
Delay 1 sec
RightClick
Delay 500
MousePos 300, 253
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 5
IF $BeltPick_P1_Remove5 = 0
MousePos 265, 262
Delay 1 sec
RightClick
Delay 500
MousePos 300, 272
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 6
IF $BeltPick_P1_Remove6 = 0
MousePos 265, 281
Delay 1 sec
RightClick
Delay 500
MousePos 300, 291
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 7
IF $BeltPick_P1_Remove7 = 0
MousePos 265, 300
Delay 1 sec
RightClick
Delay 500
MousePos 300, 310
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 8
IF $BeltPick_P1_Remove8 = 0
MousePos 265, 319
Delay 1 sec
RightClick
Delay 500
MousePos 300, 329
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 9
IF $BeltPick_P1_Remove9 = 0
MousePos 265, 338
Delay 1 sec
RightClick
Delay 500
MousePos 300, 348
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
IF $BeltPick_P1 = 10
IF $BeltPick_P1_Remove10 = 0
MousePos 265, 357
Delay 1 sec
RightClick
Delay 500
MousePos 300, 367
Delay 500
LeftClick
Delay 1 sec
ELSE
Call PROC_BeltWarp_Player1
END
END
END

PROCEDURE PROC_CheckForRoids_Player3
SetActiveWindow $WindowTitle_Player3
Delay 2 sec
Loop 20
IsObject NothingFound at 922, 797
IF $BeltPick_P3 = 1
SetConst $BeltPick_P1_Remove1 = 1
END
IF $BeltPick_P3 = 2
SetConst $BeltPick_P1_Remove2 = 1
END
IF $BeltPick_P3 = 3
SetConst $BeltPick_P1_Remove3 = 1
END
IF $BeltPick_P3 = 4
SetConst $BeltPick_P1_Remove4 = 1
END
IF $BeltPick_P3 = 5
SetConst $BeltPick_P1_Remove5 = 1
END
IF $BeltPick_P3 = 6
SetConst $BeltPick_P1_Remove6 = 1
END
IF $BeltPick_P3 = 7
SetConst $BeltPick_P1_Remove7 = 1
END
IF $BeltPick_P3 = 8
SetConst $BeltPick_P1_Remove8 = 1
END
IF $BeltPick_P3 = 9
SetConst $BeltPick_P1_Remove9 = 1
END
IF $BeltPick_P3 = 10
SetConst $BeltPick_P1_Remove10 = 1
END
Call PROC_BeltWarp_Player3
Delay 500
Delay $WarpToBeltDelay
Delay 500
Call PROC_DeployDrones
Delay 500
ELSE
Delay 500
BREAK
END
END
Call PROC_OrbitAsteriod
Delay 500
END


Ahk
You could make a temporary list containing the numbers 1 through 9, or whatever you're after. Delete each element and decrease the counter of the list (or count the list each time through, however you choose)...it's harder to explain it seems.

Assign or generate numbers into a temporary list.

Temporary list:
1
2
3
4
5
6

Compute Random number 1 through count (6)
Delete element just used
Decrease count of temporary list
Compute Random number 1 through count (5)
Delete element just used
...etc etc

This way, each one will be used only once, and will still be random.
How you implement it into your code is up to you. I'm not sure which would be easier, list or dataset offhand. You'll have to figure out one or the other and/or whatever is easiest.

Good luck.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.