[Tkabber-dev] r951 - in trunk/tkabber-plugins: . renju

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Feb 17 15:28:50 MSK 2007


Author: sergei
Date: 2007-02-17 15:28:48 +0300 (Sat, 17 Feb 2007)
New Revision: 951

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/renju/renju.tcl
Log:
	* renju/renju.tcl: Added tournament Gomoku variant (with 5x5 forbidden
	  zone for black at the second turn).


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-02-16 20:54:57 UTC (rev 950)
+++ trunk/tkabber-plugins/ChangeLog	2007-02-17 12:28:48 UTC (rev 951)
@@ -1,3 +1,8 @@
+2006-02-17  Sergei Golovan <sgolovan at nes.ru>
+
+	* renju/renju.tcl: Added tournament Gomoku variant (with 5x5 forbidden
+	  zone for black at the second turn).
+
 2006-02-16  Sergei Golovan <sgolovan at nes.ru>
 
 	* checkers/checkers.tcl, chess/chess.tcl, renju/renju.tcl,

Modified: trunk/tkabber-plugins/renju/renju.tcl
===================================================================
--- trunk/tkabber-plugins/renju/renju.tcl	2007-02-16 20:54:57 UTC (rev 950)
+++ trunk/tkabber-plugins/renju/renju.tcl	2007-02-17 12:28:48 UTC (rev 951)
@@ -30,6 +30,7 @@
 	[list \
 	    gomoku:freestyle  [::msgcat::mc "Free-style Gomoku"] \
 	    gomoku:standard   [::msgcat::mc "Standard Gomoku"] \
+	    gomoku:tournament [::msgcat::mc "Tournament Gomoku"] \
 	]
     array set game_names $game_names_list
 
@@ -107,6 +108,9 @@
     radiobutton $wf.standard -text [::msgcat::mc "Standard Gomoku"] \
 	-value gomoku:standard -variable [namespace current]::game
     pack $wf.standard -padx 15m -anchor w
+    radiobutton $wf.tournament -text [::msgcat::mc "Tournament Gomoku"] \
+	-value gomoku:tournament -variable [namespace current]::game
+    pack $wf.tournament -padx 15m -anchor w
     radiobutton $wf.renju -text [::msgcat::mc "Renju"] \
 	-state disabled -value renju -variable [namespace current]::game
     pack $wf.renju -padx 15m -anchor w
@@ -328,6 +332,7 @@
 		} else {
 		    set flags(position,turn) white
 		}
+		find_legal_moves $gid $flags(position,turn)
 	    }
 	    resign {
 		end_game $gid 1 [::msgcat::mc "You win (Opponent resigned)"]
@@ -904,6 +909,7 @@
     } else {
 	set flags(position,turn) white
     }
+    find_legal_moves $gid $flags(position,turn)
 
     jlib::send_iq set \
 	[jlib::wrapper:createtag turn \
@@ -1059,7 +1065,8 @@
     set s4 [expr {1 + $str(v1) + $str(v2)}]
 
     switch -- $flags(game) {
-	gomoku:freestyle {
+	gomoku:freestyle -
+	gomoku:tournament {
 	    return [expr {$s1 >= 5 || $s2 >= 5 || $s3 >= 5 || $s4 >= 5}]
 	}
 	gomoku:standard {
@@ -1112,30 +1119,31 @@
 	gomoku:standard {
 	    return 1
 	}
-	renju {
+	gomoku:tournament {
 	    if {![is_black $color]} {
 		return 1
 	    } else {
-		set empty 1
-		for {set c 0} {$c < 15} {incr c} {
-		    for {set r 0} {$r < 15} {incr r} {
-			if {$flags(position,$c,$r) != ""} {
-			    set empty 0
-			}
-		    }
-		}
-		if {$empty} {
+		set hist [llength $flags(position,history)]
+		if {$hist == 0} {
 		    if {$ct == 7 && $rt == 7} {
 			return 1
 		    } else {
 			return 0
 		    }
+		} elseif {$hist == 2} {
+		    if {$ct >= 5 && $ct <= 9 && $rt >= 5 && $rt <= 9} {
+			return 0
+		    } else {
+			return 1
+		    }
 		} else {
-		    # TODO: Fouls
 		    return 1
 		}
 	    }
 	}
+	renju {
+	    # TODO
+	}
     }
 }
 
@@ -1218,6 +1226,7 @@
     switch -- $game {
 	gomoku:freestyle -
 	gomoku:standard -
+	gomoku:tournament -
 	renju {}
 	default {
 	    return
@@ -1252,6 +1261,7 @@
     switch -- [jlib::wrapper:getattr $vars type] {
 	gomoku:freestyle -
 	gomoku:standard -
+	gomoku:tournament -
 	renju {}
 	default {
 	    return



More information about the Tkabber-dev mailing list