Skip to content

♠️ A JVM implementation of Who's the Ass (http://en.wikipedia.org/wiki/Who's_the_Ass%3F) with the ability to inject each player's strategy.

Notifications You must be signed in to change notification settings

dnahodil/whostheass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Who's the Ass?

About »
Releases »
Using this project yourself »
Implementing your own strategy »

About

A JVM implementation of Who's the Ass with the ability to inject each player's strategy.

Written in Groovy but implementations of PlayStrategy can be written in any JVM language.

Developed using IntelliJ IDEA Community Edition.

Doesn't have unit tests (yet?) because I am lazy. 😞

Releases

Complete

v1.0

  • Rules and gameplay implemented
  • Can play specified unmber of games with configurable play strategies
  • Can implement your own play strategies

In progress

v2.0

  • [✓] End-of-round summary passed to PlayStrategy (#2)
  • Project built as JAR (so you can write your own PlayStrategy without checking out the whole project) (#11)

v2.1

  • BaseStrategy class with common code and useful metrics made available. This will make implementing your own PlayStrategy much easier. (#13)

Using this project yourself

To use this project you need to:

  • Install Groovy
  • Install IntelliJ IDEA Community Edition
  • Check out this project
  • Open IntelliJ and the 'Open Project' and select the project from where you checked it out (You will need to point the IntelliJ project to where your Groovy SDK is)

Implementing your own strategy

To implement and use your own strategy you need to write a class that implements PlayStrategy.

You will need to know about the Card enum and the OpponentView interface.

Methods to implement

playNormalRound()

The method called to choose which card(s) to play on a normal round.

public List<Card> playNormalRound(
  List<Card> cardsInHand,                  // The cards you have in your hand
  List<OpponentView> playersWhoHavePlayed, // The OpponentViews of the people who have already played in this round
  List<List<Card>> movesPlayed,            // The list of cards played by the people who have already played this round
  List<OpponentView> playersStillToPlay    // The OpponentViews of the people who are still to play this round
)

The return value must be a java.util.List of the Card(s) you wish to play. To play a single card there should be one element in the List. To pass you should return an empty List (ie. not null). To play multiple cards you should include many instances of the Card in the list. For example to play 3 x Sixes your List should contain the Card.Six value 3 times. You can also include any number of Card.Jokers in your List to use those Jokers to supplement your other cards.

playAssRound()

The method called to choose which card(s) to play on an ass round.

public List<Card> playAssRound(
  List<Card> cardsInHand,                  // The cards you have in your hand
  List<OpponentView> playersWhoHavePlayed, // The OpponentViews of the people who have already played in this round
  List<List<Card>> movesPlayed,            // A list of cards played by the people who have already played this round
  List<OpponentView> playersStillToPlay    // The OpponentViews of the people who are still to play this round
)

The return value must be a java.util.List of the Card you wish to play. There should normally only be 1 element in the returned List. The exception is that if you want to play a Joker you need to return 2 cards: The Card.Joker and the Card value that you want that Joker to be used as. To use a Joker as a Joker (ie. 14 points) you need to return 2 Jokers in the list.

startRound()

This method is called when it is your turn to start a round.

public List<Card> startRound(
  List<Card> cardsInHand,                // The cards you have in your hand
  List<OpponentView> playersStillToPlay, // The OpponentViews of the players who will play after you
  boolean canLeadAss                     // Whether you may lead the Ass card or not
)

The return value must be a java.util.List of the Card(s) you wish to play. The List cannot be empty.

updateAfterNormalRound()

This method is used to pass you the results of a round that has just finished.

public void updateAfterNormalRound(
  List<OpponentView> allPlayers, // The OpponentViews of all players in the Game
  List<List<Card>> movesPlayed,  // The Cards they each played
  OpponentView winner            // The OpponentView of the player who won the round
);

updateAfterAssRound()

This method is used to pass you the results of an ass round that has just finished.

public void updateAfterAssRound(
  List<OpponentView> allPlayers, // The OpponentViews of all players in the Game
  List<List<Card>> movesPlayed,  // The Cards they each played
  OpponentView tookCards         // The OpponentView of the player who took the Cards from before they took the Cards
);

About

♠️ A JVM implementation of Who's the Ass (http://en.wikipedia.org/wiki/Who's_the_Ass%3F) with the ability to inject each player's strategy.

Resources

Stars

Watchers

Forks

Packages

No packages published