Meaningless Drivel is fun!*
The moose likes Game Development and the fly likes 2 player chess Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "2 player chess" Watch "2 player chess" New topic
Author

2 player chess

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi,

I am building a chess program(as applet) and as application.
It is currently 1 player, and so you play against the program, (and lose
if you are me).
I know I can use sockets to get 2 java programs to talk to each other,
but when me and my mate tried it, I was unable to receive data(Strings),
only could I send data. Something to do with my modem settings I think.

I had an idea, but not sure if its a good one or not.
I've been able to get my applets/applications to write(via php) and read
from a text file on the server for my website.

So in theory, player 1 can make a move, this will write something to the server, then player 2 (reading from server every 2 seconds) can wait for new data to be added, so when it sees it, then player 1's move will be played on player 2's pc.
And after player 1 has made that move, it will start to read from server every 2 seconds, until player 2 has moved.

Its slightly annoying that each computer has to continuously read from the server, but I can't see anyway that an applet/application on one computer can push data to an applet/application on a different computer, without using sockets.

Is my idea any good?
Or do you think it will be problematic?
Thanks
Johnny Kewl
Greenhorn

Joined: Apr 16, 2007
Posts: 8
Hi there I have done a little experimenting with games on a POJO Application Server and the results are very good.
http://coolharbor.100free.com/index.htm

Let me explain a little....
A POJO server runs normal Java programs so in theory if you have a single Java program, and you can start a user interface and call it player one, and then start another UI and call it player 2... its done.

You need to read up a little on it, but what you can do is make it only deliver just those UI forms to remote machines, so the actual chess engine is still on the server... your game will pop up out of the browser, and play just like the stad-alone program. No sockets needed... it does that stuff for you... just need to make the game and understand a POJO server.

Have a look at the pac man game on that site...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

"Johnny Kewl", you have previously been warned on multiple occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.

Failure to comply will result in the removal of your account.

bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Johnny Kewl
Greenhorn

Joined: Apr 16, 2007
Posts: 8
That is my name... blame my parents!
Google the web... I had that name all my life, yes they had a crazy sense of humor!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Please contact me via email. Ignoring a moderators communication is not an appropriate course of action.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Thanks, I've had a quick look.
But before I dive in, I want to check that I'm not wasting my time.
I have normal webhosting, which allows perl/php, but not servlets/jsps.

Can I still use this pojo thing?
Thanks
Rachid Fydhan
Greenhorn

Joined: Nov 26, 2007
Posts: 8
No, you cant use...
Your theory was applied (at least once) before
(in designing a chat applet & server.)

But i have another idea

How about declaring a static String property for the applet and can you pls try and see what will happen its value in the other applet (at your mate's browser) if that static String is changed (by you pushing a button) at your brower?
[ November 26, 2007: Message edited by: Rachid Fydhan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 player chess