Jump to content

Pathfinding 'game'


Recommended Posts

Hi guys, i am trying to make a game: For example there are some radioboxes in some sequense. You choose the start and end location and the script must find the way from Start to End Location. I have no idea yet how to do this, if you can help me and advice me which functioins i have to use/learn to do this i will be gratefull here is an image of what i am trying to achieve:

Posted Image

Link to comment
Share on other sites

It will take an algorithm of sorts. the logic (in my head) would go like this.

Start at beginning, try a path, if back track occurs note step before backtrack and start over

You should be able to find the shortest path via something like that.

Link to comment
Share on other sites

Wow, you just gave me a great idea (to create an AutoIt script game inspired by this project)!

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiSlider.au3>

Dim $arrSliders[4][2]
$Form1 = GUICreate("Form1", 422, 291, 314, 242)
$arrSliders[0][0] = GUICtrlCreateSlider(112, 104, 38, 149, BitOR($TBS_VERT,$TBS_BOTH))
GUICtrlSetData(-1,100)
$arrSliders[1][0] = GUICtrlCreateSlider(186, 105, 38, 149, BitOR($TBS_VERT,$TBS_BOTH))
GUICtrlSetData(-1,100)
$arrSliders[2][0] = GUICtrlCreateSlider(264, 105, 38, 149, BitOR($TBS_VERT,$TBS_BOTH))
GUICtrlSetData(-1,100)
$arrSliders[3][0] = GUICtrlCreateSlider(343, 105, 38, 149, BitOR($TBS_VERT,$TBS_BOTH))
GUICtrlSetData(-1,100)
$LevelSelect = GUICtrlCreateInput("0", 36, 230, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY))
$UpDown = GUICtrlCreateUpdown($LevelSelect)
GUICtrlSetLimit(-1,10,0)
$Reset = GUICtrlCreateButton("Reset", 24, 160, 67, 41)
GUICtrlCreateLabel("0", 129, 252, 10, 17)
GUICtrlCreateLabel("0", 202, 252, 10, 17)
GUICtrlCreateLabel("0", 360, 252, 10, 17)
GUICtrlCreateLabel("0", 281, 252, 10, 17)
GUICtrlCreateLabel("1", 129, 84, 10, 17)
GUICtrlCreateLabel("1", 202, 84, 10, 17)
GUICtrlCreateLabel("1", 281, 84, 10, 17)
GUICtrlCreateLabel("1", 360, 84, 10, 17)
GUICtrlCreateLabel("4-bit Puzzle", 144, 16, 140, 33)
GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif")

GUIRegisterMsg($WM_VSCROLL, "WM_Slider")
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Reset
            _SlideUp($arrSliders)
            _SlideDown($arrSliders)
    EndSwitch
WEnd

Func _SlideUp($hwnd)
    If IsArray($hwnd) Then
        For $x = 0 to UBound($hwnd)-1
            $hwnd[$x][1] = 100-_GUICtrlSlider_GetPos($hwnd[$x][0])
        Next
        For $pos = 1 to 100
            For $x = 0 to UBound($hwnd)-1
                _GUICtrlSlider_SetPos($hwnd[$x][0],(100-_ExpoEaseInOut($pos, $hwnd[$x][1], 101, 100)))
            Next
            $timer = TimerInit()
            While TimerDiff($timer) < 10
            Wend
            $timer = 0
        Next
    Else
        $start = 100-_GUICtrlSlider_GetPos($hwnd)
        For $pos = 1 to 100
            _GUICtrlSlider_SetPos($hwnd,(100-_ExpoEaseInOut($pos, $start, 101, 100)))
            $timer = TimerInit()
            While TimerDiff($timer) < 10
            Wend
            $timer = 0
        Next
    EndIf
EndFunc

Func _SlideDown($hwnd)
    If IsArray($hwnd) Then
        For $x = 0 to UBound($hwnd)-1
            $hwnd[$x][1] = _GUICtrlSlider_GetPos($hwnd[$x][0])
        Next
        For $pos = 1 to 100
            For $x = 0 to UBound($hwnd)-1
                _GUICtrlSlider_SetPos($hwnd[$x][0],(_ExpoEaseInOut($pos, $hwnd[$x][1], 101, 100)))
            Next
            $timer = TimerInit()
            While TimerDiff($timer) < 10
            Wend
            $timer = 0
        Next
    Else
        $start = _GUICtrlSlider_GetPos($hwnd)
        For $pos = 1 to 100
            _GUICtrlSlider_SetPos($hwnd,(_ExpoEaseInOut($pos, $start, 101, 100)))
            $timer = TimerInit()
            While TimerDiff($timer) < 10
            Wend
            $timer = 0
        Next
    EndIf
EndFunc

Func WM_Slider($hWnd, $iMsg, $wParam, $lParam)
    ;If $lParam = GUICtrlGetHandle($Slider1) Then
        ConsoleWrite($wParam & ":" & $lParam & ":" & _GUICtrlSlider_GetPos($lParam) & @CRLF)
    ;EndIf
    ;Return $GUI_RUNDEFMSG
EndFunc

Func _ExpoEaseInOut($iFrame, $iStartValue, $iInterval, $iEndValue) ;Credit to Josh Rowe - http://autoitscript.com/forum/topic/102851-transitions-udf/
    $iFrame = $iFrame / ($iEndValue / 2)
    If $iFrame < 1 Then
        Return $iInterval / 2 * (2 ^ (10 * ($iFrame - 1))) + $iStartValue
    EndIf

    $iFrame = $iFrame - 1
    Return $iInterval / 2 * (-(2 ^ (-10 * $iFrame)) + 2) + $iStartValue
EndFunc   ;==>_ExpoEaseInOut

One would usually provide a hint as to what this code is supposed to be, do etc...

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

One would usually provide a hint as to what this code is supposed to be, do etc...

It seemed fairly obvious to me if you look at the link and the spoiler

edit: the code in the spoiler is incomplete, but if you watched the video in the link I'm pretty sure you can guess what it, "is supposed to be".

edit: sorry for the hijack Dangerous

Edited by spudw2k
Link to comment
Share on other sites

I could understand not going out of your way to/or wasting time watching random videos, but when a video answers a question and you refuse to watch it seems to me that you are doing yourself an injustice.

Why comment on something if you don't want to hear the answer?

No offense.

Edited by spudw2k
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...