annuncio

Comprimi
Ancora nessun annuncio.

[EASYUO HELP]need help from advanced scripers

Comprimi
X
 
  • Filtro
  • Ora
  • Visualizza
Elimina tutto
nuovi messaggi

  • [EASYUO HELP]need help from advanced scripers

    have anybody tried to write recursive round of tree in easyuo? :/ just need an idea how to make recursive sub and actualy tree in easyuo.
    i want to make a dessicion-tree for rail-runing

  • #2
    what i v got now. not so elegant
    any ideas how to make it elegant?

    codice:
    sub ExitRoom
        set %RoomNumber %1
        set %RailPointsQ 0
    
        set %RailIsBuilt #false
        set %NextNod 1
        repeat
              set %CurrentNod %NextNod
              gosub ExitRoomMakeDecision %CurrentNod
        until %RailIsBuilt
    
    return
    
    sub ExitRoomMakeDecision
    
                            set %Mat %RoomNumber , CondEq , %CurrentNod
        set %exitRoomCondEq  %exitRoom . %Mat
                             set %Mat %RoomNumber , CondFac , %CurrentNod
        set %exitRoomCondFac %exitRoom . %Mat
                             set %Mat %RoomNumber , CondVal , %CurrentNod
        set %exitRoomCondVal %exitRoom . %Mat
                             set %Mat %RoomNumber , CondPX , %CurrentNod
        set %exitRoomCondPX %exitRoom . %Mat
                            set %Mat %RoomNumber , CondPY , %CurrentNod
        set %exitRoomCondPY %exitRoom . %Mat
                            set %Mat %RoomNumber , CondThan , %CurrentNod
        set %exitRoomCondThan %exitRoom . %Mat
                              set %Mat %RoomNumber , CondElse , %CurrentNod
        set %exitRoomCondElse %exitRoom . %Mat
        
        pause
        
        if %exitRoomCondFac = x
           set %exitRoomCondFac #charposx
        if %exitRoomCondFac = y
           set %exitRoomCondFac #charposy
           
        if %exitRoomCondFac %exitRoomCondEq %exitRoomCondVal
        {
           if %exitRoomCondPX <> no
           {
              set %RailPointsQ %RailPointsQ + 1
              set %RailPointsX . %RailPointsQ %exitRoomCondPX
              set %RailPointsY . %RailPointsQ %exitRoomCondPY
           }
           set %NextNod %exitRoomCondThan
        
        }
        else
        {
            set %NextNod %exitRoomCondElse
        }
        if %NextNod = 0
           set %RailIsBuilt #true
    
    return
    
    sub InitVars
    
        set %exitRoom1CondEq1 <=
        set %exitRoom1CondFac1 y
        set %exitRoom1CondVal1 432
        set %exitRoom1CondPX1 474
        set %exitRoom1CondPY1 432
        set %exitRoom1CondThan1 2
        set %exitRoom1CondElse1 3
        
        set %exitRoom1CondEq2 <=
        set %exitRoom1CondFac2 x
        set %exitRoom1CondVal2 477
        set %exitRoom1CondPX2 no
        set %exitRoom1CondPY2 no
        set %exitRoom1CondThan2 0
        set %exitRoom1CondElse2 3
        
        set %exitRoom1CondEq3 >
        set %exitRoom1CondFac3 x
        set %exitRoom1CondVal3 477
        set %exitRoom1CondPX3 477
        set %exitRoom1CondPY3 432
        set %exitRoom1CondThan3 0
        set %exitRoom1CondElse3 0

    Commenta


    • #3
      can't figure out what you're talking about.

      what is a "recursive round of tree"? are you talking about an AI decision tree?
      why are you calling ExitRoomMakeDecision with an argument if you never read it inside the sub?
      when do you call InitVars and why you never return from it?
      why is that "pause" there? (mixing debug code with plain code?)

      Really... there's no way we can help you if you don't give us better explanations...

      Commenta


      • #4
        Originariamente inviato da kusanagi97 Visualizza il messaggio
        what is a "recursive round of tree"?
        recursive is recuresive.

        sub a
        gosub a
        return

        tree is a tree.
        there's array a1 a2 a3 a4. there s tree a1 a11 a10 a111 etc
        recursive round of tree is calling recursive sub recursively to go througth all nods of a tree )

        Originariamente inviato da kusanagi97 Visualizza il messaggio
        why are you calling ExitRoomMakeDecision with an argument if you never read it inside the sub?
        because it's draft

        Originariamente inviato da kusanagi97 Visualizza il messaggio
        when do you call InitVars and why you never return from it?
        in posted part of the script never.

        Originariamente inviato da kusanagi97 Visualizza il messaggio
        Really... there's no way we can help you if you don't give us better explanations...
        we? Imperor Napoleon?
        explanation for u Recursion (computer science) - Wikipedia, the free encyclopedia

        Commenta


        • #5
          all that i have for now

          codice:
          gosub Init
          while #true
          {
                ;wait 20
                gosub GetCurrentRoom
                if #result <> #false
                   gosub ExitRoom #result
                else
                {
                 event exmsg #charid 0 0 ERROR not in room
                 pause
                }
                halt
          }
          
          
          sub GetCurrentRoom
              set %CurrentRoomNumber #false
              for %iR 1 5
              {
                  set %RoomConditions 0
                  if #charposx >= %RoomCornersxmin . %iR
                     set %RoomConditions %RoomConditions + 1
                  if #charposx <= %RoomCornersxmax . %iR
                     set %RoomConditions %RoomConditions + 1
                  if #charposy >= %RoomCornersymin . %iR
                     set %RoomConditions %RoomConditions + 1
                  if #charposy <= %RoomCornersymax . %iR
                     set %RoomConditions %RoomConditions + 1
                  if %RoomConditions = 4
                  {
                     set %CurrentRoomNumber %iR
                     break
                  }
              }
          return %CurrentRoomNumber
          
          sub RunRail
          return
          
          sub InitMenu
          return
          
          sub Init
              set #lpc 1000
              gosub InitVars
          return
          
          sub ExitRoom
              set %RoomNumber %1
              set %RailPointsQ 0
          
              set %RailIsBuilt #false
              set %NextNod 1
              repeat
                    set %CurrentNod %NextNod
                    event exmsg #charid 0 0 %CurrentNod
                    ;pause
                    gosub ExitRoomMakeDecision %CurrentNod
              until %RailIsBuilt
              
              if %RailPointsQ = 0
              {
                 event exmsg #charid 0 0 ERROR 0 rail points
                 pause
              }
                 
              for %iMoveP %RailPointsQ 1
              {
                  set %MoveX %RailPointsX . %iMoveP
                  set %MoveY %RailPointsY . %iMoveP
                  gosub MoveTo %MoveX %MoveY
                  if ! #result
                  {
                     event exmsg #charid 0 0 ERROR sub Moveto
                     pause
                  }
          
              }
              
          
          return
          
          Sub MoveTo
              set %PathfindTimeOut #systime + 15000
              set %nextpathfind #systime
              while ( #charposx <> %1 || #charposy <> %2 ) && #systime <= %PathfindTimeOut
              {
                    if #systime >= %nextpathfind
                    {
                       event pathfind %1 %2 #charposz
                       set %nextpathfind #systime + 2000
                    }
                    sleep 10
              }
              if #systime > %PathfindTimeOut
                 return #false
          return #true
          
          sub ExitRoomMakeDecision
          
                                  set %Mat %RoomNumber , CondEq , %CurrentNod
              set %exitRoomCondEq  %exitRoom . %Mat
                                   set %Mat %RoomNumber , CondFac , %CurrentNod
              set %exitRoomCondFac %exitRoom . %Mat
                                   set %Mat %RoomNumber , CondVal , %CurrentNod
              set %exitRoomCondVal %exitRoom . %Mat
          
          
                                  set %Mat %RoomNumber , CondPY , %CurrentNod
              set %exitRoomCondPY %exitRoom . %Mat
                                  set %Mat %RoomNumber , CondThan , %CurrentNod
              set %exitRoomCondThan %exitRoom . %Mat
                                    set %Mat %RoomNumber , CondElse , %CurrentNod
              set %exitRoomCondElse %exitRoom . %Mat
              
              
              if %exitRoomCondFac = x
                 set %exitRoomCondFac #charposx
              if %exitRoomCondFac = y
                 set %exitRoomCondFac #charposy
                 
              if %exitRoomCondFac %exitRoomCondEq %exitRoomCondVal
              {
                                   set %Mat %RoomNumber , CondTX , %CurrentNod
                 set %exitRoomCondTX %exitRoom . %Mat
              
                 if %exitRoomCondTX <> no
                 {
                 
                                   set %Mat %RoomNumber , CondTY , %CurrentNod
                    set %exitRoomCondTY %exitRoom . %Mat
          
                    set %RailPointsQ %RailPointsQ + 1
                    set %RailPointsX . %RailPointsQ %exitRoomCondTX
                    set %RailPointsY . %RailPointsQ %exitRoomCondTY
                 }
                 set %NextNod %exitRoomCondThan
              
              }
              else
              {
                                   set %Mat %RoomNumber , CondFX , %CurrentNod
                 set %exitRoomCondFX %exitRoom . %Mat
          
                 if %exitRoomCondFX <> no
                 {
          
                                   set %Mat %RoomNumber , CondFY , %CurrentNod
                    set %exitRoomCondFY %exitRoom . %Mat
          
                    set %RailPointsQ %RailPointsQ + 1
                    set %RailPointsX . %RailPointsQ %exitRoomCondFX
                    set %RailPointsY . %RailPointsQ %exitRoomCondFY
                 }
                  set %NextNod %exitRoomCondElse
              }
              if %NextNod = 0
                 set %RailIsBuilt #true
          
          return
          
          sub InitVars
          
              set %exitRoom1CondFac1 y
              set %exitRoom1CondEq1 <=
              set %exitRoom1CondVal1 432
              set %exitRoom1CondTX1 474
              set %exitRoom1CondTY1 432
              set %exitRoom1CondFX1 474
              set %exitRoom1CondFY1 433
              set %exitRoom1CondThan1 3
              set %exitRoom1CondElse1 2
          
              set %exitRoom1CondFac3 x
              set %exitRoom1CondEq3 <
              set %exitRoom1CondVal3 478
              set %exitRoom1CondTX3 no
              set %exitRoom1CondTY3 no
              set %exitRoom1CondFX3 no
              set %exitRoom1CondFY3 no
              set %exitRoom1CondThan3 0
              set %exitRoom1CondElse3 6
              
              set %exitRoom1CondFac6 y
              set %exitRoom1CondEq6 <=
              set %exitRoom1CondVal6 428
              set %exitRoom1CondTX6 no
              set %exitRoom1CondTY6 no
              set %exitRoom1CondFX6 no
              set %exitRoom1CondFY6 no
              set %exitRoom1CondThan6 13
              set %exitRoom1CondElse6 12
              
              set %exitRoom1CondFac12 x
              set %exitRoom1CondEq12 >
              set %exitRoom1CondVal12 488
              set %exitRoom1CondTX12 488
              set %exitRoom1CondTY12 432
              set %exitRoom1CondFX12 no
              set %exitRoom1CondFY12 no
              set %exitRoom1CondThan12 0
              set %exitRoom1CondElse12 0
              
              set %exitRoom1CondFac13 x
              set %exitRoom1CondEq13 >
              set %exitRoom1CondVal13 488
              set %exitRoom1CondTX13 488
              set %exitRoom1CondTY13 428
              set %exitRoom1CondFX13 no
              set %exitRoom1CondFY13 no
              set %exitRoom1CondThan13 0
              set %exitRoom1CondElse13 0
              
              set %exitRoom1CondFac2 x
              set %exitRoom1CondEq2 <
              set %exitRoom1CondVal2 480
              set %exitRoom1CondTX2 no
              set %exitRoom1CondTY2 no
              set %exitRoom1CondFX2 no
              set %exitRoom1CondFY2 no
              set %exitRoom1CondThan2 5
              set %exitRoom1CondElse2 10
              
              set %exitRoom1CondFac5 y
              set %exitRoom1CondEq5 >=
              set %exitRoom1CondVal5 447
              set %exitRoom1CondTX5 480
              set %exitRoom1CondTY5 446
              set %exitRoom1CondFX5 no
              set %exitRoom1CondFY5 no
              set %exitRoom1CondThan5 0
              set %exitRoom1CondElse5 0
              
              set %exitRoom1CondFac10 x
              set %exitRoom1CondEq10 >
              set %exitRoom1CondVal10 488
              set %exitRoom1CondTX10 no
              set %exitRoom1CondTY10 no
              set %exitRoom1CondFX10 no
              set %exitRoom1CondFY10 no
              set %exitRoom1CondThan10 21
              set %exitRoom1CondElse10 20
          
              set %exitRoom1CondFac20 y
              set %exitRoom1CondEq20 >
              set %exitRoom1CondVal20 447
              set %exitRoom1CondTX20 480 ;480
              set %exitRoom1CondTY20 437 ;446
              set %exitRoom1CondFX20 no
              set %exitRoom1CondFY20 no
              set %exitRoom1CondThan20 0
              set %exitRoom1CondElse20 0
              
              set %exitRoom1CondFac21 y
              set %exitRoom1CondEq21 <
              set %exitRoom1CondVal21 438
              set %exitRoom1CondTX21 488
              set %exitRoom1CondTY21 433
              set %exitRoom1CondFX21 no
              set %exitRoom1CondFY21 no
              set %exitRoom1CondThan21 0
              set %exitRoom1CondElse21 42
              
              set %exitRoom1CondFac42 y
              set %exitRoom1CondEq42 <
              set %exitRoom1CondVal42 447
              set %exitRoom1CondTX42 488
              set %exitRoom1CondTY42 438
              set %exitRoom1CondFX42 488
              set %exitRoom1CondFY42 447
              set %exitRoom1CondThan42 0
              set %exitRoom1CondElse42 0
              
              set %RoomCornersxmin1 474
              set %RoomCornersymin1 413
              set %RoomCornersxmax1 509
              set %RoomCornersymax1 469
              
              set %RoomCornersxmin2 454
              set %RoomCornersymin2 497
              set %RoomCornersxmax2 500
              set %RoomCornersymax2 540
          
              set %RoomCornersxmin3 380
              set %RoomCornersymin3 505
              set %RoomCornersxmax3 435
              set %RoomCornersymax3 550
              
              set %RoomCornersxmin4 303
              set %RoomCornersymin4 479
              set %RoomCornersxmax4 380
              set %RoomCornersymax4 537
          
              set %RoomCornersxmin5 303
              set %RoomCornersymin5 410
              set %RoomCornersxmax5 359
              set %RoomCornersymax5 459
          
          return
          importnant note to avoid strange questions: there s no recursion now and this is the only reason why this thread was ever created )

          Commenta


          • #6
            I look for you on icq.

            btw, easy uo dont have scoping of vars, so every time u access a var in a sub, u edit the unique var of ur script, to made a scoping u can use scope of easyuo,every time u call a sub u alloc a scope and claim when u come back, is this ur problem? sorry but my english today is on holiday.
            Lista dei Punti di Xorina
            icq 112740352

            Commenta


            • #7
              Originariamente inviato da Lord_Of_Cove Visualizza il messaggio
              I look for you on icq.

              btw, easy uo dont have scoping of vars, so every time u access a var in a sub, u edit the unique var of ur script, to made a scoping u can use scope of easyuo,every time u call a sub u alloc a scope and claim when u come back, is this ur problem? sorry but my english today is on holiday.
              it looks this now. no idea if it works correctly )

              codice:
              gosub Init
              
                    gosub GetCurrentRoom
                    if #result <> #false
                       gosub ExitRoom #result 1
                    halt
              
              sub ExitRoom
              ;1 - room, 2 - node
                 namespace push
                 namespace local ExitRoom , #systime , #random
                 set !RoomNumber %1
                 set !CurrentNod %2
                 
                                      set %Mat !RoomNumber , CondEq , !CurrentNod
                  set !exitRoomCondEq  %exitRoom . %Mat
                                       set %Mat !RoomNumber , CondFac , !CurrentNod
                  set !exitRoomCondFac %exitRoom . %Mat
                                       set %Mat !RoomNumber , CondVal , !CurrentNod
                  set !exitRoomCondVal %exitRoom . %Mat
              
              
                  if !exitRoomCondFac = x
                     set !exitRoomCondFac #charposx
                  if !exitRoomCondFac = y
                     set !exitRoomCondFac #charposy
              
                  if !exitRoomCondFac !exitRoomCondEq !exitRoomCondVal
                  {
                                             set %Mat !RoomNumber , CondThan , !CurrentNod
                     set !exitRoomCondDo %exitRoom . %Mat
                                       set %Mat !RoomNumber , CondTX , !CurrentNod
                     set !exitRoomCondX %exitRoom . %Mat
                     if !exitRoomCondX <> no
                     {
                                       set %Mat !RoomNumber , CondTY , !CurrentNod
                        set !exitRoomCondY %exitRoom . %Mat
                     }
                  }
                  else
                  {
                                        set %Mat !RoomNumber , CondElse , !CurrentNod
                      set !exitRoomCondDo %exitRoom . %Mat
                                       set %Mat %RoomNumber , CondFX , !CurrentNod
                     set !exitRoomCondX %exitRoom . %Mat
                     if !exitRoomCondX <> no
                     {
                                       set %Mat !RoomNumber , CondFY , !CurrentNod
                        set !exitRoomCondY %exitRoom . %Mat
                     }
                  }
              
                  if !exitRoomCondDo <> 0
                     gosub ExitRoom !RoomNumber !exitRoomCondDo
                  if !exitRoomCondX <> no
                     gosub MoveTo !exitRoomCondX !exitRoomCondY
                     
                  namespace clear
                  namespace pop
              return
              
              Sub MoveTo
                  set %PathfindTimeOut #systime + 15000
                  set %nextpathfind #systime
                  while ( #charposx <> %1 || #charposy <> %2 ) && #systime <= %PathfindTimeOut
                  {
                        if #systime >= %nextpathfind
                        {
                           event pathfind %1 %2 #charposz
                           set %nextpathfind #systime + 2000
                        }
                        sleep 10
                  }
                  if #systime > %PathfindTimeOut
                     return #false
              return #true
              
              sub GetCurrentRoom
                  set %CurrentRoomNumber #false
                  for %iR 1 5
                  {
                      set %RoomConditions 0
                      if #charposx >= %RoomCornersxmin . %iR
                         set %RoomConditions %RoomConditions + 1
                      if #charposx <= %RoomCornersxmax . %iR
                         set %RoomConditions %RoomConditions + 1
                      if #charposy >= %RoomCornersymin . %iR
                         set %RoomConditions %RoomConditions + 1
                      if #charposy <= %RoomCornersymax . %iR
                         set %RoomConditions %RoomConditions + 1
                      if %RoomConditions = 4
                      {
                         set %CurrentRoomNumber %iR
                         break
                      }
                  }
              return %CurrentRoomNumber
              
              sub InitVars
              
                  set %exitRoom1CondFac1 y
                  set %exitRoom1CondEq1 <=
                  set %exitRoom1CondVal1 432
                  set %exitRoom1CondTX1 474
                  set %exitRoom1CondTY1 432
                  set %exitRoom1CondFX1 474
                  set %exitRoom1CondFY1 433
                  set %exitRoom1CondThan1 3
                  set %exitRoom1CondElse1 2
              
                  set %exitRoom1CondFac3 x
                  set %exitRoom1CondEq3 <
                  set %exitRoom1CondVal3 478
                  set %exitRoom1CondTX3 no
                  set %exitRoom1CondTY3 no
                  set %exitRoom1CondFX3 no
                  set %exitRoom1CondFY3 no
                  set %exitRoom1CondThan3 0
                  set %exitRoom1CondElse3 6
              
                  set %exitRoom1CondFac6 y
                  set %exitRoom1CondEq6 <=
                  set %exitRoom1CondVal6 428
                  set %exitRoom1CondTX6 no
                  set %exitRoom1CondTY6 no
                  set %exitRoom1CondFX6 no
                  set %exitRoom1CondFY6 no
                  set %exitRoom1CondThan6 13
                  set %exitRoom1CondElse6 12
              
                  set %exitRoom1CondFac12 x
                  set %exitRoom1CondEq12 >
                  set %exitRoom1CondVal12 488
                  set %exitRoom1CondTX12 488
                  set %exitRoom1CondTY12 432
                  set %exitRoom1CondFX12 no
                  set %exitRoom1CondFY12 no
                  set %exitRoom1CondThan12 0
                  set %exitRoom1CondElse12 0
              
                  set %exitRoom1CondFac13 x
                  set %exitRoom1CondEq13 >
                  set %exitRoom1CondVal13 488
                  set %exitRoom1CondTX13 488
                  set %exitRoom1CondTY13 428
                  set %exitRoom1CondFX13 no
                  set %exitRoom1CondFY13 no
                  set %exitRoom1CondThan13 0
                  set %exitRoom1CondElse13 0
              
                  set %exitRoom1CondFac2 x
                  set %exitRoom1CondEq2 <
                  set %exitRoom1CondVal2 480
                  set %exitRoom1CondTX2 no
                  set %exitRoom1CondTY2 no
                  set %exitRoom1CondFX2 no
                  set %exitRoom1CondFY2 no
                  set %exitRoom1CondThan2 5
                  set %exitRoom1CondElse2 10
              
                  set %exitRoom1CondFac5 y
                  set %exitRoom1CondEq5 >=
                  set %exitRoom1CondVal5 447
                  set %exitRoom1CondTX5 480
                  set %exitRoom1CondTY5 446
                  set %exitRoom1CondFX5 no
                  set %exitRoom1CondFY5 no
                  set %exitRoom1CondThan5 0
                  set %exitRoom1CondElse5 0
              
                  set %exitRoom1CondFac10 x
                  set %exitRoom1CondEq10 >
                  set %exitRoom1CondVal10 488
                  set %exitRoom1CondTX10 no
                  set %exitRoom1CondTY10 no
                  set %exitRoom1CondFX10 no
                  set %exitRoom1CondFY10 no
                  set %exitRoom1CondThan10 21
                  set %exitRoom1CondElse10 20
              
                  set %exitRoom1CondFac20 y
                  set %exitRoom1CondEq20 >
                  set %exitRoom1CondVal20 447
                  set %exitRoom1CondTX20 480 ;480
                  set %exitRoom1CondTY20 437 ;446
                  set %exitRoom1CondFX20 no
                  set %exitRoom1CondFY20 no
                  set %exitRoom1CondThan20 0
                  set %exitRoom1CondElse20 0
              
                  set %exitRoom1CondFac21 y
                  set %exitRoom1CondEq21 <
                  set %exitRoom1CondVal21 438
                  set %exitRoom1CondTX21 488
                  set %exitRoom1CondTY21 433
                  set %exitRoom1CondFX21 no
                  set %exitRoom1CondFY21 no
                  set %exitRoom1CondThan21 0
                  set %exitRoom1CondElse21 42
              
                  set %exitRoom1CondFac42 y
                  set %exitRoom1CondEq42 <
                  set %exitRoom1CondVal42 447
                  set %exitRoom1CondTX42 488
                  set %exitRoom1CondTY42 438
                  set %exitRoom1CondFX42 488
                  set %exitRoom1CondFY42 447
                  set %exitRoom1CondThan42 0
                  set %exitRoom1CondElse42 0
              
                  set %RoomCornersxmin1 474
                  set %RoomCornersymin1 413
                  set %RoomCornersxmax1 509
                  set %RoomCornersymax1 469
              
                  set %RoomCornersxmin2 454
                  set %RoomCornersymin2 497
                  set %RoomCornersxmax2 500
                  set %RoomCornersymax2 540
              
                  set %RoomCornersxmin3 380
                  set %RoomCornersymin3 505
                  set %RoomCornersxmax3 435
                  set %RoomCornersymax3 550
              
                  set %RoomCornersxmin4 303
                  set %RoomCornersymin4 479
                  set %RoomCornersxmax4 380
                  set %RoomCornersymax4 537
              
                  set %RoomCornersxmin5 303
                  set %RoomCornersymin5 410
                  set %RoomCornersxmax5 359
                  set %RoomCornersymax5 459
              
              return

              Commenta

              Sto operando...
              X