Question about Assignment

35 views
Skip to first unread message

Kyle Pullicino

unread,
Feb 19, 2012, 5:42:08 PM2/19/12
to SystemsProgramming2011_12
Hi,

I've got a question regarding the assignment question. When a new turn
starts, and everyone rolls the movement points they'll gain, do all
players make their moves simultaneously or do they take it in turns to
move around the map, one after the other?

Thanks,
Kyle

Joseph Cordina

unread,
Feb 20, 2012, 8:49:48 AM2/20/12
to systemsprogr...@googlegroups.com
Hi,
   the moves happen concurrently. So lets say there are currently 3 players, player 1 gets 5 on his dice, player 2 gets 10 on his dice and player 3 gets 12 on his dice. Now player1 can move around while player 2 can also move around and so on. Yet once they forfeir their turn or run out of movement points, then all of them have to wait for all three players to have forfeited their turn or run out of points, before the nice dice roll can happen. So roll of dice happens synchronously, yet movement happens concurrently.

Joe

Kyle Pullicino

unread,
Feb 20, 2012, 9:09:04 AM2/20/12
to systemsprogr...@googlegroups.com
Understood.

Thanks,
Kyle

Ivan

unread,
Feb 21, 2012, 6:39:44 AM2/21/12
to SystemsProgramming2011_12
I have another question myself. Can new players enter the game mid-
game while other players are playing?

Joseph Cordina

unread,
Feb 21, 2012, 6:56:05 AM2/21/12
to systemsprogr...@googlegroups.com
Yes they can (and the start up position should be one which is currently free, and if not, just place them on a square that is pre-owned already) !! And they can leave also (in which case their conquered squares are released).

Joseph Cordina

JG

unread,
Feb 22, 2012, 7:34:00 AM2/22/12
to SystemsProgramming2011_12
Hi,

If a new player enters the game while the other players are moving, is
the player placed inside the game area after all the others finished
their turn (that is when the next turn starts) or does he enter
immediately? If the latter is the case, does he also roll the dice
despite the fact that the others already rolled earlier, or must he
roll the dice in the next turn (thus stands still while the others are
moving for that particular turn) ?

thanks

John Galea

Joseph Cordina

unread,
Feb 22, 2012, 8:34:05 AM2/22/12
to systemsprogr...@googlegroups.com
Hi,
   he can enter at any time, but if you make every new player start with zero movement points = 0, then he will not be able to move until the next turn (i.e. until the dice are thrown)

Joseph Cordina

Joseph Cordina

unread,
Feb 22, 2012, 8:37:39 AM2/22/12
to systemsprogr...@googlegroups.com
Hi,
  I got the following questions on my email which I think is better I answer here so others can benefit:
>>If players can join at any point, does this mean that players who
>>have lost, reconnect again?
Players can reconnect but they will be treated as new players.
>>What is the limit of players that
>>can connect to the server? I mean there needs to be a limit unless you want all the
>squares to be occupied by 4000 different players.
You can set the limit to a big number, something like a 1000 sounds good to me

Regards

Joseph Cordina

JG

unread,
Feb 22, 2012, 8:41:16 AM2/22/12
to SystemsProgramming2011_12
Ok thanks

ad

unread,
Feb 23, 2012, 4:55:12 AM2/23/12
to SystemsProgramming2011_12
Hi,

I have a question regarding processes and pthreads. Would it make more
sense to handle multiple clients using threads rather than forking a
new process for this application,
assuming many clients?

Thanks,
Adrian

Joseph Cordina

unread,
Feb 23, 2012, 11:13:09 AM2/23/12
to systemsprogr...@googlegroups.com
Hi,
  well it all depends really. If you are worried about efficiency, threads tend to be more efficient, yet harder to program in. I would really recommend you use fork, at least you get isolation of memory and you will not have to worry about race conditions on shared memory etc. An ever better approach is first do it using fork() and once that works, you can spend the remaining time (if there is any left) converting it to pthreads, which is quite trivial to do. But in general you will not lose or earn marks if you choose pthreads versus fork. But you will lose marks if it does not work !

Joseph Cordina

ad

unread,
Feb 23, 2012, 3:40:13 PM2/23/12
to SystemsProgramming2011_12
Thank you Sir

Ivan

unread,
Feb 24, 2012, 9:09:37 AM2/24/12
to SystemsProgramming2011_12
I have some more questions, just to make sure.


Are squares diagonal to each other 'immediately adjacent'?

By 2 players colliding, do you mean when a player moves onto another
player? And after the winner of a collision is determined, what
happens? Does the loser get killed and has to exit the game? And does
the winner claim all the loser's conquered squares?

The user has to see 'the result of the last dice throws', but is the
total sufficient or do you want the result of each dice throw to be
shown?


Thanks,
Ivan Galea

ad

unread,
Feb 25, 2012, 5:56:29 AM2/25/12
to SystemsProgramming2011_12
I have a question on collisions as well, would a collision cost either
player any movement points? (would i be right to assume that hence
only the winner is deducted these points, if any?)

Thanks,
Adrian

JG

unread,
Feb 25, 2012, 6:17:34 AM2/25/12
to SystemsProgramming2011_12
I think so adrian, because the other player will be killed...

Joseph Cordina

unread,
Feb 25, 2012, 8:31:24 AM2/25/12
to systemsprogr...@googlegroups.com
Hi, that is a lot of questions :) Here are the answers:

>>Are squares diagonal to each other 'immediately adjacent'? 
Yes they are. So if you are not on the edges of the area, you always have 8 immediately adjacent squares.


>>By 2 players colliding, do you mean when a player moves onto another 
player? 
Yes when 2 players end up on the same location

>>And after the winner of a collision is determined, what 
>>happens? Does the loser get killed and has to exit the game? 
Yes the loser will get disconnected from the game
>>And does the winner claim all the loser's conquered squares? 
No all the loser's squares will become unclaimed, apart from the square held by the winner which will obviously be owned by the winner.


>>The user has to see 'the result of the last dice throws', but is the 
>>total sufficient or do you want the result of each dice throw to be 
>>shown? 
When 2 dice are thrown, then show result of the 2 dice (put only of 1 turn).

Hope that helps

Joseph Cordina

Joseph Cordina

unread,
Feb 25, 2012, 8:34:13 AM2/25/12
to systemsprogr...@googlegroups.com
So lets say there is player1 and player2, and player1 moves on the square held by player 2, then the movement points cost to player2 will be equal to the movement points as if player2 moves to an enemy square (i.e. 3 movement points). Then whoever wins is irrelevant to the movement point cost.

Joseph Cordina

ad

unread,
Feb 25, 2012, 9:01:49 AM2/25/12
to SystemsProgramming2011_12
Thank you sir

Ivan

unread,
Feb 27, 2012, 9:16:12 AM2/27/12
to SystemsProgramming2011_12
In order to implement the blinking asterix and blinking diamond
characters I used the A_BLINK video attribute from the ncurses library
but it is not working properly, the character just draws with a grey
background instead of blinking. Can you please help?


Ivan Galea

Joseph Cordina

unread,
Feb 27, 2012, 2:10:52 PM2/27/12
to systemsprogr...@googlegroups.com
Hi,
  did you use it with the 'bitwise or' character, so with something like this :

 mvaddch(y,x,ACS_DIAMOND| A_BLINK);

If this still does not work, do not fuss too much about it, after all its not really something that will help your systems programming knowledge.

Regards

Joseph Cordina

Ivan

unread,
Feb 27, 2012, 7:43:44 PM2/27/12
to SystemsProgramming2011_12
Yes I tried the 'bitwise or' like you showed among other things. In
fact the other video attributes work as advertised, it's A_BLINK that
misbehaves. I shall leave as it is then. Thanks.

Ivan

unread,
Mar 13, 2012, 9:25:51 AM3/13/12
to systemsprogr...@googlegroups.com
I am using pthreads and I am having difficulty catching signals. I tried creating a separate thread to handle signals by first calling pthread_sigmask on a sigset and then creating a thread that calls sigwait on that same sigset. This did not work, signals were being ignored including ctrl-z. I also tried using sigaction on each thread but it didn't work either.
So how can I catch signals when using pthreads?

Joseph Cordina

unread,
Mar 13, 2012, 4:39:25 PM3/13/12
to systemsprogr...@googlegroups.com
Hi,
  note that as mentioned many times before, the use of threads at this level will complicate your implementation. Yet if I understand well, you have opted to make every thread block that signal and then made only one thread receive that signal. In that case, you should be able to receive that signal. If you are not doing that, it will be difficult to control which thread actually receives that signal. You can find some useful information here http://www.cognitus.net/html/howto/pthreadSemiFAQ_8.html

Regards

Joseph Cordina
Reply all
Reply to author
Forward
0 new messages