Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[AutoIt - Artificial Intelligence] Randomly selecting a char. in Diablo II
#1
This AutoIt script was designed to by-pass Blizzard Entertainment's Diablo II's latest anti-hack features (the automated flagging system).

It utilizes a rudimentary form of artificial intelligence in order to reduce the odds of being flagged as a botter.

Code:
#include <MsgBoxConstants.au3>   ; Message box constants (for "magic numbers" for icons selected)
#include <math.au3>            ; For deciding if a number is an EVEN or ODD value
#include <Array.au3>            ; For _ArrayXYZ() functions

Global Enum $MOVE_UP = 1, $MOVE_DOWN = 2, $MOVE_LEFT = 3, $MOVE_RIGHT = 4
Global Enum $ODD_NUM = 1, $EVEN_NUM = 2

main()

Func main()
  Local $curSlot = 1
  Local $targetSlot = 8
  Local $maxMoves = 1

  Local $path = generateRandomPath($curSlot, $targetSlot, $maxMoves)

  _ArrayDisplay($path, "FULL PATH")
EndFunc

Func generateRandomPath(ByRef $curSlot, Const ByRef $targetSlot, Const ByRef $maxMoves)
   Local $path[$maxMoves]

   For $n = 0 To $maxMoves - 1
      $path[$n] = generateRandomMove($curSlot)
      updateCurSlotPos($curSlot, $path[$n])
   Next

   If ($curSlot <> $targetSlot) Then
      Local $pathToTarget[0]

      Local Const $targetSide = _MathCheckDiv($targetSlot, 2)
      If ($targetSide == $MATH_ISDIVISIBLE) Then
         If (canMoveRight($curSlot)) Then
            _ArrayAdd($pathToTarget, $MOVE_RIGHT)
            updateCurSlotPos($curSlot, $MOVE_RIGHT)
         EndIf
      ElseIf ($targetSide == $MATH_ISNOTDIVISIBLE) Then
         If (canMoveLeft($curSlot)) Then
            _ArrayAdd($pathToTarget, $MOVE_LEFT)
            updateCurSlotPos($curSlot, $MOVE_LEFT)
         EndIf
      EndIf

      While ($curSlot <> $targetSlot)
         ; Are we "above" the target slot?
         If ($targetSlot < $curSlot) Then
            If (canMoveUp($curSlot)) Then
               _ArrayAdd($pathToTarget, $MOVE_UP)
               updateCurSlotPos($curSlot, $MOVE_UP)
            EndIf
         EndIf

         ; Are we "below" the target slot?
         If ($targetSlot > $curSlot) Then
            If (canMoveDown($curSlot)) Then
               _ArrayAdd($pathToTarget, $MOVE_DOWN)
               updateCurSlotPos($curSlot, $MOVE_DOWN)
            EndIf
         EndIf
      WEnd

      _ArrayShuffle($pathToTarget)
      _ArrayConcatenate($path, $pathToTarget)
   EndIf

   Return $path
EndFunc

Func generateRandomMove(ByRef Const $curSlot)
   Local $validMoves = getValidMoves($curSlot)
   ;_ArrayDisplay($validMoves, "$validMoves")

   Return $validMoves[Random(0, UBound($validMoves) - 1, 1)]
EndFunc

Func getValidMoves(ByRef Const $curSlot)
   Local $validMoves[0]

   If (canMoveUp($curSlot)) Then
      _ArrayAdd($validMoves, $MOVE_UP)
   EndIf

   If (canMoveDown($curSlot)) Then
      _ArrayAdd($validMoves, $MOVE_DOWN)
   EndIf

   If (canMoveLeft($curSlot)) Then
      _ArrayAdd($validMoves, $MOVE_LEFT)
   ElseIf (canMoveRight($curSlot)) Then
      _ArrayAdd($validMoves, $MOVE_RIGHT)
   EndIf

   Return $validMoves
EndFunc

Func updateCurSlotPos(ByRef $curSlot, ByRef Const $move)
   Switch ($move)
      Case $MOVE_UP
         $curSlot -= 2
      Case $MOVE_DOWN
         $curSlot += 2
      Case $MOVE_LEFT
         $curSlot -= 1
      Case $MOVE_RIGHT
         $curSlot += 1
   EndSwitch
EndFunc

Func canMoveUp(Const ByRef $curSlot)
   If ($curSlot > 2) Then
     Return True
   EndIf

   Return False
EndFunc

Func canMoveDown(Const ByRef $curSlot)
   If ($curSlot < 7) Then
     Return True
   EndIf

   Return False
EndFunc

Func canMoveRight(Const ByRef $curSlot)
   Local Const $retValue = _MathCheckDiv($curSlot, 2)

   Switch ($retValue)
   Case $MATH_ISDIVISIBLE
     If ($curSlot < 8) Then
       Return True
     EndIf
   EndSwitch

   Return False
EndFunc

Func canMoveLeft(Const ByRef $curSlot)
   Local Const $retValue = _MathCheckDiv($curSlot, 2)

   Switch ($retValue)
   Case $MATH_ISNOTDIVISIBLE
     If ($curSlot > 1) Then
       Return True
     EndIf
   EndSwitch

   Return False
EndFunc
Discord moderator
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)