Simon McGregor on Thu, 5 Aug 2010 06:02:33 -0700 (MST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[game-lang] GALA


Before we go designing a new language, are we sure we don't want to
use GALA (or a syntactically sugared version thereof)?

I don't understand it fully yet, because I can't get my head around
its execution-path-meets-Prolog structure, but it looks pretty
credible in its abbreviated description of Poker:


game(poker, [

	players: [dealer, gambler],

	...
	
	flow: (
		play_round(ante),
		deal,
		bet),
				
	ante: (
		%% each player gets his/her initial allocation of cash
		money($player) gets $cash,
		%% and pays the ante into the pot
		pay($ante, $player, pot)),

	deal: (choose(nature,
		%% a pair of random hands is chosen and dealt from the deck
		(Hand1, Hand2),
		(deal(deck, $cards, Hand1),
		 deal(deck, $cards, Hand2))),
		%% each player's hand is revealed only to him
		reveal(gambler, myhand(Handl)),
		reveal(dealer, myhand(Hand2)),
		%% evaluate the hands immediately, so that we only do
		%% it once per deal, rather than at every possible showdown
		if(beats(Hand1, Hand2),
			betterhand gets gambler,
			betterhand gets dealer)),

	bet: (
		%% the player chooses his bet
		choose(gambler, InitialBet, between(0, $money(gambler), InitialBet)),
		%% reveals it to the other player
		reveal(dealer, bet(gambler, InitialBet)),
		%% and pays it into the pot
		debt := InitialBet,
		pay(InitialBet, gambler, pot),

		take_turns(next_bet)),
		
	next-bet: (
		choose($player, Bet,
			% meet or raise
			(between($debt, $money($player), Bet);
			% fold
			($debt > 0, Bet = 0)))
				
		if ( ($debt>0, Bet = 0),
			% fold
			wins($opponent),
			% meet or raise
			(pay(Bet, $player, pot),
				if($debt=0,
					% showdown
					wins($betterhand),
					(reveal($opponent, bet($player, Bet)),
					debt gets Bet - $debt))))),
					
	...
_______________________________________________
game-lang mailing list
game-lang@xxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/game-lang