haskell-spacegoo-0.1: 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 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 :: Int
 
name :: Text
 

data Fleet Source

Constructors

Fleet 

Fields

fleetId :: Int
 
fleetOwner :: Int
 
origin :: Int
 
target :: Int
 
fleetShips :: Units
 
eta :: Int
 

Instances

data State Source

Constructors

State 

Fields

gameOver :: Bool
 
round :: Int
 
maxRounds :: Int
 
players :: [Player]
 
fleets :: [Fleet]
 
planets :: [Planet]
 

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.

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.