haskell-spacegoo-0.2.0.1: Client API for Rocket Scissor Spacegoo

Safe HaskellNone
LanguageHaskell98

Game.Spacegoo

Contents

Description

This module provides you with everything to quicky write clients for the GPN13 Spacegoo programming contest. Essentially you write a function of type Strategy that takes the State and may return a Move. If you pass such a function to clients, you are good to go. See the examples section for some examples.

Synopsis

The state

type PlayerId = Int Source

The player (0,1 or 2)

type Round = Int Source

A Round count

type Units = (Int, Int, Int) Source

Units, either on a planet, on a fleet, or as a production indication.

type Coord = (Int, Int) Source

A position on the map

data Player Source

Constructors

Player 

Fields

itsme :: Bool
 
playerId :: PlayerId
 
name :: Text
 

data Fleet Source

Constructors

Fleet 

Instances

data State Source

Constructors

State 

Instances

Moves

type Move = Maybe (Int, Int, Units) Source

A Move contains the id of a source planet, the id or a target planet, and the number of ships to send

Writing clients

client Source

Arguments

:: Int

Port

-> String

Hostname

-> String

Username

-> String

Passwort

-> Strategy

Your strategy

-> IO () 

This is your main entry point to play one round of the game.

Utilities

me :: State -> Int Source

My id

he :: State -> Int Source

The other players id

opponentName :: State -> Text Source

The opponent's name; to filter out known bad opponents

battle :: Units -> Units -> (Bool, Units) Source

Whether the first argument wins against the second, and how many ships are left

winsAgainst :: Units -> Units -> Bool Source

Whether the first fleet wins against the second (defaulting to the second)

hasMore :: Units -> Units -> Bool Source

Whether the first player has at least as many ships as the other

ownerAt :: State -> Int -> Round -> (PlayerId, Units) Source

Predict the owner and strength of the planet at the given round

Example strategies

nop :: Strategy Source

The dead man strategy. Usually not very effective.

attackNeutral :: Strategy Source

Picks an own planet with a reasonable number of ships and sends it to some neutral planet.

sendSomewhere :: Strategy Source

From any own planet, send all ships to any opposing planet.

intercept :: Strategy Source

Look for an opposing fleet. If we have a planet with more ships than the opposing fleet that would arrive shortly after that, send a fleet the same size as the opposing fleet.