Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 24th, 2006, 6:20 PM   #1
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
message queue game

In this assignment, you are required to use LINUX inter-process communication (IPC) to
implement the game of “Rock, Paper, and Scissors”. The rule of this game need not be further
explained (just see the picture below). In each round, if two players choose the same weapon, the
round is a still a tie and the tie must be broken.
You are asked to write a player program. When a player enters the system, it should check if
another player is already waiting there. If so, the new player will challenge the existing player.
They will play a best-of-five series to decide the winner. A player may also forfeit the series.
Then the loser leaves and the winner will wait for another challenger. If multiple players want to
challenge an existing player, they will join on a first-come first-serve basis.
To implement this, you need to use the message-passing interface in LINUX. The first player
should create a message queue (with a well-known key). A new arriving player should get the
queue identifier to communicate with the existing player. You need to make sure only two players
are playing the game at one time. The choices of weapon should be exchanged between two
players in a best-of-five series. The text terminals should display the progress of the series. In
addition, the message queue should be destroyed when the last player in the system leaves.


before you get mad at me for posting an assignment here, let me tell you that it makes me feel comfortable if i discuss my approach with someone as I proceed. I dont know anybody in the class, so I am going to discuss my assignment here

^^^ now i am gonna divide the assignment into several sections.
the section i am gonna work first on is to manage the entrance of several players. I am going to assume that all the players enter from the same terminal. Now, there should be some way of knowin that a player is trying to enter the game, which can be used by assigning letter 'p' to determine that. In other words, any time 'p' in the keyboard gets hit, then it means somebody is trying to enter the game.
now am i supposed to use client server approach to handle this? if yes, then do different players imply different clients?
programmingnoob is offline   Reply With Quote
Old Sep 24th, 2006, 6:46 PM   #2
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 3 Narue is on a distinguished road
Jan ken pon!

>now am i supposed to use client server approach to handle this?
That makes sense. Client/server is probably the easiest to get right, and it's also the most popular.

>if yes, then do different players imply different clients?
Yep yep.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Sep 25th, 2006, 11:59 PM   #3
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
okay my bad
i was supposed to assume players enter from different terminals!!
programmingnoob is offline   Reply With Quote
Old Sep 26th, 2006, 8:23 AM   #4
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 3 Narue is on a distinguished road
>i was supposed to assume players enter from different terminals!!
That's irrelevant. Clients can be local or remote, over a wide variety of connections. Most likely you'll end up using a socket interface to communicate between clients and the server, but that can be tested locally without affecting the solution.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Sep 27th, 2006, 4:54 AM   #5
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
Quote:
Originally Posted by programmingnoob View Post
In this assignment, you are required to use LINUX inter-process communication (IPC) to
implement the game of “Rock, Paper, and Scissors”. The rule of this game need not be further
explained (just see the picture below). In each round, if two players choose the same weapon, the
round is a still a tie and the tie must be broken.
You are asked to write a player program. When a player enters the system, it should check if
another player is already waiting there. If so, the new player will challenge the existing player.
They will play a best-of-five series to decide the winner. A player may also forfeit the series.
Then the loser leaves and the winner will wait for another challenger. If multiple players want to
challenge an existing player, they will join on a first-come first-serve basis.
To implement this, you need to use the message-passing interface in LINUX. The first player
should create a message queue (with a well-known key). A new arriving player should get the
queue identifier to communicate with the existing player. You need to make sure only two players
are playing the game at one time. The choices of weapon should be exchanged between two
players in a best-of-five series. The text terminals should display the progress of the series. In
addition, the message queue should be destroyed when the last player in the system leaves.


before you get mad at me for posting an assignment here, let me tell you that it makes me feel comfortable if i discuss my approach with someone as I proceed. I dont know anybody in the class, so I am going to discuss my assignment here

^^^ now i am gonna divide the assignment into several sections.
the section i am gonna work first on is to manage the entrance of several players. I am going to assume that all the players enter from the same terminal. Now, there should be some way of knowin that a player is trying to enter the game, which can be used by assigning letter 'p' to determine that. In other words, any time 'p' in the keyboard gets hit, then it means somebody is trying to enter the game.
now am i supposed to use client server approach to handle this? if yes, then do different players imply different clients?
what do they mean by "To implement this, you need to use the message-passing interface in LINUX."?
Did they mean I need to use the stantard library header instead of manually coding the header?
programmingnoob is offline   Reply With Quote
Old Sep 27th, 2006, 4:17 PM   #6
sarumont
Hobbyist Programmer
 
sarumont's Avatar
 
Join Date: Apr 2004
Location: /dev/urandom
Posts: 154
Rep Power: 5 sarumont is on a distinguished road
Send a message via ICQ to sarumont Send a message via AIM to sarumont Send a message via Yahoo to sarumont
They probably want you to use this:

http://en.wikipedia.org/wiki/Message_passing_interface
http://www-unix.mcs.anl.gov/mpi/

__________________
"Time is an illusion. Lunchtime doubly so."
-the late, great Douglas Adams
sarumont is offline   Reply With Quote
Old Sep 28th, 2006, 2:47 AM   #7
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
alright so i am a bit confused with msgget command
msgget command apparently checks whether a queue exists or not and creates one, right?

int jick;
msgget (key, jick);
I read the tutorials on web over and over, but I still am not sure what effect msgget( key, jick) would have?
it would try to access or create a queue with given "key", right? but what exactly does "jick" do here?
programmingnoob is offline   Reply With Quote
Old Sep 28th, 2006, 2:58 AM   #8
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
also how would i find out whether msgget is creating a queue or accessing a queue??
programmingnoob is offline   Reply With Quote
Old Sep 28th, 2006, 9:33 AM   #9
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
i have a question:
suppose one of the terminals has entered the game and waiting for the second person to join.
when the second person joins, how is the person supposed to know somebody is waiting, therefore he's not the host of the game, but a guest?

my approach would be to let host be in the queue too, no?
programmingnoob is offline   Reply With Quote
Old Sep 28th, 2006, 9:56 AM   #10
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
alright, let me sum up my approach and then you guys can tell me if you find any loopholes:
The first player enters the game, it does not see anybody in the queue, then it adds itself to the queue and waits for the second person.
The second person comes and sees the first person in the queue, the second person is acting like a guest now and the first person is acting like a host.
Doubt: Am I really supposed to put the "host" in the queue?

In the meanwhile the third person tries to join the game, but then it just adds itself to the queue and waits for one of them to exit/lose the game.
Doubt: How can you determine how many people are in the queue? I mean what is the command?

now the actual game, the guest sends the message to the host telling it what tool it has picked etc. The assumption I am making here is that the client does not remove itself from the queue right after making the connection, it just waits there and picks tool for itself and sends the message to the host.
Doubt: How do I delete the queue place associated with this guest? msgctl makes no sense to me! Could somebody explain that to me a little bit?
programmingnoob is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling Maverik 6.2 (from C) megamind5005 C 16 May 3rd, 2006 5:41 PM
How to to do this using Win32 API? csharp C++ 4 Nov 1st, 2005 5:22 AM
Java programmers, game developers, artists, be ware! RPG game team is recruiting! atcomputers.us Paid Job Offers 7 Sep 25th, 2005 7:25 PM
Can anyone help me PLEASE???? jasmm_73 C 4 Jun 7th, 2005 8:27 PM
Programmers Needed! Online Game troy_eisert C++ 2 Jan 29th, 2005 12:51 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:07 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC