StealthBot.net: oblivious - Viewing Profile

Jump to content

oblivious's Profile User Rating: -----

Group:
Members
Active Posts:
342 (0.09 per day)
Most Active In:
Scripting (200 posts)
Joined:
October-25 09
Profile Views:
1,033
Last Active:
User is offline Private
Currently:
Offline

Additional Information

Icon   oblivious has not set their status

Topics I've Started

  1. Clueless

    Posted 25 Oct 2010

    I'm currently getting this error:

    Quote

    [05:14:28 PM] Error (#438): Object doesn't support this property or method in GetScriptName().
    [05:14:28 PM] Error (438): Object doesn't support this property or method in LoadScripts().


    I've got no idea why it's happening. Well, that's not true. I think I know what's causing it. It has something to to with my include directive. If I comment it out, it goes way.

    The script I'm writing isn't complete yet so the following is what I've written so far (I test each individual part before I continue, it just makes things easier...)

    #include "\lib\Exception.
    txt"
    
    Option Explicit
    Script("Name") = "Card Games"
    Script("Author") = Script("Author") & ", CardGames written by Oblivious"
    Script("Description"
    ) = Script("Description"
    ) & ", CardGames handles the card games and commands"
    Script("Revision"
    ) = 0
    
    Private Sub Event_Load()
        Dim s_areCommands, s_commandsVersion
        s_areCommands = GetSettingsEntry("CommandsInstalled"
    )    
        s_commandsVersion = GetSettingsEntry("CommandsVersion"
    )
        If (s_areCommands = vbNullString) Then
            Call Output("Installing Commands")
            Call CreateScriptCommands()
        ElseIf (s_commandsVersion = vbNullString) Then
            Call DeleteScriptCommands()
            Call CreateScriptCommands()
        ElseIf (CInt(s_commandsVersion) <> Script("Revision"
    )) Then
                Call Output("Updating Commands")
                Call DeleteScriptCommands()
                Call CreateScriptCommands()
            End If
        End If
    End Sub
    
    Private Sub DeleteScriptCommands()
        Dim command
        Dim scr:scr = Scripts(Script("Name"
    ))
        For Each command In scr.GetCommands()
            Call scr.Deletecommand(command)
        Next    
    End Sub
    
    Private Sub CreateScriptCommands()
        Dim command, parameter
        Call WriteSettingsEntry("CommandsInstalled"
    , True)
        Call WriteSettingsEntry("CommandsVersion"
    , Script("Revision"
    ))
        Set command = OpenCommand("listgames"
    )
        If (command Is Nothing) Then
            'Command does not exist
            'Create command
            Set command = CreateCommand("listgames"
    )
            With command
                .RequiredRank = 10
                .Description = "Lists the current games in the CardGames system."
                .Save
            End With
        End If
        
        
        
    End Sub
    
    
    


    The code in exception.txt is the following, and it is in the path.

    Private Sub ThrowNewException(str)
        AddChat vbRed, StringFormat("[{0}]
     {1}", Script("Name"), str)
    End Sub
    
    Private Sub Output(str)
        AddChat vbCyan, StringFormat("[{0}]
     {1}", Script("Name"), str)
    End Sub
    


    The annoying thing is I can include this in another file, for example my priority queue (small) tester

    #include "\lib\SingleLink.
    txt"
    #include "\lib\PriorityQueue.
    txt"
    #include "\lib\Exception.
    txt"
    
    Option Explicit
    Script("Name") = "PQ Test"
    
    Private pq
    
    Sub Event_Load()
        
    End Sub
    
    Sub Event_PressedEnter(text)
        If (text = "pq") Then
                    ThrowNewException("Testing heap")
                    Dim i
                    Set pq = New PriorityQueue
                    Call pq.enqueue(0, 0)
                    Call pq.enqueue(4, 4)
                    Call pq.enqueue(2, 2)
                    Call pq.enqueue(7, 7)
                    Call pq.enqueue(1, 1)
                    Call pq.enqueue(3,3)
                    Call pq.enqueue(8,8)
                    Call pq.enqueue(5, 5)
                    Call pq.enqueue(9,9)
                    Call pq.enqueue(6,6)
                    AddChat vbRed, pq.examine()
                    For i = 0 To 9
                            Call Output(pq.dequeue())
                    Next
            End If
    End Sub
    


    Does anyone know why this error is occuring?
  2. VetoThisMessage()

    Posted 27 Jul 2010

    What does this function do?
    I've tried searching, it's in the Wiki but there isn't a page for it.

    Can anyone please explain what this function does?
  3. Priority Queue

    Posted 1 Jul 2010

    I've attached the priorityqueue.txt file, so if you need to use a priority queue, you can just go #include "\lib\PriorityQueue. txt" at the top of your script (see below too) and use the class.

    PriorityQueue
    ----------------------- -------------
    A Prioritised First-In, First-Out (FIFO) data structure.
    In order to use this, you must include the following files:
    #include "\lib\Exception.
    txt"
    

    ----------------------- -------------

    Construction
    Just like a normal vbscript class construction.
    Example:
    Set pq = New PriorityQueue
    


    Functions/Subs
    Public Function isEmpty
    Returns true if the queue is empty, false otherwise.
    Parameters:
    None

    Notes:
    None

    Example:
    If (q.isEmpty) Then AddChat vbRed, "Oops!"
    


    Public Function isElement(e)
    Returns true if the element is in the list, false otherwise.
    Parameters:
    e: This is the element you want to check is in the queue.

    Notes:
    Linear time

    Example:
    q.isElement(1)
    


    Public Function isElementStrict(priority, e)
    Returns true if the element with the priority is in the list, false otherwise.
    Parameters:
    priority: This is the priority of the element you want to check is in the queue.
    e: This is the element you want to check is in the queue.

    Notes:
    Linear time. If the same element is in the queue but does not have the same priority then this function will return false.

    Example:
    q.isElement(1)
    


    Public Function enqueue(priority, e)
    Enqueues an element into the queue, depending on the priority.
    Parameters:
    priority: This is the priority of the element you want to enqueue
    e: This is the element you want to enqueue

    Notes:
    Elements are sorted first by priority and then by chronological order. For example elements of the same priority are FIFO, and the elements with the highest priority are at the front of the queue.
    Linear time.

    Example:
    q.enqueue(1,
     1)
    q.enqueue(2,2)
    q.enqueue(4, 4)
    q.enqueue(3,3)
    

    This will result in a queue 4, 3, 2, 1.

    Public Function dequeue()
    Returns the first element in the queue and removes it from the queue.
    Parameters:
    None

    Notes:
    Constant time.

    Example:
    q.dequeue()
    


    Public Function examine()
    Returns the first item in the queue.
    Parameters:
    None

    Notes:
    Returns the highest priority element, constant time.

    Example:
    q.examine()
    
  4. Stack and Queues

    Posted 30 Jun 2010

    I've written another data structure, the stack, today. I also took out some of the things the queue had before (that I released) to make the code a little bit more abstract. If you want those features it's easy to implement in the script you write, just look at the other code. Both data structures do not care what elements you're inputting or taking out of the structures. They can either be objects, or not objects, or a mixture of both.

    I've also modularised the code a bit more, which requires you (if you're using them) to include a few files.

    I've attached all necessary files to this post.

    I've also written a nicer specification

    I would recommend you put the files in \lib\, or if you want, \lib\Oblivious\
    I don't mind.

    Queue
    ----------------------- -------------
    A First-In, First-Out (FIFO) data structure.
    In order to use this, you must include the following files:
    #include "\lib\SingleLink.
    txt"
    #include "\lib\Exception.
    txt"
    

    You might not have to include SingleLink.txt if you're only using QUEUE_BLOCK, but I haven't tried that.
    ----------------------- -------------

    Construction
    Unfortunately due to VBScript construction of the queue is a little weird, but straight forward
    Public Function NewQueue(qtype, size)
    Parameters:
    qtype: Accepts possible values QUEUE_BLOCK ( = 1) Or QUEUE_LINKED ( = 2)
    This parameter specifies the type of the queue you want to create.
    QUEUE_BLOCK creates a queue which is implemented via an array in a cyclic fashion. There is no memory erosion and the queue is bounded.
    QUEUE_LINKED creates a queue which is implemented via multiple links in a chain each link carrying an item and the reference to the next link. There is no memory erosion and the queue is not bounded.
    size: Accepts integer values greater than 0.
    If qtype == QUEUE_BLOCKED then this value is the maximum size of the queue.
    If qtype == QUEUE_LINKED then this value does not matter, but it must be specified because vbscript does not allow optional parameters.
    Notes:
    QUEUE_BLOCKED: It is also possible to construct your own QueueBlock directly using, where size > 0
    Set q = New QueueBlock
    q.initialise(size)
    
    

    Make sure size > 0. Note that it is initialise with an s.

    QUEUE_LINKED: It is also possible to construct your own QueueLinked directly using
    Set q = New QueueLinked
    
    

    Note that there is no initialise function because there is no maximum size. Creating a new linked version of a queue does not require any parameters so VBScript is suitable.
    I would recommend sticking to NewQueue, it makes things easier to remember.

    Example:
    Set q = NewQueue(QUEUE_LINKED, 0)
    Set q = NewQueue(QUEUE_BLOCK, 10)
    


    Common Functions/Subs
    Public Function isEmpty
    Returns true if the queue is empty, false otherwise.
    Parameters:
    None

    Notes:
    None

    Example:
    If (q.isEmpty) Then AddChat vbRed, "Oops!"
    


    Public Function isElement(e)
    Returns true if the element is in the list, false otherwise.
    Parameters:
    e: This is the element you want to check is in the queue.

    Notes:
    Linear time

    Example:
    q.isElement(1)
    


    Public Function enqueue(e)
    Enqueues an element into the queue.
    Parameters:
    e: This is the element you want to enqueue

    Notes:
    None

    Example:
    q.enqueue(1)
    


    Public Function dequeue()
    Returns the first element in the queue and removes it from the queue.
    Parameters:
    None

    Notes:
    None

    Example:
    q.dequeue()
    


    QUEUE_BLOCK specific functions/subs
    Public Function isFull()
    Returns true if the queue is full, false otherwise.
    Parameters:
    None

    Notes:
    None

    Example:
    q.isFull()
    


    Public Function examine(i)
    Returns the item at the corresponding index.
    Parameters:
    i: The index (from 0) of the item you want to examine. It cannot be greater than or equal to the current number of items in the queue.

    Notes:
    It does not remove the item from the queue. The adt takes care of the cyclic nature of the queue, the numbers are strictly in the range of 0 and count-1

    Example:
    q.examine(0)
    

    returns the first element in the queue


    Public Function swap(i, j)
    Rearranges items in the array.
    Parameters:
    i: The index of the first item you want to swap.
    j: The index of the second item you want to swap.

    Notes:
    i and j have the same restrictions as examine. Note that while i can equal j, there is no point. I was considering taking out this function, but the deck class I wrote earlier uses it. I will eventually write the list adt, and then I will update the queue and make the specifications equal.

    Example:
    q.swap(0,
     2)
    

    will swap the first and third item in the queue.


    Public Property Get Count
    Returns current number of items in the queue.
    Parameters:
    None

    Notes:
    This is actually a property. It is read-only.

    Example:
    q.count
    

    will return the current number of elements in the queue.


    QUEUE_LINKED specific functions/subs

    Public Function examine()
    Returns the first item in the queue.
    Parameters:
    None

    Notes:
    Unlike the QUEUE_BLOCK, you cannot extract a specific item. This is more like a real queue and less like a list.

    Example:
    q.examine()
    


    Stack
    ----------------------- -------------
    A Last-In, First-Out (LIFO) data structure.
    In order to use this, you must include the following files:
    #include "\lib\SingleLink.
    txt"
    #include "\lib\Exception.
    txt"
    

    You might not have to include SingleLink.txt if you're only using STACK_BLOCK, but I haven't tried that.
    ----------------------- -------------

    Construction
    Unfortunately due to VBScript construction of the queue is a little weird, but straight forward
    Public Function NewStack(stype, size)
    Parameters:
    stype: Accepts possible values STACK_BLOCK ( = 1) Or STACK_LINKED ( = 2)
    This parameter specifies the type of the queue you want to create.
    STACK_BLOCK creates a stack which is implemented via an array in a cyclic fashion. There is no memory erosion and the stack is bounded.
    STACK_LINKED creates a stack which is implemented via multiple links in a chain each link carrying an item and the reference to the next link. There is no memory erosion and the stack is not bounded.
    size: Accepts integer values greater than 0.
    If stype == STACK_BLOCKED then this value is the maximum size of the stack.
    If stype == STACK_LINKED then this value does not matter, but it must be specified because vbscript does not allow optional parameters.
    Notes:
    STACK_BLOCKED: It is also possible to construct your own StackBlock directly using, where size > 0
    Set s = New StackBlock
    s.initialise(size)
    
    

    Make sure size > 0. Note that it is initialise with an s.

    STACK_LINKED: It is also possible to construct your own StackLinked directly using
    Set s = New StackLinked
    
    

    Note that there is no initialise function because there is no maximum size. Creating a new linked version of a stack does not require any parameters so VBScript is suitable.
    I would recommend sticking to NewStack, it makes things easier to remember.

    Example:
    Set s = NewStack(STACK_LINKED, 0)
    Set s = NewStack(STACK_BLOCK, 10)
    


    Common Functions/Subs
    Public Function isEmpty
    Returns true if the stack is empty, false otherwise.
    Parameters:
    None

    Notes:
    None

    Example:
    If (s.isEmpty) Then AddChat vbRed, "Oops!"
    


    Public Function isElement(e)
    Returns true if the element is in the stack, false otherwise.
    Parameters:
    e: This is the element you want to check is in the stack.

    Notes:
    Linear time

    Example:
    s.isElement(1)
    


    Public Function push(e)
    Pushes an element onto the stack.
    Parameters:
    e: This is the element you want to push onto the stack.

    Notes:
    None

    Example:
    s.enqueue(1)
    


    Public Function pop()
    Returns the item on top of the stack and removes it from the stack
    Parameters:
    None

    Notes:
    None

    Example:
    s.pop()
    



    Public Function peek()
    Returns the item on top of the stack
    Parameters:
    None

    Notes:
    Unlike the QUEUE_BLOCK, you cannot extract a specific item in either implementation of the stack.

    Example:
    s.peek()
    


    STACK_BLOCK specific functions/subs
    Public Function isFull()
    Returns true if the queue is full, false otherwise.
    Parameters:
    None

    Notes:
    None

    Example:
    s.isFull()
    


    Public Property Get Count
    Returns current number of items in the queue.
    Parameters:
    None

    Notes:
    This is actually a property. It is read-only.

    Example:
    s.count
    

    will return the current number of elements in the queue.


    STACK_LINKED specific functions/subs
    None
  5. Card, Deck, and Hand Classes

    Posted 10 Jun 2010

    There seems to be quite a few requests for card games.

    Unfortunately it's exam time at the moment, I don't have much time to think about logic/get around the limitations of vbscript while porting from another language, I haven't been able to write a full game.

    These files are libraries you can use in order to create your own card game.

    The Deck.txt file also contains a very basic queue class (cyclic array) but I screwed up the modularity of it specifically for the deck... I will write a full ADT library later... maybe.

    The Card.txt file contains the Class for the individual cards. I don't think you ever have to worry about this class, but you must include it for the Deck.

    Card.txt Specification:

    Properties

    Suit
    -Sets/Gets the suit
    -Public Const enumeration provides Diamonds, Spades, Clubs, Hearts from 1 to 4 inclusive
    -Class arraySuits(0-3) (non-static zz) provides string representations (must -1 though, 1-4 -> 0-3).

    FaceVal
    -Sets/Gets the face value
    -Public Const enumeration provides Two... Jack, Queen, King, Ace, from 2 to 14 inclusive.
    -Class arrayValues(2-14) (non-static zz) provides string representations (do not need to -2). The bounds are actually 0 - 14 but 0 and 1 are null values

    isCardUp
    -Sets/Gets the (boolean) value, if the card is facing up or not

    Functions

    switchIsCardUp
    -switches value,
    -returns new value of isCardUp

    ToString
    -returns string representation
    -eg "The Nine of Spades"

    ToStringShort
    -returns shorter string representation
    -eg "9S"

    Equals(card)
    -Returns true if the card you're referencing equals the card supplied in the argument
    -false o/w


    Constructor

    NewCard(suit, value, isCardUp)
    -creates and returns a new card
    -eg 'Set card = NewCard(Spades, Nine, True)'
    -VBScript is lame, constructor is external (so it's a function outside of the class)


    Deck.txt

    Queue Class

    Constructor
    -Set q = New Queue
    -This one is internal, it just makes an empty queue of size 52. There is an option to increase this size but I haven't done that yet

    Properties

    list
    -returns the array

    position(at)
    -returns the item at the position from 0
    -eg position(5) returns the 6th item in the queue

    count
    -returns the number of items in the queue


    Functions

    isFull
    -returns True if the queue is full, false o/w

    isEmpty
    -returns True if the queue is empty, false o/w

    isElement(o)
    -returns True if o is in the queue, false o/w
    -linear time, unsorted queue

    enqueue(val)
    -puts val on the end of the queue
    -AddChats if the queue is full

    dequeue(val)
    -returns the first value and removes it from the queue
    -AddChats if the queue is empty

    Swap(i,j)
    -swaps the elements at the position i and position j


    Class Deck

    Properties

    isEmpty
    -as above
    -not sure why I made this a property

    Size
    -returns (current) size of deck
    -eg number of cards remaining

    position(at)
    -returns the card at the position 'at'.
    -0 is top of the deck


    Subs

    NewDeck
    -Enqueues a new deck, all cards, from 2D to AH
    -not a constructor

    Shuffle
    -shuffles the deck
    -n swaps on a reducing set


    Functions

    Draw
    -returns the card at the top of the deck and dequeues it


    Class Hand

    It's basically a mini deck

    Properties

    Cards
    -returns the queue

    Card(i)
    -card at position i

    NumCards
    -number of cards in the hand


    Subs

    Add(card)
    -enqueues the card

    Remove(i)
    -dequeues the (i+1)th card in the queue and returns it
    -upsets order if i > 0


    I apologise for the messy specs, I'm in a rush.

My Information

Member Title:
Full Member
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender

Contact Information

E-mail:
Private

Friends

Showing 50 random friends of 3

Comments

Page 1 of 1
  1. Photo

    Oliroh Icon

    Feb 01 2010 - 19:02
    Hey oblivius i have some questions..
    do you have MSN ? :p
Page 1 of 1