icfp
play

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


  1. 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 Duncan Coutts Abusing Ants for Fun and Profit – p. 1/21 Abusing Ants for Fun and Profit – p. 2/21 ICFP ICFP International Conference on Functional International Conference on Functional Programming Programming Most important Functional Programming Most important Functional Programming conference conference Therefore most important Computer Science Therefore most important Computer Science conference conference Had an associated programming contest for 7 years Abusing Ants for Fun and Profit – p. 2/21 Abusing Ants for Fun and Profit – p. 2/21

  2. Languages The team The programming contest is being conducted by Team Dunkosmiloolump consisted of: ICFP , which has a desire to promote functional Duncan Coutts languages. However, rather than debate the Andres Löh (kosmikus) definition of a “functional programming language,” we will accept submissions Ian Lynagh (Igloo) implemented using any language whatsoever . Ganesh Sittampalam (Heffalump) Abusing Ants for Fun and Profit – p. 3/21 Abusing Ants for Fun and Profit – p. 4/21 The team Format Team Dunkosmiloolump consisted of: Contest start, task posted: Friday June 4 at 17:00 BST Duncan Coutts Lightning division deadline: Andres Löh (kosmikus) Saturday June 5 at 17:00 BST Ian Lynagh (Igloo) Contest finish: Ganesh Sittampalam (Heffalump) Monday June 7 at 17:00 BST Abusing Ants for Fun and Profit – p. 4/21 Abusing Ants for Fun and Profit – p. 5/21

  3. The board 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. 6/21 Abusing Ants for Fun and Profit – p. 7/21 Programming ants Conditions Move st1 st2 Sense LeftAhead st1 st2 cond Turn Left st Foe PickUp st1 st2 FriendWithFood Drop st FoeWithFood Flip p st1 st2 Food Mark i st Rock Unmark i st Marker i FoeMarker Home Abusing Ants for Fun and Profit – p. 8/21 Abusing Ants for Fun and Profit – p. 9/21 FoeHome

  4. Fighting The Bird slide After moving, if next to 5 enemy ants, die The PRNG — From half an A4 page down to: Otherwise, if now the 5th ant surrounding an mkRng :: Int -> [Int] enemy ant, it dies mkRng = drop 4 . map ((‘mod‘ 16384) Dead ants turn into 3 food . (‘div‘ 65536)) Each team has 91 ants. Potentially . iterate ((‘mod‘ (65536*16384)) (2 ∗ 91 − 5) ∗ 3 = 531 extra food. . (1 +) . (22695477 *)) Abusing Ants for Fun and Profit – p. 10/21 Abusing Ants for Fun and Profit – p. 11/21 Tasks Simulator Simulator Given 2 ants and a world, print out info for visualiser Visualiser Slow (used immutable datastructures) Ant DSL Worked! Ant Clear code allowed easy extensibility Abusing Ants for Fun and Profit – p. 12/21 Abusing Ants for Fun and Profit – p. 13/21

  5. Visualiser Ant Andres had some code lying around from a Always know direction ant is facing hex map based game Walk around looking for food, making home Slow (using wxHaskell incorrectly?) marker if none already Worked! 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. 14/21 Abusing Ants for Fun and Profit – p. 15/21 Ant DSL Ant Stats Gotos and labels 3,104 and 3,134 states (max allowed 10,000) Monadic combinators for fresh label Against DoNothing.ant , take generation 30,000-40,000 timesteps to get all the food (runs to 100,000) Inline gotos, common continuation elimination, remove pointless code Abusing Ants for Fun and Profit – p. 16/21 Abusing Ants for Fun and Profit – p. 17/21

  6. Profiler Results Simulator prints stats every 100 timesteps Team OCant are an extremely cool bunch of hackers! gnuplot graphs stats Abusing Ants for Fun and Profit – p. 18/21 Abusing Ants for Fun and Profit – p. 19/21 Results Results Team OCant are an extremely cool bunch of Team OCant are an extremely cool bunch of hackers! hackers! Java and C++ are very suitable for rapid Java and C++ are very suitable for rapid prototyping. (Red Team) prototyping. (Red Team) Haskell and C++ are fine programming tools for many applications. (Frictionless Bananas) Abusing Ants for Fun and Profit – p. 19/21 Abusing Ants for Fun and Profit – p. 19/21

  7. Results Demos 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 Abusing Ants for Fun and Profit – p. 20/21 Languages 25 20 15 20 10 5 15 0 C O C J P P L H C a + e y I # 10 C v a r t S + s a a l h P k m o e n l l l Entries in 2003 5 0 C O h J H P C L P S u C R P S B m M S E T D A G N b R S a a n a + C a y i e c # u a M a c r c l N e e m n v s 4 e l s t r h k s s a l i v + a s h p l b r a c m h a a d k e n c L i l U y c c a n e o l m o m o a e c e u g e l l n l r u t l o l w r p a l e l y e t l d n s i i o k e l n d o Entries in 2004 n Abusing Ants for Fun and Profit – p. 21/21

Recommend


More recommend