Results 1 to 6 of 6

Thread: Hard question about AI

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Hi.

    Imagine a blue screen... A ball bouncing back and
    forth across the screen. The ball to your eyes doesnt
    have the same color as the back round.. you can see it perfectly.

    Now for a little information. This ball is not in my program. Its in another window just being drawn on.

    Q: Say your hand isnt on the mouse. And you want to make a program that directs the cursor to follow the ball around. So where ever the ball goes... The cursor would be in the middle of the ball.

    How would you do this?

  2. #2
    Member Visual Programmer's Avatar
    Join Date
    Dec 2000
    Posts
    59
    hi, This isn't called AI its called 'moving the mouse'
    try this link:

    http://www.vb-world.net/mouse/tip15.html
    VP/Sonic taking on the (vb) world, one post at a time.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Noooo.

    I want to have the program FOLLOW the
    ball. (Like it needs to find the color change and
    then find the middle and then put the mouse in it)

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Use the api GetPixel in a loop to catch color change in the ball. Once you place your cursor at the centre of the ball initially, constantly check for the movement of hte ball by checking co-ordintes which are a few pixel away from the perimeter of the ball. Tis will tell us the directon in which the ball is goimg. Move your cursor accordingly ot keep in the centre of the ball

  5. #5
    Guest
    Use the SetCursorPos function in a Timer, so that it updates regularly.
    Code:
    Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long
    
    Private Sub Timer1_Timer()
       SetCursorPos (BallWidth / 2) + Me.Width, (BallHeight / 2) + Me.Height
    End Sub

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Optimal scan

    If you start searching for the ball, and it's small, it might take time. But if you go trough the screen in more detail everytime you do the scan, you could find the ball very fast.

    Have 3 nested loops, in innermost for x axis, second for y and third for resolution. Both inner loops should start from resolution\2 and resolution should start with the smaller from screen width/height divided by 2. The inner loops should be for next type and step trough resolution and the other one should be a do while resolution>=ballradius. and resolution should be halved each time.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width