News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Adam Jensen's Blog:
Spades and the Strategy Pattern
March 12, 2009 @ 13:44:01

Adam Jensen has submitted a new post he's written up about the idea he had for a spades game written in PHP. There's no fancy graphics or computer AI but there is a good example of using the Strategy Pattern between the players and interfaces in this CLI script.

Here's the project (and I deliberately didn't check to see if anyone's done this before): write a command-line PHP script that runs any number of automated spades games, involving a variety of players utilizing different play algorithms.

The Strategy Pattern comes in with the players - each influences how the player will bid and what cards it will choose to play. He gives the code for these two interfaces - Spades_Player_Interface and Spades_Strategy_Interface. He also sets up a randomizing class and several of the other "structure" classes (Spades_Play, Spades_Card, etc).

This post is just the start of the project. If there's enough interest, Adam will release the source for the project including some of the other strategies he's considering.

0 comments voice your opinion now!
spades strategy pattern interface designpattern player


blog comments powered by Disqus

Similar Posts

DevShed: Building an Error Logger with the Chain of Responsibility Pattern in PHP 5

Joshua Thompson's Blog: Return to Prototype Based Programming in PHP

PHPMaster.com: Handling Collections of Aggregate Roots - the Repository Pattern

Suresh Ariya: Implement Flash Messages using Session in PHP (Part 1 & 2)

Web Builder Zone: Real-life closures examples...for real


Community Events

Don't see your event here?
Let us know!


wordpress language podcast community introduction example library unittest version extension interview framework laravel api release voicesoftheelephpant series opinion laravel5 php7

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework