• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Limiting User Input

 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing a connect four game for an artificial intelligence course. The first phase of the project is to write a user interface. Since I'm sometimes a little bit of an over-achiever, I decided to create a GUI and do some fancy animations and such. I've written the program and it's good enough to turn in. Since there is quite a bit of code, I decided not to post it; instead, anyone that offers to help can download the source as a jar file from my school webspace.

I still have some problems that may come back to bite me when I go and develop the AI portion so the user can play against the computer. At the moment, it's just made to allower to human players to play against each other. The problem is that if the user clicks on the game board quickly several times in a row, the animation for the falling pieces is all screwed up.

I'm trying to use the Model-View-Controller pattern for my connect four board. In particular, I have three classes ConnectFourBoard (the model), ConnectFourPanel (the view), and ConnectFourController (the controller). Another difficulty is that I'm creating a separate Thread for the animation so that the GUI still responds to some user input that should still be allowed (such as navigating the menu). While this isn't crucial, I thought it would be a good idea.

I'm having a difficult time finding an elegant way to ignore mouse clicks on the ConnectFourPanel while the animation is going. This will be especially crucial because when I start implementing the AI routines, I don't want the user to be able to make a move while the computer is "thinking" about which move to make. Does anyone have any suggestions of how I can implement this in my current design framework?

Any suggestions will be greatly appreciated.

Thanks,

Layne

p.s. Also, if this question would be more appropriate in a different forum, please let me know. There are several choices in my mind, but this GUI forum makes the most sense to me.
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do some searching on Glass Plane. It's not actually a class, but searching on that should find you some solutions.

One other thing. I hate to mention this, and you may not want to look, but Connect 4 has been solved. Of course that doesn't stop you from building an AI for it.

Have fun.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Steven Bell:
I hate to mention this, and you may not want to look, but Connect 4 has been solved. Of course that doesn't stop you from building an AI for it.

Have fun.



I'm sure it has. It's not that difficult of a game. But as I mentiond I'm doing it for a class project. Besides, it's an interesting educational experience.

I'll look into your suggestions about Glass Pane, too. Thanks.

Layne
 
It means our mission is in jeapordy! Quick, read this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic