This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing control  RSS feed

 
Peter Tellanaki
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello !
Not sure right spot for my qeustion since it is about game devel, but i am beginner so i guess i should post in beginner since simple question.

I have made a checkers game and gui. Can play with my self using gui. Also i have made an ai which returns best move in a position. But!

I have trouble finding out how to pass control between human player and ai player. Can this be done not using threads ? I want to have human player make move on gui and then
ai player makes move. Am kind of lost here. thought that this would be easy part when CheckersBoard and GUI classes are easy
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure I'm missing something in your question, but passing control should be easy. At a high level your code might look something like this:

 
Campbell Ritchie
Sheriff
Posts: 55323
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
Peter Tellanaki
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again.

Thank you for comments and welcome. Sorry my poor english..
My problem is i dont know how to design so i can get move from human-click on gui. My first program i just play for both. But now AI needs to be told about
human move.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!