[Gamesnws-commits] r27 - / old pkg/R pkg/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 12 15:01:17 CEST 2009


Author: schmidb
Date: 2009-08-12 15:01:16 +0200 (Wed, 12 Aug 2009)
New Revision: 27

Added:
   old/
   old/adminPoker.R
   old/examplePoker.R
   old/exampleUno.R
   old/playPoker.R
Removed:
   pkg/R/adminPoker.R
   pkg/R/playPoker.R
   pkg/man/examplePoker.R
   pkg/man/exampleUno.R
Modified:
   pkg/man/playUno.Rd
Log:
struktur anpassung

Copied: old/adminPoker.R (from rev 26, pkg/R/adminPoker.R)
===================================================================
--- old/adminPoker.R	                        (rev 0)
+++ old/adminPoker.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -0,0 +1,116 @@
+createPokerGame <- function(name, ...)
+{
+	require(nws)
+
+	cat("\ngreat idea, will be implemented soon\n")
+}
+
+createPokerGameOLD <- function(name, bigBlind=50,...)
+{
+	require(nws)
+	# create nws
+	ws <<- netWorkSpace(name, ...)
+	
+	# put inital data to the nws
+	cards <- list( 'Pik-A', 'Pik-K', 'Pik-Q', 'Pik-J', 
+			'Pik-10', 'Pik-9', 'Pik-8', 'Pik-7', 'Pik-6', 'Pik-5', 'Pik-4', 'Pik-3', 'Pik-2',
+			'Herz-A', 'Herz-K', 'Herz-Q', 'Herz-J', 
+			'Herz-10', 'Herz-9', 'Herz-8', 'Herz-7', 'Herz-6', 'Herz-5', 'Herz-4', 'Herz-3', 'Herz-2',
+			'Caro-A', 'Caro-K', 'Caro-Q', 'Caro-J', 
+			'Caro-10', 'Caro-9', 'Caro-8', 'Caro-7', 'Caro-6', 'Caro-5', 'Caro-4', 'Caro-3', 'Caro-2',
+			'Kreuz-A', 'Kreuz-K', 'Kreuz-Q', 'Kreuz-J', 
+			'Kreuz-10', 'Kreuz-9', 'Kreuz-8', 'Kreuz-7', 'Kreuz-6', 'Kreuz-5', 'Kreuz-4', 'Kreuz-3', 'Kreuz-2')
+	
+	nwsStore(ws, 'cards', cards)
+	nwsStore(ws, 'bigBlind', bigBlind)
+	nwsDeclare(ws, 'pott', 'single')
+	nwsStore(ws, 'pott', 0)
+	nwsDeclare(ws, 'cardsPlayed', 'single')
+	nwsStore(ws, 'players', NULL)
+	nwsDeclare(ws, 'state', 'single')
+	nwsStore(ws, 'state', "wait")
+	
+	cat("Send the name and the server address to the other players!\n")
+	
+	r <- ""
+	while(r!="e"){
+		r <- readline("Players online [o], Start Game [s], End Game [e]")
+		if(r=="o"){
+			players <- nwsFindTry(ws, 'players')
+			cat("Players:", players, "\n")
+		}
+		if(r=="s"){	
+			playMaster(ws, bigBlind)
+		}
+	}
+	
+	
+	#######################################
+	#End
+	
+	# Check for other players	
+	players <- nwsFind(ws, 'players')
+	
+	#TODO löschen
+	if(is.null(NULL)){ 
+		players <- nwsFetchTry(ws, 'players')
+		for( p in players)
+			nwsDeleteWs(ws at server, paste(name, p, sep="_"))
+		nwsDeleteWs(ws at server, name)
+		nwsClose(ws)
+	} else warning("There are other players online: TODO")
+}
+
+playMaster <- function(ws, bigBlind){
+	
+	nwsStore(ws, 'state', "cards")
+	
+	#Put cards to player
+	cat("\tGive Cards\n")
+	cards <- nwsFindTry(ws, "cards")
+	players <- nwsFindTry(ws, "players")
+	scards <- unlist(sample(cards, 2*length(players)))
+	scards <- split(scards, 1:length(players))
+	
+	for( p in 1:length(players)){
+		wsUser <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
+		# pay blinds
+		if(p==1){
+			nwsStore(wsUser, "money", nwsFindTry(wsUser, "money")-bigBlind/2 )
+			nwsStore(ws, "pott", nwsFetchTry(ws, "pott")+bigBlind/2)
+		}
+		
+		if(p==2){
+			nwsStore(wsUser, "money", nwsFindTry(wsUser, "money")-bigBlind )
+			nwsStore(ws, "pott", nwsFetchTry(ws, "pott")+bigBlind/2)
+		}
+		nwsStore(wsUser, "hand", unlist(scards[p]))
+		nwsClose(wsUser)
+		
+	}
+	
+	#ask players for operation
+	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
+	for( p in 1:length(players)){
+		wsUser <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
+		nwsStore(wsUser, "operation", c("r", "c", "f"))
+		operation <- nwsFindTry(wsUser, 'operation')
+		i <- run <- 0
+		while( length(operation)!=1 ){
+			setTxtProgressBar(pb, i)
+			if(run==0)
+				i <- i+1
+			else i <- i-1
+			if(i==10) run<-1
+			if(i==0) run<-0
+			operation <- nwsFindTry(wsUser, 'operation')
+		}
+	}
+	close(pb)
+	
+	# aufdecken von Karten
+	id <- which(unlist(cards) %in% unlist(scards))
+	cards <- unlist(cards)[-id]
+	table_cards <- unlist(sample(cards, 3))
+	nwsStore(ws, "cardsPlayed", table_cards)
+}
\ No newline at end of file


Property changes on: old/adminPoker.R
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: old/examplePoker.R (from rev 26, pkg/man/examplePoker.R)
===================================================================
--- old/examplePoker.R	                        (rev 0)
+++ old/examplePoker.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -0,0 +1,15 @@
+# Admin
+library(pokerNws)
+game <- createPokerGame('test', serverHost="138.245.80.17")
+
+##########################
+# Player1
+library(pokerNws)
+playPoker('test', serverHost="138.245.80.17", user="markus")
+
+
+#####################
+# Player2
+library(pokerNws)
+playPoker('test', serverHost="138.245.80.17", user="Manuel")
+


Property changes on: old/examplePoker.R
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: old/exampleUno.R (from rev 26, pkg/man/exampleUno.R)
===================================================================
--- old/exampleUno.R	                        (rev 0)
+++ old/exampleUno.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -0,0 +1,33 @@
+library("gamesNws")
+ws <- createUnoGame("test", serverHost="138.245.80.17")
+startUnoGame(ws, log=T)
+
+########################################
+
+library("gamesNws")
+playUno("test", user="Markus", computerPlayer=T, serverHost="138.245.80.17")
+
+library("gamesNws")
+playUno("test", user="Manuel", computerPlayer=T, serverHost="138.245.80.17")
+
+library("gamesNws")
+playUno("test", user="Flo", computerPlayer=T)#, serverHost="138.245.80.17")
+
+
+#########################################
+
+library("gamesNws")
+playUno("test", user="Markus",computerPlayer=F, serverHost="138.245.80.17")
+
+library("gamesNws")
+playUno("test", user="Manuel", computerPlayer=F, serverHost="138.245.80.17")
+
+############################################
+library(nws)
+library("gamesNws")
+s <- sleigh(workerCount=3)
+result = eachElem(s, function(x){
+			library("gamesNws")
+			playUno("test", user=paste("user", x, sep=""),computerPlayer=T, serverHost="138.245.80.17")
+		}, 1:length(s at nodeList))
+stopSleigh(s)
\ No newline at end of file


Property changes on: old/exampleUno.R
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: old/playPoker.R (from rev 26, pkg/R/playPoker.R)
===================================================================
--- old/playPoker.R	                        (rev 0)
+++ old/playPoker.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -0,0 +1,120 @@
+
+player <- function(name, user=Sys.info()["user"], ...)
+{
+	require(nws)
+	
+	cat("\ngreat idea, will be implemented soon\n")
+}
+
+playPokerOLD <- function(name, user=Sys.info()["user"], money=500, ...)
+{
+	require(nws)
+	# Login to nws
+	ws <<- netWorkSpace(name, ...)
+	
+	# set user
+	players <- nwsFetchTry(ws, 'players')
+	players <- c(players, user)
+	nwsStore(ws, 'players', players)
+	#TODO Check for users
+	
+	# set nws for user
+	wsUser <<- netWorkSpace(paste(name, user, sep='_'), ...)
+	nwsDeclare(wsUser, 'money', 'lifo')
+	nwsStore(wsUser, 'money', money)
+	nwsDeclare(wsUser, 'operation', "single")
+	bigBlind <- nwsFindTry(ws,'bigBlind')
+	cat("Big Blind:", bigBlind, "\n")
+	
+	# Wait for other players
+	cat("Wait for other players:\n")
+	state <- nwsFindTry(ws, 'state')
+	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
+	i <- run <- 0
+	while( state != 'cards' ){
+		setTxtProgressBar(pb, i)
+		if(run==0)
+			i <- i+1
+		else i <- i-1
+		if(i==10) run<-1
+		if(i==0) run<-0
+		state <- nwsFindTry(ws, 'state')
+	}
+	close(pb);cat("\n")
+	
+	# Get cards
+	players <- nwsFindTry(ws, 'players')
+	for(p in 1:length(players)){
+		wsUserGegner <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
+		if( players[p] == user ){
+			hand <- nwsFetch(wsUser, 'hand')
+			cat(players[p], ":", hand, sep=" ")
+		}
+		else 
+			cat(players[p], ": XX XX", sep=" ")
+		if(p==1) cat(" - pay:", bigBlind/2, "(", nwsFindTry(wsUserGegner, 'money'),")")
+		if(p==2) cat(" - pay:", bigBlind, "(", nwsFindTry(wsUserGegner, 'money'),")")
+		cat("\n")
+		nwsClose(wsUserGegner)
+	}
+	
+	# Wait for other players
+	cat("Wait for other players:\n")
+	operation <- nwsFindTry(wsUser, 'operation')
+	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
+	i <- run <- 0
+	while( is.null(operation) ){
+		setTxtProgressBar(pb, i)
+		if(run==0)
+			i <- i+1
+		else i <- i-1
+		if(i==10) run<-1
+		if(i==0) run<-0
+		operation <- nwsFindTry(wsUser, 'operation')
+	}
+	close(pb)
+	
+	#Operation
+	r <- ""
+	while(r==""){
+		r <- readline("raise [r], call [c], fold [f]")
+		if(r=="r"){
+			nwsStore(wsUser, 'operation', "r")
+		}
+		if(r=="c"){	
+			nwsStore(wsUser, 'operation', "c")
+		}
+	}
+	
+	# Wait for other players and new cards
+	cat("Wait for other players and new cards:\n")
+	cardsPlayed <- nwsFindTry(ws, 'cardsPlayed')
+	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
+	i <- run <- 0
+	while( is.null(cardsPlayed) ){
+		setTxtProgressBar(pb, i)
+		if(run==0)
+			i <- i+1
+		else i <- i-1
+		if(i==10) run<-1
+		if(i==0) run<-0
+		cardsPlayed <- nwsFindTry(ws, 'cardsPlayed')
+	}
+	close(pb)
+	
+	# Get cards and infos
+	cat("Table:", cardsPlayed, "\n")
+	for(p in 1:length(players)){	
+		wsUserGegner <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
+		operation <- nwsFindTry(wsUserGegner, 'operation')
+		if( players[p] == user ){
+			cat(players[p], ":", hand, ":", operation, "\n", sep=" ")
+		}
+		else cat(players[p], ": XX XX :", operation, " \n")
+		nwsClose(wsUserGegner)
+	}
+	
+	
+	return(NULL)
+}
+


Property changes on: old/playPoker.R
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: pkg/R/adminPoker.R
===================================================================
--- pkg/R/adminPoker.R	2009-08-12 12:10:25 UTC (rev 26)
+++ pkg/R/adminPoker.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -1,116 +0,0 @@
-createPokerGame <- function(name, ...)
-{
-	require(nws)
-
-	cat("\ngreat idea, will be implemented soon\n")
-}
-
-createPokerGameOLD <- function(name, bigBlind=50,...)
-{
-	require(nws)
-	# create nws
-	ws <<- netWorkSpace(name, ...)
-	
-	# put inital data to the nws
-	cards <- list( 'Pik-A', 'Pik-K', 'Pik-Q', 'Pik-J', 
-			'Pik-10', 'Pik-9', 'Pik-8', 'Pik-7', 'Pik-6', 'Pik-5', 'Pik-4', 'Pik-3', 'Pik-2',
-			'Herz-A', 'Herz-K', 'Herz-Q', 'Herz-J', 
-			'Herz-10', 'Herz-9', 'Herz-8', 'Herz-7', 'Herz-6', 'Herz-5', 'Herz-4', 'Herz-3', 'Herz-2',
-			'Caro-A', 'Caro-K', 'Caro-Q', 'Caro-J', 
-			'Caro-10', 'Caro-9', 'Caro-8', 'Caro-7', 'Caro-6', 'Caro-5', 'Caro-4', 'Caro-3', 'Caro-2',
-			'Kreuz-A', 'Kreuz-K', 'Kreuz-Q', 'Kreuz-J', 
-			'Kreuz-10', 'Kreuz-9', 'Kreuz-8', 'Kreuz-7', 'Kreuz-6', 'Kreuz-5', 'Kreuz-4', 'Kreuz-3', 'Kreuz-2')
-	
-	nwsStore(ws, 'cards', cards)
-	nwsStore(ws, 'bigBlind', bigBlind)
-	nwsDeclare(ws, 'pott', 'single')
-	nwsStore(ws, 'pott', 0)
-	nwsDeclare(ws, 'cardsPlayed', 'single')
-	nwsStore(ws, 'players', NULL)
-	nwsDeclare(ws, 'state', 'single')
-	nwsStore(ws, 'state', "wait")
-	
-	cat("Send the name and the server address to the other players!\n")
-	
-	r <- ""
-	while(r!="e"){
-		r <- readline("Players online [o], Start Game [s], End Game [e]")
-		if(r=="o"){
-			players <- nwsFindTry(ws, 'players')
-			cat("Players:", players, "\n")
-		}
-		if(r=="s"){	
-			playMaster(ws, bigBlind)
-		}
-	}
-	
-	
-	#######################################
-	#End
-	
-	# Check for other players	
-	players <- nwsFind(ws, 'players')
-	
-	#TODO löschen
-	if(is.null(NULL)){ 
-		players <- nwsFetchTry(ws, 'players')
-		for( p in players)
-			nwsDeleteWs(ws at server, paste(name, p, sep="_"))
-		nwsDeleteWs(ws at server, name)
-		nwsClose(ws)
-	} else warning("There are other players online: TODO")
-}
-
-playMaster <- function(ws, bigBlind){
-	
-	nwsStore(ws, 'state', "cards")
-	
-	#Put cards to player
-	cat("\tGive Cards\n")
-	cards <- nwsFindTry(ws, "cards")
-	players <- nwsFindTry(ws, "players")
-	scards <- unlist(sample(cards, 2*length(players)))
-	scards <- split(scards, 1:length(players))
-	
-	for( p in 1:length(players)){
-		wsUser <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
-		# pay blinds
-		if(p==1){
-			nwsStore(wsUser, "money", nwsFindTry(wsUser, "money")-bigBlind/2 )
-			nwsStore(ws, "pott", nwsFetchTry(ws, "pott")+bigBlind/2)
-		}
-		
-		if(p==2){
-			nwsStore(wsUser, "money", nwsFindTry(wsUser, "money")-bigBlind )
-			nwsStore(ws, "pott", nwsFetchTry(ws, "pott")+bigBlind/2)
-		}
-		nwsStore(wsUser, "hand", unlist(scards[p]))
-		nwsClose(wsUser)
-		
-	}
-	
-	#ask players for operation
-	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
-	for( p in 1:length(players)){
-		wsUser <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
-		nwsStore(wsUser, "operation", c("r", "c", "f"))
-		operation <- nwsFindTry(wsUser, 'operation')
-		i <- run <- 0
-		while( length(operation)!=1 ){
-			setTxtProgressBar(pb, i)
-			if(run==0)
-				i <- i+1
-			else i <- i-1
-			if(i==10) run<-1
-			if(i==0) run<-0
-			operation <- nwsFindTry(wsUser, 'operation')
-		}
-	}
-	close(pb)
-	
-	# aufdecken von Karten
-	id <- which(unlist(cards) %in% unlist(scards))
-	cards <- unlist(cards)[-id]
-	table_cards <- unlist(sample(cards, 3))
-	nwsStore(ws, "cardsPlayed", table_cards)
-}
\ No newline at end of file

Deleted: pkg/R/playPoker.R
===================================================================
--- pkg/R/playPoker.R	2009-08-12 12:10:25 UTC (rev 26)
+++ pkg/R/playPoker.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -1,120 +0,0 @@
-
-player <- function(name, user=Sys.info()["user"], ...)
-{
-	require(nws)
-	
-	cat("\ngreat idea, will be implemented soon\n")
-}
-
-playPokerOLD <- function(name, user=Sys.info()["user"], money=500, ...)
-{
-	require(nws)
-	# Login to nws
-	ws <<- netWorkSpace(name, ...)
-	
-	# set user
-	players <- nwsFetchTry(ws, 'players')
-	players <- c(players, user)
-	nwsStore(ws, 'players', players)
-	#TODO Check for users
-	
-	# set nws for user
-	wsUser <<- netWorkSpace(paste(name, user, sep='_'), ...)
-	nwsDeclare(wsUser, 'money', 'lifo')
-	nwsStore(wsUser, 'money', money)
-	nwsDeclare(wsUser, 'operation', "single")
-	bigBlind <- nwsFindTry(ws,'bigBlind')
-	cat("Big Blind:", bigBlind, "\n")
-	
-	# Wait for other players
-	cat("Wait for other players:\n")
-	state <- nwsFindTry(ws, 'state')
-	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
-	i <- run <- 0
-	while( state != 'cards' ){
-		setTxtProgressBar(pb, i)
-		if(run==0)
-			i <- i+1
-		else i <- i-1
-		if(i==10) run<-1
-		if(i==0) run<-0
-		state <- nwsFindTry(ws, 'state')
-	}
-	close(pb);cat("\n")
-	
-	# Get cards
-	players <- nwsFindTry(ws, 'players')
-	for(p in 1:length(players)){
-		wsUserGegner <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
-		if( players[p] == user ){
-			hand <- nwsFetch(wsUser, 'hand')
-			cat(players[p], ":", hand, sep=" ")
-		}
-		else 
-			cat(players[p], ": XX XX", sep=" ")
-		if(p==1) cat(" - pay:", bigBlind/2, "(", nwsFindTry(wsUserGegner, 'money'),")")
-		if(p==2) cat(" - pay:", bigBlind, "(", nwsFindTry(wsUserGegner, 'money'),")")
-		cat("\n")
-		nwsClose(wsUserGegner)
-	}
-	
-	# Wait for other players
-	cat("Wait for other players:\n")
-	operation <- nwsFindTry(wsUser, 'operation')
-	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
-	i <- run <- 0
-	while( is.null(operation) ){
-		setTxtProgressBar(pb, i)
-		if(run==0)
-			i <- i+1
-		else i <- i-1
-		if(i==10) run<-1
-		if(i==0) run<-0
-		operation <- nwsFindTry(wsUser, 'operation')
-	}
-	close(pb)
-	
-	#Operation
-	r <- ""
-	while(r==""){
-		r <- readline("raise [r], call [c], fold [f]")
-		if(r=="r"){
-			nwsStore(wsUser, 'operation', "r")
-		}
-		if(r=="c"){	
-			nwsStore(wsUser, 'operation', "c")
-		}
-	}
-	
-	# Wait for other players and new cards
-	cat("Wait for other players and new cards:\n")
-	cardsPlayed <- nwsFindTry(ws, 'cardsPlayed')
-	pb <- txtProgressBar(min=0, max=10, style=1, width=20)
-	i <- run <- 0
-	while( is.null(cardsPlayed) ){
-		setTxtProgressBar(pb, i)
-		if(run==0)
-			i <- i+1
-		else i <- i-1
-		if(i==10) run<-1
-		if(i==0) run<-0
-		cardsPlayed <- nwsFindTry(ws, 'cardsPlayed')
-	}
-	close(pb)
-	
-	# Get cards and infos
-	cat("Table:", cardsPlayed, "\n")
-	for(p in 1:length(players)){	
-		wsUserGegner <- netWorkSpace(paste(ws at wsName,players[p],sep="_"), serverHost=ws at server@serverHost)
-		operation <- nwsFindTry(wsUserGegner, 'operation')
-		if( players[p] == user ){
-			cat(players[p], ":", hand, ":", operation, "\n", sep=" ")
-		}
-		else cat(players[p], ": XX XX :", operation, " \n")
-		nwsClose(wsUserGegner)
-	}
-	
-	
-	return(NULL)
-}
-

Deleted: pkg/man/examplePoker.R
===================================================================
--- pkg/man/examplePoker.R	2009-08-12 12:10:25 UTC (rev 26)
+++ pkg/man/examplePoker.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -1,15 +0,0 @@
-# Admin
-library(pokerNws)
-game <- createPokerGame('test', serverHost="138.245.80.17")
-
-##########################
-# Player1
-library(pokerNws)
-playPoker('test', serverHost="138.245.80.17", user="markus")
-
-
-#####################
-# Player2
-library(pokerNws)
-playPoker('test', serverHost="138.245.80.17", user="Manuel")
-

Deleted: pkg/man/exampleUno.R
===================================================================
--- pkg/man/exampleUno.R	2009-08-12 12:10:25 UTC (rev 26)
+++ pkg/man/exampleUno.R	2009-08-12 13:01:16 UTC (rev 27)
@@ -1,33 +0,0 @@
-library("gamesNws")
-ws <- createUnoGame("test", serverHost="138.245.80.17")
-startUnoGame(ws, log=T)
-
-########################################
-
-library("gamesNws")
-playUno("test", user="Markus", computerPlayer=T, serverHost="138.245.80.17")
-
-library("gamesNws")
-playUno("test", user="Manuel", computerPlayer=T, serverHost="138.245.80.17")
-
-library("gamesNws")
-playUno("test", user="Flo", computerPlayer=T)#, serverHost="138.245.80.17")
-
-
-#########################################
-
-library("gamesNws")
-playUno("test", user="Markus",computerPlayer=F, serverHost="138.245.80.17")
-
-library("gamesNws")
-playUno("test", user="Manuel", computerPlayer=F, serverHost="138.245.80.17")
-
-############################################
-library(nws)
-library("gamesNws")
-s <- sleigh(workerCount=3)
-result = eachElem(s, function(x){
-			library("gamesNws")
-			playUno("test", user=paste("user", x, sep=""),computerPlayer=T, serverHost="138.245.80.17")
-		}, 1:length(s at nodeList))
-stopSleigh(s)
\ No newline at end of file

Modified: pkg/man/playUno.Rd
===================================================================
--- pkg/man/playUno.Rd	2009-08-12 12:10:25 UTC (rev 26)
+++ pkg/man/playUno.Rd	2009-08-12 13:01:16 UTC (rev 27)
@@ -55,284 +55,10 @@
 %% ~~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(name, 
-		user=Sys.info()["user"], 
-		computerPlayer=FALSE, computerPlayerFunction=computerPlayerUNO, 
-		...)
-{
-	require(nws)
-	# Login to nws
-	ws <- netWorkSpace(name, ...)
-	
-	# set user to nws: log in
-	while ( is.null(players_logedin <- nwsFetchTry(ws, 'players_logedin')) ){}
-	if( any(players_logedin == user)){
-		nwsStore(ws, 'players_logedin', players_logedin)
-		stop("User already exists, please change user name!")
-	}else if( !any(players_logedin == 'master')){
-		nwsStore(ws, 'players_logedin', players_logedin)
-		stop("Game is already running, no more login possible!")
-	}else
-		nwsStore(ws, 'players_logedin', c(players_logedin, user))
-
-	# Wait for other players and game start
-	# if the player (=user) got cards, start the game
-	# additional get cards for player (=user)
-	# and declare card-varable for user
-	nwsDeclare(ws, user, 'lifo')
-	cat("Wait for other players and game start:\n")
-	cards <- .txtProgressBarNWS(ws, user) 
- 
-	# GAME
-	# play the game, as long as there is no winner
-	while(is.null(nwsFindTry(ws, "winner")) ){
-		# look for player in Action
-		# if you are user in action, there is no winner and there is card at the table,
-		# than play your cards
-		pb <- txtProgressBar(min=0, max=10, style=1, width=20)
-		i <- run <- 0
-		while( nwsFindTry(ws, 'player_in_action')!=user && is.null(nwsFindTry(ws, "winner")) ){
-			setTxtProgressBar(pb, i)
-			if(run==0)
-				i <- i+1
-			else i <- i-1
-			if(i==10) run<-1
-			if(i==0) run<-0
-			Sys.sleep(0.1) #to reduce requests to NWS
-		}
-		close(pb)
-		playerInAction <- nwsFindTry(ws, 'player_in_action')
-		
-		# Check card stack for enough cards
-		tmp<-nwsListVars(ws, wsName=ws at wsName, showDataFrame=TRUE)
-		ncards <- tmp[tmp[,1]=="cards",]$"NumValues"
-		if( ncards < 5 ){
-			played <- nwsFetchTry(ws, 'played')
-			rest_played <- vector()
-			i=1
-			while( !is.null(tmp <- nwsFetchTry(ws,'played'))){
-				rest_played[i] <- tmp 
-				i <- i + 1
-			}
-			rest_played <- sample(rest_played)
-			for(i in 1:length(rest_played)){
-				nwsStore(ws, 'cards', rest_played[i])
-			}
-			nwsStore(ws, 'played', played)
-		}
-			
-
-		
-		#Play Card if there is no winner
-		card_play <- ""
-		NO <- 0
-		while(card_play=="" && is.null(nwsFindTry(ws, "winner")) && playerInAction==user ){
-			
-			# SOME OUTPUT
-			# get all players
-			players <- nwsFindTry(ws, "players_logedin")
-			cat("Players: ")
-			for(p in players)
-				cat(p, "(",length(nwsFindTry(ws,p)),"): ", sep="")
-			cat("\n")
-			# get played card
-			played <- nwsFindTry(ws, 'played')
-			#split for color and number
-			played_color <- strsplit(unlist(played), "-")[[1]][1]
-			played_number <- strsplit(unlist(played), "-")[[1]][2]
-			cat("Table:", played,"\n")
-			
-			# PENALTIE
-			if( played_number =='2+'){
-				cat("You got 2 penalty cards\n")
-				cards <- c(cards, nwsFetchTry(ws,"cards"), nwsFetchTry(ws,"cards"))
-				nwsStore(ws, user, cards) 
-			}
-			if( played_number =='rygb4+'){
-				cat("You got 4 penalty cards\n")
-				cards <- c(cards, nwsFetchTry(ws,"cards"), nwsFetchTry(ws,"cards"),nwsFetchTry(ws,"cards"), nwsFetchTry(ws,"cards"))
-				nwsStore(ws, user, cards)
-			}
-			cat("Hand:", unlist(cards), "\n")
-			
-			# PLAY CARD
-			if(computerPlayer == TRUE){
-				#for computer player
-				tmp <- computerPlayerFunction(cards, played)
-				card_play <- tmp$sel
-				card_play_save <- tmp$played
-				cat("Play:", card_play_save, "\n")
-				# computer palyer to fast for NWS
-				Sys.sleep(0.1)
-			} else{
-				# for user
-				card_play <- readline("Play: ")
-				# ask for
-				if(card_play=="rybg-0"){
-					# ask for color by wish card
-					col <- readline("Color: ")
-					card_play_save <- paste(col, "rygb", sep="-")
-				}else if(card_play=="rybg-4+"){
-					# ask for color by wish card
-					col <- readline("Color: ")
-					card_play_save <- paste(col, "rygb4+", sep="-")
-				}else
-					card_play_save <- card_play
-			}	
-			
-			#ACTION DEPENDONG ON CARD TYPE
-			#split for color and number
-			card_play_color <- strsplit(card_play, "-")[[1]][1]
-			card_play_number <- strsplit(card_play, "-")[[1]][2]
-			
-			if(card_play=="NO"){
-				# if there is no matching card in the hand
-				if(NO==0){
-					# in first time get new card 
-					cards <- c(cards, nwsFetchTry(ws,"cards"))
-					nwsStore(ws, user, cards) 
-					NO <- 1
-					card_play<-""
-					#no player rotation
-				} else if(NO==1){
-					# in second time, do not get new card
-					# rotate player
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					nwsStore(ws, 'player_in_action', playerInAction)
-					#card_play=NO
-				}
-				
-			}else if(card_play=="rybg-0"){
-				#remove card from hand
-				cards <- cards[-which(cards==card_play)]
-				nwsStore(ws, user, cards)
-				# play card
-				nwsStore(ws, "played", card_play_save)
-				#check for winner and goto next player
-				if(length(cards) != 0 ){
-					# rotate player
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					nwsStore(ws, 'player_in_action', playerInAction)
-				} else
-					nwsStore(ws, "winner", playerInAction)
-				
-			}else if(card_play=="rybg-4+"){
-				#remove card from hand
-				cards <- cards[-which(cards==card_play)]
-				nwsStore(ws, user, cards)
-				# play card
-				nwsStore(ws, "played", card_play_save)
-				#check for winner and goto next player
-				if(length(cards) != 0 ){
-					# rotate player
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					nwsStore(ws, 'player_in_action', playerInAction)
-				} else
-					nwsStore(ws, "winner", playerInAction)
-	
-			}else if(card_play_number=="BREAK"){
-				#remove card from hand
-				cards <- cards[-which(cards==card_play)]
-				nwsStore(ws, user, cards)
-				# play card
-				nwsStore(ws, "played", card_play_save)
-				#check for winner and goto next player
-				if(length(cards) != 0 ){
-					# rotate player 2 times
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					nwsStore(ws, 'player_in_action', playerInAction)
-				} else
-					nwsStore(ws, "winner", playerInAction)
-	
-			}else if(card_play_number=="BACK"){
-				#remove card from hand
-				cards <- cards[-which(cards==card_play)]
-				nwsStore(ws, user, cards)
-				# play card
-				nwsStore(ws, "played", card_play_save)
-				#check for winner and goto next player
-				if(length(cards) != 0 ){
-					#  rotate all players
-					players_tmp <- vector()
-					i=1
-					while( !is.null(tmp <- nwsFetchTry(ws,'players'))){
-						players_tmp[i] <- tmp 
-						i <- i + 1
-					}
-					print(players_tmp)
-					for(i in (length(players_tmp)-1):1){
-						nwsStore(ws, 'players', players_tmp[i])
-					}
-					nwsStore(ws, 'players', players_tmp[length(players_tmp)])
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					nwsStore(ws, 'player_in_action', playerInAction)
-				} else
-					nwsStore(ws, "winner", playerInAction)
-	
-			}else if(card_play_number=="2+"){
-				#remove card from hand
-				cards <- cards[-which(cards==card_play)]
-				nwsStore(ws, user, cards)
-				# play card
-				nwsStore(ws, "played", card_play_save)
-				#check for winner and goto next player
-				if(length(cards) != 0 ){
-					# rotate player
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					nwsStore(ws, 'player_in_action', playerInAction)
-				} else
-					nwsStore(ws, "winner", playerInAction)
-	
-			}else if(!(card_play \%in\% unlist(cards))){
-				cat("\tCard not in your cards!\n\t'NO' for new card.\n")
-				card_play <- ""
-
-			}else if(played_color != card_play_color && played_number != card_play_number){
-				cat("\tCard does not match!\n")
-				card_play <- ""
-
-			}else {
-				# play normal card with color and number
-				#remove card from hand
-				cards <- cards[-which(cards==card_play)]
-				nwsStore(ws, user, cards)
-				# play card
-				nwsStore(ws, "played", card_play_save)
-				#check for winner and goto next player
-				if(length(cards) != 0 ){
-					# rotate player
-					playerInAction <- nwsFetchTry(ws, 'players')
-					nwsStore(ws, "players", playerInAction)
-					nwsStore(ws, 'player_in_action', playerInAction)
-				} else
-					nwsStore(ws, "winner", playerInAction)
-			}
-		}
-	}
-
-	# End of game, small output
-	if(length(cards) == 0 ){
-		cat("!! CONGRATULATION,", nwsFindTry(ws,"winner"), " you won !!\n")
-	} else
-		cat("Sorry you lost, winner:", nwsFindTry(ws,"winner"), "\n")
-	
-	# close nws connection
-	nwsClose(ws)
-  }
+\dontrun{
+	playUno("test")
 }
+}
 % Add one or more standard keywords, see file 'KEYWORDS' in the
 % R documentation directory.
 \keyword{ ~kwd1 }



More information about the Gamesnws-commits mailing list