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 #

The player (0,1 or 2)

type Round = Int #

A Round count

type Units = (Int, Int, Int) #

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

type Coord = (Int, Int) #

A position on the map

data Player #

Constructors

Player 

Fields

data Fleet #

Constructors

Fleet 

data State #

Constructors

State 

Moves

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

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

type Strategy = State -> Move #

Writing clients

client #

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 #

My id

he :: State -> Int #

The other players id

opponentName :: State -> Text #

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

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

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

winsAgainst :: Units -> Units -> Bool #

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

hasMore :: Units -> Units -> Bool #

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

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

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

Example strategies

nop :: Strategy #

The dead man strategy. Usually not very effective.

attackNeutral :: Strategy #

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

sendSomewhere :: Strategy #

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

intercept :: Strategy #

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.