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

Safe HaskellNone

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 = IntSource

The player (0,1 or 2)

type Round = IntSource

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

clientSource

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 -> IntSource

My id

he :: State -> IntSource

The other players id

opponentName :: State -> TextSource

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 -> BoolSource

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

hasMore :: Units -> Units -> BoolSource

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 :: StrategySource

The dead man strategy. Usually not very effective.

attackNeutral :: StrategySource

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

sendSomewhere :: StrategySource

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

intercept :: StrategySource

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.