Yesterday, I returned to a game that I’d given up on: Nick Bentley’s Catchup. My implementation was maybe 80% there, but Goadrich and I couldn’t figure out what was causing some various errors, and we decided that it went unimplemented for a reason. Now that I’ve gone let’s get down to business mode with the Ludii games, though, I managed to reengineer it. The game is quite simple to explain to a human.

A GROUP is a connected chain of friendly stones. The game is on a hexagon, so there’s no diagonal connections to worry about. Initially, Black drops one stone, then for the remaining turns players drop one or two stones of either color. If one makes a group larger than the previously largest group on their turn, their opponent may place up to three stones. After the board is full, the player with the largest group wins. If there’s a tie, the next largest group is scored, and so on. Draws are impossible. The game is Hexish, obviously, but involves some intriguing novel tactics, with the new win condition.

I’m a broken record about “the toughest problems possess inherently the elegantest solutions”. I say that even more than “Like Barney’s Hair, is made of little cloths,” which I say every day.

	(define "LargestGroupCascading"
	  (max (intersection (difference (sizes Group #1) (sizes Group #2)) 
									 (sizes Group #1)))         
	)
	   
	//------------------------------------------------------------------------------
	   
	(game "Catchup" 
	  (players 2) 
	  (equipment { 
		(board (hex 5))
		(piece "Marker" Each) 
	  }) 
	  (rules
		(play 
		  (if (!= (mover) (prev)) 
			(move Add (to (sites Empty)) 
			  (then (if (= (count Moves) 1) (set Var "MaxGroup" 1) 
					  (if (= (max (union (sizes Group P1) (sizes Group P2))) (var "MaxGroup")) 
						(set Var "MaxGroup" (max (union (sizes Group P1) (sizes Group P2))) 
						  (then (moveAgain)))
						(set Var "MaxGroup" (max (union (sizes Group P1) (sizes Group P2))) 
						  (then (if (= (var "MaxGroup") (max (sizes Group Mover)))
							(set Score Next  1 (then (moveAgain)))
							(set Score Mover 1 (then (moveAgain))))))))))
			(or {(move Add (to (sites Empty)))
				 (move Pass)}
			  (then (if (= (score Mover) 1) 
					  (set Score Mover 0 (then (moveAgain))))))))        
		(end
		  (if (= 0 (count Sites in:(sites Empty)))
			(byScore {
			  (score P1 ("LargestGroupCascading" P1))
			  (score P2 ("LargestGroupCascading" P2))})))))


	//------------------------------------------------------------------------------

	(metadata 
		
		(info
			{
			(description "Catchup is played on an empty 5x5 hexagonal board.")
			(rules "GROUP - A connected chain of friendly stones.
					TURN - Initially, Black drops one stone, then for the remaining turns players drop one or two stones of either color. If one makes a group larger than the previously largest group on their turn, their opponent may place up to three stones.
					GOAL - After the board is full, the player with the largest group wins. If there's a tie, the next largest group is scored, and so on. Draws are impossible")
			(id "1804")
			(source "<a href=\"http://www.di.fc.ul.pt/~jpn/gv/product.htm\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />www.di.fc.ul.pt</a>")
			(version "1.3.11")
			(classification "board/space/group")
			(author "Nick Bentley")
			(credit "Noah Morris")
			(date "2011")
			}
		)
		
		(graphics
			(show Score)
		)
		
		(ai
			"Catchup_ai"
		)
	)


	//------------------------------------------------------------------------------

	(metadata 
		
		(info
			{
			(description "Catchup is played on an empty 5x5 hexagonal board.")
			(rules "GROUP - A connected chain of friendly stones.
					TURN - Initially, Black drops one stone, then for the remaining turns players drop one or two stones of either color. If one makes a group larger than the previously largest group on their turn, their opponent may place up to three stones.
					GOAL - After the board is full, the player with the largest group wins. If there's a tie, the next largest group is scored, and so on. Draws are impossible")
			(id "1804")
			(source "<a href=\"http://www.di.fc.ul.pt/~jpn/gv/product.htm\" target=\"_blank\" class=\"style1\" style=\"color: #0000EE\" />www.di.fc.ul.pt</a>")
			(version "1.3.11")
			(classification "board/space/group")
			(author "Nick Bentley")
			(credit "Noah Morris")
			(date "2011")
			}
		)
		
		(ai
			"Catchup_ai"
		)
	)