ICFP International Conference on Functional Abusing Ants for Fun - - PDF document

icfp
SMART_READER_LITE
LIVE PREVIEW

ICFP International Conference on Functional Abusing Ants for Fun - - PDF document

ICFP International Conference on Functional Abusing Ants for Fun and Programming Profit Most important Functional Programming conference How Haskell won the ICFP 2004 Programming Contest Ian Lynagh, Andres L oh, Ganesh Sittampalam and


slide-1
SLIDE 1

Abusing Ants for Fun and Profit

How Haskell won the ICFP 2004 Programming Contest

Ian Lynagh, Andres L¨

  • h, Ganesh Sittampalam and Duncan Coutts

Abusing Ants for Fun and Profit – p. 1/21

ICFP

International Conference on Functional Programming Most important Functional Programming conference

Abusing Ants for Fun and Profit – p. 2/21

ICFP

International Conference on Functional Programming Most important Functional Programming conference Therefore most important Computer Science conference

Abusing Ants for Fun and Profit – p. 2/21

ICFP

International Conference on Functional Programming Most important Functional Programming conference Therefore most important Computer Science conference Had an associated programming contest for 7 years

Abusing Ants for Fun and Profit – p. 2/21

slide-2
SLIDE 2

Languages

The programming contest is being conducted by ICFP , which has a desire to promote functional

  • languages. However, rather than debate the

definition of a “functional programming language,” we will accept submissions implemented using any language whatsoever.

Abusing Ants for Fun and Profit – p. 3/21

The team

Team Dunkosmiloolump consisted of: Duncan Coutts Andres Löh (kosmikus) Ian Lynagh (Igloo) Ganesh Sittampalam (Heffalump)

Abusing Ants for Fun and Profit – p. 4/21

The team

Team Dunkosmiloolump consisted of: Duncan Coutts Andres Löh (kosmikus) Ian Lynagh (Igloo) Ganesh Sittampalam (Heffalump)

Abusing Ants for Fun and Profit – p. 4/21

Format

Contest start, task posted: Friday June 4 at 17:00 BST Lightning division deadline: Saturday June 5 at 17:00 BST Contest finish: Monday June 7 at 17:00 BST

Abusing Ants for Fun and Profit – p. 5/21

slide-3
SLIDE 3

The board

Abusing Ants for Fun and Profit – p. 6/21

The aim

8 ∗ 3 ∗ 4 ∗ 5 = 480 food initially 100,000 timesteps Ants are a state machine, max 10,000 states Team with most food dropped on their anthill at the end wins

Abusing Ants for Fun and Profit – p. 7/21

Programming ants

Move st1 st2 Turn Left st PickUp st1 st2 Drop st Flip p st1 st2 Mark i st Unmark i st

Abusing Ants for Fun and Profit – p. 8/21

Conditions

Sense LeftAhead st1 st2 cond Foe FriendWithFood FoeWithFood Food Rock Marker i FoeMarker Home FoeHome

Abusing Ants for Fun and Profit – p. 9/21

slide-4
SLIDE 4

Fighting

After moving, if next to 5 enemy ants, die Otherwise, if now the 5th ant surrounding an enemy ant, it dies Dead ants turn into 3 food Each team has 91 ants. Potentially (2 ∗ 91 − 5) ∗ 3 = 531 extra food.

Abusing Ants for Fun and Profit – p. 10/21

The Bird slide

The PRNG — From half an A4 page down to: mkRng :: Int -> [Int] mkRng = drop 4 . map ((‘mod‘ 16384) . (‘div‘ 65536)) . iterate ((‘mod‘ (65536*16384)) . (1 +) . (22695477 *))

Abusing Ants for Fun and Profit – p. 11/21

Tasks

Simulator Visualiser Ant DSL Ant

Abusing Ants for Fun and Profit – p. 12/21

Simulator

Given 2 ants and a world, print out info for visualiser Slow (used immutable datastructures) Worked! Clear code allowed easy extensibility

Abusing Ants for Fun and Profit – p. 13/21

slide-5
SLIDE 5

Visualiser

Andres had some code lying around from a hex map based game Slow (using wxHaskell incorrectly?) Worked!

Abusing Ants for Fun and Profit – p. 14/21

Ant

Always know direction ant is facing Walk around looking for food, making home marker if none already Randomly turn after a few steps If you find a trail to food, follow it If you find food, take it home leaving a trail to where you came from Action after hitting something depends on what you hit

Abusing Ants for Fun and Profit – p. 15/21

Ant DSL

Gotos and labels Monadic combinators for fresh label generation Inline gotos, common continuation elimination, remove pointless code

Abusing Ants for Fun and Profit – p. 16/21

Ant Stats

3,104 and 3,134 states (max allowed 10,000) Against DoNothing.ant, take 30,000-40,000 timesteps to get all the food (runs to 100,000)

Abusing Ants for Fun and Profit – p. 17/21

slide-6
SLIDE 6

Profiler

Simulator prints stats every 100 timesteps gnuplot graphs stats

Abusing Ants for Fun and Profit – p. 18/21

Results

Team OCant are an extremely cool bunch of hackers!

Abusing Ants for Fun and Profit – p. 19/21

Results

Team OCant are an extremely cool bunch of hackers! Java and C++ are very suitable for rapid

  • prototyping. (Red Team)

Abusing Ants for Fun and Profit – p. 19/21

Results

Team OCant are an extremely cool bunch of hackers! Java and C++ are very suitable for rapid

  • prototyping. (Red Team)

Haskell and C++ are fine programming tools for many applications. (Frictionless Bananas)

Abusing Ants for Fun and Profit – p. 19/21

slide-7
SLIDE 7

Results

Team OCant are an extremely cool bunch of hackers! Java and C++ are very suitable for rapid

  • prototyping. (Red Team)

Haskell and C++ are fine programming tools for many applications. (Frictionless Bananas) Haskell is the language of choice for discriminating hackers! (Dunkosmiloolump)

Abusing Ants for Fun and Profit – p. 19/21

Demos

Abusing Ants for Fun and Profit – p. 20/21

Languages

C + + O C a m l h a n d c

  • d

e d J a v a H a s k e l l P y t h

  • n

C L i s p P e r l S c h e m e u n k n

  • w

n C # R u b y P a s c a l S M L B a s i c m 4 M e r c u r y S c a l a E r l a n g T c l D A l i c e G N U e p s i l

  • n

N e m e r l e b a s h R e v

  • l

u t i

  • n

S m a l l t a l k 5 10 15 20 25

Entries in 2004

C O C a m l C + + J a v a P e r l P y t h

  • n

L I S P H a s k e l l C # 5 10 15 20

Entries in 2003

Abusing Ants for Fun and Profit – p. 21/21