Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with an Othello (AKA Reversi) Game
#5
I played a few more game with the AI (with the loop disabled), and it only tried to make illegal moves in some games, and apparantly, the Out of Stack error was fixed when I put in the mouse and removed the on key gosub commands Smile . Sorry about that :oops: . However, the out of memory error still occurs, even if I just hit F5 and then, before I even move the mouse, hit Ctrl+Scroll. This makes me think it has something to do with the way I have it polling the mouse, or something like that. This is the code that it is running when I stop it:
Code:
SUB AskAI

...

        PRINT TAB(26); "************   *************"
        PRINT TAB(26); "* New Game *   * Load Game *"
        PRINT TAB(26); "************   *************"
        PRINT
        ik$ = ""
        WHILE ik$ = ""
                CALL MousePoll(MRow, MCol, MlButton, MrButton)
                IF MRow > 11 AND MRow < 15 AND MlButton THEN
                        IF MCol > 27 AND MCol < 39 THEN ik$ = "n"
                        IF MCol > 41 AND MCol < 53 THEN ik$ = "l"
                END IF
        WEND

...

END SUB



SUB MousePoll (MouseRow, MouseCol, lButton, rButton) STATIC

    ' =======================================================================
    ' Polls mouse driver, then sets parms correctly
    ' =======================================================================

    MouseDriver 3, button, MouseCol, MouseRow
    MouseRow = MouseRow / 8 + 1
    MouseCol = MouseCol / 8 + 1
                        
    IF button AND 1 THEN
        lButton = TRUE
    ELSE
        lButton = FALSE
    END IF

    IF button AND 2 THEN
        rButton = TRUE
    ELSE
        rButton = FALSE
    END IF

END SUB



SUB MouseDriver (m0, m1, m2, m3) STATIC

    DIM regs AS RegType

    IF MouseChecked = FALSE THEN
        DEF SEG = 0

        MouseSegment& = 256& * PEEK(207) + PEEK(206)
        MouseOffset& = 256& * PEEK(205) + PEEK(204)

        DEF SEG = MouseSegment&

        IF (MouseSegment& = 0 AND MouseOffset& = 0) OR PEEK(MouseOffset&) = 207 THEN
            MousePresent = FALSE
            MouseChecked = TRUE
            DEF SEG
        END IF
    END IF

    IF MousePresent = FALSE AND MouseChecked = TRUE THEN
        EXIT SUB
    END IF

    ' =======================================================================
    ' Calls interrupt 51 to invoke mouse functions in the MS Mouse Driver.
    ' =======================================================================
    
    regs.ax = m0
    regs.bx = m1
    regs.cx = m2
    regs.dx = m3

    Interrupt 51, regs, regs

    m0 = regs.ax
    m1 = regs.bx
    m2 = regs.cx
    m3 = regs.dx

    IF MouseChecked THEN EXIT SUB

    ' =======================================================================
    ' Check for successful mouse initialization
    ' =======================================================================

    IF m0 AND NOT MouseChecked THEN
        MousePresent = TRUE
        DEF SEG
    END IF

    MouseChecked = TRUE
    
END SUB

BTW, I did not write the code for the mouse; it was from mouse.bas, which came as a tutorial/example with qb when I downloaded it. I only wrote the first of the three subs shown in this post.
Reply


Messages In This Thread
Help with an Othello (AKA Reversi) Game - by Z!re - 08-03-2005, 03:39 AM
Help with an Othello (AKA Reversi) Game - by JasonSG - 08-03-2005, 07:18 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)