[Gamesnws-commits] r28 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 13 09:54:23 CEST 2009


Author: grafab
Date: 2009-08-13 09:54:22 +0200 (Thu, 13 Aug 2009)
New Revision: 28

Modified:
   pkg/R/adminUno.R
   pkg/man/computerPlayerUNO.Rd
   pkg/man/createUnoGame.Rd
   pkg/man/playUno.Rd
   pkg/man/startUnoGame.Rd
   pkg/man/watchUnoGame.Rd
Log:
doc-files are revised

Modified: pkg/R/adminUno.R
===================================================================
--- pkg/R/adminUno.R	2009-08-12 13:01:16 UTC (rev 27)
+++ pkg/R/adminUno.R	2009-08-13 07:54:22 UTC (rev 28)
@@ -76,7 +76,7 @@
 # especially to get commands from master-user
 # and to wait for other players
 ############################################################
-startUnoGame <- function(ws, cardsStart=3, 
+startUnoGame <- function(ws, cardsStart=7, 
 		minPlayers=2, maxPlayers=10, 
 		log=0, logfile=NULL, debug=FALSE)
 {	
@@ -229,7 +229,6 @@
 	require(nws)
 	
 	
-	#TODO: write to logfile
 	#TODO: log hand cards of players for statistics
 	
 	# connect to nws server

Modified: pkg/man/computerPlayerUNO.Rd
===================================================================
--- pkg/man/computerPlayerUNO.Rd	2009-08-12 13:01:16 UTC (rev 27)
+++ pkg/man/computerPlayerUNO.Rd	2009-08-13 07:54:22 UTC (rev 28)
@@ -4,9 +4,12 @@
 \title{Computer Player for UNO}
 \description{ Very stupid - random - computer player for UNO}
 \usage{
-	computerPlayerUNO(hand, card_played)
+	computerPlayerUNO(ws, 
+                    hand, 
+                    card_played)
 }
 \arguments{
+  \item{ws}{name of workspace, that is used in the whole program}
   \item{hand}{A vector of cards, which the player holds in his hand.}
   \item{card_played}{A string, which indicates the latest played card.}
 }
@@ -20,5 +23,6 @@
 \item{played_card}{A string for the card, the player plays. Especially for color-selection cards (rybg), a color-rybg string has to be returned.}
 }
 \author{
-Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>
+Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
+Fabian Grandke
 }

Modified: pkg/man/createUnoGame.Rd
===================================================================
--- pkg/man/createUnoGame.Rd	2009-08-12 13:01:16 UTC (rev 27)
+++ pkg/man/createUnoGame.Rd	2009-08-13 07:54:22 UTC (rev 28)
@@ -1,105 +1,28 @@
 \name{createUnoGame}
 \Rdversion{1.1}
 \alias{createUnoGame}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{
-%%  ~~function to do ... ~~
-}
-\description{
-%%  ~~ A concise (1-5 lines) description of what the function does. ~~
-}
-\usage{
-createUnoGame(wsName, ...)
-}
-%- maybe also 'usage' for other objects documented here.
+\title{Creates new UNO-Game}
+\description{New UNO-Game into the given workspace}
+\usage{createUnoGame( wsName, 
+                      ...)}
 \arguments{
-  \item{wsName}{
-%%     ~~Describe \code{wsName} here~~
+  \item{wsName}{Name of the workspace}
+  \item{\dots}{Usual netWorkSpace()-attributes}
 }
-  \item{\dots}{
-%%     ~~Describe \code{\dots} here~~
-}
-}
 \details{
-%%  ~~ If necessary, more details than the description above ~~
+Checks if workspace allready exists.
+Declares workspacevariables.
 }
 \value{
-%%  ~Describe the value returned
-%%  If it is a LIST, use
-%%  \item{comp1 }{Description of 'comp1'}
-%%  \item{comp2 }{Description of 'comp2'}
-%% ...
+\item{ws}{the created workspace with all necessary variables for the UNO-Game}
 }
-\references{
-%% ~put references to the literature/web site here ~
-}
 \author{
-%%  ~~who you are~~
+Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
+Fabian Grandke
 }
-\note{
-%%  ~~further notes~~
-}
-
-%% ~Make other sections like Warning with \section{Warning }{....} ~
-
-\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
-}
 \examples{
-##---- Should be DIRECTLY executable !! ----
-##-- ==>  Define data, use random,
-##--	or do  help(data=index)  for the standard data sets.
-
-## The function is currently defined as
-function(wsName, ...)
-{
-	require(nws)
-
-	# create nws
-	ws <- netWorkSpace(wsName, ...)
-
-	# declate variables in nws
-	nwsDeclare(ws, 'players', 'fifo')
-	nwsDeclare(ws, 'played', 'lifo') 
-	nwsDeclare(ws, 'cards', 'fifo')
-	nwsDeclare(ws, 'players_logedin', 'single')
-	nwsDeclare(ws, 'player_in_action', 'single')
-	nwsDeclare(ws, 'winner', 'single')
-	# user declares own variable for his hand-cards in .playUnoMaster()
-
-	# initialize cards as described in wikipedia
-	# mischen and store in nws
-	cards <- c( paste("red", 1:9, sep="-"), paste("red", 1:9, sep="-"), "red-0",
-			rep("red-BREAK",2), 
-			rep("red-2+",2), 
-			rep("red-BACK",2),
-			paste("yellow", 1:9, sep="-"), paste("yellow", 1:9, sep="-"), "yellow-0",
-			rep("yellow-BACK",2), 
-			rep("yellow-2+"), 
-			rep("yellow-BREAK",2),
-			paste("blue", 1:9, sep="-"), paste("blue", 1:9, sep="-"), "blue-0",
-			rep("blue-BACK",2), 
-			rep("blue-2+",2), 
-			rep("blue-BREAK",2),
-			paste("green", 1:9, sep="-"), paste("green", 1:9, sep="-"), "green-0",
-			rep("green-BREAK",2),
-			rep("green-2+",2),
-			rep("green-BACK",2),
-			rep("rybg-0", 4), rep("rybg-4+",4)
-	)
-	cards <- sample(cards)
-	for( i in 1:length(cards))
-		nwsStore(ws, 'cards', cards[i])
-	
-	nwsStore(ws, 'players_logedin', 'master')
-
-	cat("Send the name and the server address to your other players!\n")
-	cat("Start the game with 'startUnoGame(ws)'\n")
-
-	return(ws)
-  }
+\dontrun{
+  ws<-createUnoGame("test","138.245.80.17")
+  startUnoGame(ws)
 }
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ ~kwd1 }
-\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
+}
\ No newline at end of file

Modified: pkg/man/playUno.Rd
===================================================================
--- pkg/man/playUno.Rd	2009-08-12 13:01:16 UTC (rev 27)
+++ pkg/man/playUno.Rd	2009-08-13 07:54:22 UTC (rev 28)
@@ -1,65 +1,43 @@
 \name{playUno}
 \Rdversion{1.1}
 \alias{playUno}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{
-%%  ~~function to do ... ~~
-}
-\description{
-%%  ~~ A concise (1-5 lines) description of what the function does. ~~
-}
+\title{The function, that has to be called by each UNO-player}
+\description{The player calls it and inputs all necessary values. 
+The function rules the whole course of the UNO-game.}
 \usage{
-playUno(name, user = Sys.info()["user"], computerPlayer = FALSE, computerPlayerFunction = computerPlayerUNO, ...)
+playUno(  name, 
+          user = Sys.info()["user"], 
+          computerPlayer = FALSE, 
+          computerPlayerFunction = computerPlayerUNO, ...)
 }
-%- maybe also 'usage' for other objects documented here.
 \arguments{
-  \item{name}{
-%%     ~~Describe \code{name} here~~
+  \item{name}{Name of the workspace}
+  \item{user}{playername}
+  \item{computerPlayer}{is the player manual or automatical controlled}
+  \item{computerPlayerFunction}{which computerplayer is used}
+  \item{\dots}{}
 }
-  \item{user}{
-%%     ~~Describe \code{user} here~~
-}
-  \item{computerPlayer}{
-%%     ~~Describe \code{computerPlayer} here~~
-}
-  \item{computerPlayerFunction}{
-%%     ~~Describe \code{computerPlayerFunction} here~~
-}
-  \item{\dots}{
-%%     ~~Describe \code{\dots} here~~
-}
-}
 \details{
-%%  ~~ If necessary, more details than the description above ~~
-}
-\value{
-%%  ~Describe the value returned
-%%  If it is a LIST, use
-%%  \item{comp1 }{Description of 'comp1'}
-%%  \item{comp2 }{Description of 'comp2'}
-%% ...
-}
-\references{
-%% ~put references to the literature/web site here ~
-}
-\author{
-%%  ~~who you are~~
-}
-\note{
-%%  ~~further notes~~
-}
+This function rules everything, a player needs. It asks for decisions and shows information.
+Commands:
+say-uno: before playing the second-last card, you have to say uno
+get-info: shows some game relevant information
+color*-number**: plays card
 
-%% ~Make other sections like Warning with \section{Warning }{....} ~
 
-\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
+*color=(red,yellow,blue,green,rybg)
+**number=(0:9,2+,4+)
+
 }
+\author{
+Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
+Fabian Grandke
+}
 \examples{
 \dontrun{
-	playUno("test")
+	playUno("test",user="tom",serverHost="138.245.80.17")
 }
+\dontrun{
+  playUno("test2",user="paul",computerPlayer=TRUE)
 }
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ ~kwd1 }
-\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
+}

Modified: pkg/man/startUnoGame.Rd
===================================================================
--- pkg/man/startUnoGame.Rd	2009-08-12 13:01:16 UTC (rev 27)
+++ pkg/man/startUnoGame.Rd	2009-08-13 07:54:22 UTC (rev 28)
@@ -1,107 +1,43 @@
 \name{startUnoGame}
 \Rdversion{1.1}
 \alias{startUnoGame}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{
-%%  ~~function to do ... ~~
-}
-\description{
-%%  ~~ A concise (1-5 lines) description of what the function does. ~~
-}
+\title{Starts the UNO-Game that is in the given workspace}
+\description{After a UNO-Game is created in a workspace, it gets started with this function.}
 \usage{
-startUnoGame(ws, cardsStart = 7, minPlayers = 2, maxPlayers = 10, log = FALSE, logfile = NULL)
+startUnoGame( ws, 
+              cardsStart = 7, 
+              minPlayers = 2, 
+              maxPlayers = 10, 
+              log = 0, 
+              logfile = NULL, 
+              debug = FALSE)
 }
-%- maybe also 'usage' for other objects documented here.
 \arguments{
-  \item{ws}{
-%%     ~~Describe \code{ws} here~~
+  \item{ws}{workspace with a created UNO-Game in it}
+  \item{cardsStart}{the number of cards, each player gets at the beginning}
+  \item{minPlayers}{the number of players, that are necessary to start a game}
+  \item{maxPlayers}{the number of players, that maximal can join a game}
+  \item{log}{number of log mode}
+  \item{logfile}{the directory, where the log should be saved to(not yet implemented)}
+  \item{debug}{logical variable if debug mode is enabled}
 }
-  \item{cardsStart}{
-%%     ~~Describe \code{cardsStart} here~~
-}
-  \item{minPlayers}{
-%%     ~~Describe \code{minPlayers} here~~
-}
-  \item{maxPlayers}{
-%%     ~~Describe \code{maxPlayers} here~~
-}
-  \item{log}{
-%%     ~~Describe \code{log} here~~
-}
-  \item{logfile}{
-%%     ~~Describe \code{logfile} here~~
-}
-}
 \details{
-%%  ~~ If necessary, more details than the description above ~~
+After starting the game, with this function, the players could log in with playUno().
+When you started the game, you can decide the play mode.
+
 }
-\value{
-%%  ~Describe the value returned
-%%  If it is a LIST, use
-%%  \item{comp1 }{Description of 'comp1'}
-%%  \item{comp2 }{Description of 'comp2'}
-%% ...
-}
-\references{
-%% ~put references to the literature/web site here ~
-}
+
 \author{
-%%  ~~who you are~~
+Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
+Fabian Grandke
 }
-\note{
-%%  ~~further notes~~
-}
-
-%% ~Make other sections like Warning with \section{Warning }{....} ~
-
-\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
-}
 \examples{
-##---- Should be DIRECTLY executable !! ----
-##-- ==>  Define data, use random,
-##--	or do  help(data=index)  for the standard data sets.
-
-## The function is currently defined as
-function(ws, cardsStart=7, 
-		minPlayers=2, maxPlayers=10, 
-		log=FALSE, logfile=NULL)
-{
-
-	readCommand <- ""
-	while(readCommand != "e"){
-
-		# Ask for command from master user
-		readCommand <- readline("Players online [o], Start Game [s], End Game [e]?")
-	
-		# get players
-		players <- nwsFindTry(ws, 'players_logedin')
-		if( any(players=="master"))
-			players <- players[ -which( players == "master")]
-		nplayers <- length(players)
-
-		# Commands for actions depending on master-user Input
-		if(readCommand=="s" && nplayers>=minPlayers && nplayers<=maxPlayers){
-			# Start game	
-			.playUnoMaster(ws, players, cardsStart, log=log, logfile=logfile)
-			cat("For replay you have to reset the Game: createUnoGame()\n")
-			readCommand <- readline("End Game [e]?")
-		} else if( ! (nplayers>=minPlayers) &&  readCommand=="s"){
-			cat("You need more than ", nplayers," player!\n")
-		} else if( ! (nplayers<=maxPlayers) &&  readCommand=="s"){
-			cat("You can only play with less than ", nplayers," players!\n")
-		} else if(readCommand=="o") 
-			cat("Players:", players, "\n")
-		
-	}
-
-	# At the end close / delete game and nws Server
-	nwsDeleteWs(ws at server, ws at wsName)
-	nwsClose(ws)
-	cat(" GAME OVER \n")
-  }
+\dontrun{
+  ws<-createUnoGame("test","138.245.80.17")
+  startUnoGame(ws,log=1)
 }
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ ~kwd1 }
-\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
+\dontrun{
+  ws<-createUnoGame("test","138.245.80.17")
+  startUnoGame(ws, cardsStart=13, minPlayers=4)
+}
+}
\ No newline at end of file

Modified: pkg/man/watchUnoGame.Rd
===================================================================
--- pkg/man/watchUnoGame.Rd	2009-08-12 13:01:16 UTC (rev 27)
+++ pkg/man/watchUnoGame.Rd	2009-08-13 07:54:22 UTC (rev 28)
@@ -1,99 +1,34 @@
 \name{watchUnoGame}
 \Rdversion{1.1}
 \alias{watchUnoGame}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{
-%%  ~~function to do ... ~~
-}
-\description{
-%%  ~~ A concise (1-5 lines) description of what the function does. ~~
-}
+\title{logs the game}
+\description{writes a logfile of the game and returns the winner}
 \usage{
-watchUnoGame(ws, ..., logfile = NULL)
+watchUnoGame( ws, 
+              ..., 
+              logfile = NULL)
 }
-%- maybe also 'usage' for other objects documented here.
 \arguments{
-  \item{ws}{
-%%     ~~Describe \code{ws} here~~
+  \item{ws}{Name of the workspace}
+  \item{\dots}{no function yet, but in future some logging-specific attributes are available}
+  \item{logfile}{the directory, where the log should be saved to(not yet implemented)}
 }
-  \item{\dots}{
-%%     ~~Describe \code{\dots} here~~
-}
-  \item{logfile}{
-%%     ~~Describe \code{logfile} here~~
-}
-}
 \details{
-%%  ~~ If necessary, more details than the description above ~~
+This function will be called in a playUnoMaster()-function.
+The logfile-argument is not yet implemented, so actually the logfile is written in your workingdirectory.
+Different logging-modes will be possible.
 }
 \value{
-%%  ~Describe the value returned
-%%  If it is a LIST, use
-%%  \item{comp1 }{Description of 'comp1'}
-%%  \item{comp2 }{Description of 'comp2'}
-%% ...
+\item{winner}{player that has won the UNO-Game}
 }
-\references{
-%% ~put references to the literature/web site here ~
-}
 \author{
-%%  ~~who you are~~
+Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
+Fabian Grandke
 }
-\note{
-%%  ~~further notes~~
-}
-
-%% ~Make other sections like Warning with \section{Warning }{....} ~
-
-\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
-}
 \examples{
-##---- Should be DIRECTLY executable !! ----
-##-- ==>  Define data, use random,
-##--	or do  help(data=index)  for the standard data sets.
-
-## The function is currently defined as
-function(ws, ..., logfile=NULL)
-{	
-	# connect to nws
-	require(nws)
-	if( class(ws) != "netWorkSpace" ){
-		# connect to nws
-		ws <- netWorkSpace(ws, ...)
-	}
-	
-	
-	# read played cards
-	card_played <- card_played_tmp <- ""
-	user <- user_tmp <- ""
-	while( is.null(winner <- nwsFindTry(ws, 'winner'))
-		|| card_played != card_played_tmp 
-		|| user != user_tmp
-		){
-		card_played <- nwsFindTry(ws, 'played') 
-
-		#if cards change: output
-		if( card_played != card_played_tmp ){
-			cat(user, ": ", card_played, " (",length(nwsFindTry(ws,user)),")\n", sep="")
-			user <- nwsFindTry(ws, 'player_in_action')
-			user_tmp <- user # save player 
-			card_played_tmp <- card_played # save card
-		# if user change and no card: output
-		}else if( user != user_tmp){
-			cat(user_tmp, ": NO (",length(nwsFindTry(ws,user_tmp)),")\n", sep="")
-			#user <- nwsFindTry(ws, 'players')
-			user_tmp <- user
-		}
-		user <- nwsFindTry(ws, 'player_in_action')
-		Sys.sleep(0.1)
-	}
-		
-	#return winner
-	return(winner)
+\dontrun{
+  if(log!=0){
+		winner <- watchUnoGame(ws, logfile=logfile)
   }
 }
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ ~kwd1 }
-\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
+}
\ No newline at end of file



More information about the Gamesnws-commits mailing list