Paste: icfp2009 score

Author: rand
Mode: factor
Date: Sat, 27 Jun 2009 12:56:58
Plain Text |
! Copyright (C) 2009 Doug Coleman, Kobi Lurie
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces kernel icfp2009.vm ;
IN: icfp2009
SYMBOLS: our-ship ;

TUPLE: satellite 
    velocity
    acceleration
    location
    initial-fuel
    remaining-fuel
    { timesteps initial: 0 }
    hook-timesteps ;

! slots I think we should have. binary simulation data may expose sensors to other data, so add or change as necessary.
! haven't yet figured out what the binary data means
    
: <satellite> ( -- tuple )
    satellite new ;

! global level code:    
<satellite> our-ship set 





: scenario1 ( -- seq ) "vocab:icfp2009/bin1.obf" data-file>vm ;
: scenario2 ( -- seq ) "vocab:icfp2009/bin2.obf" data-file>vm ;
: scenario3 ( -- seq ) "vocab:icfp2009/bin3.obf" data-file>vm ;
: scenario4 ( -- seq ) "vocab:icfp2009/bin4.obf" data-file>vm ;


: magnetize-to-satellite ( satellite -- )
    unimplemented ;


! -------------------------------------------------    
    USING: kernel math namespaces icfp2009 ;
IN: icfp2009.score

SYMBOL: task-end-time ! set when we reach our goal. based on our-ship's timesteps.

: scenario-score ( -- score )
    our-ship get [ remaining-fuel>> ] [ initial-fuel>> ] bi / 45 * 25 + 
    task-end-time get 1000 / log2 30 swap - 
    + ;
    
: hohmann-score ( -- n )
    scenario-score ;

: meet-and-greet-score ( -- n )
    scenario-score 2 * ;

: eccentric-score ( -- n )
    scenario-score 4 * ;

    

    
: clear-sky-total-time ( -- time )
    all-satellites [ hook-timesteps>> 10 6 ^ 2 * swap - ] map sum ;
    
: clear-sky-time-score ( -- score )
    clear-sky-total-time 24 10 6 ^ *  / 75 * ;

: clear-sky-fuel-score ( -- score )
    our-ship get 
    fueling-station get 2array 
    [ [ remaining-fuel>> ] [ initial-fuel>> ] bi / ] map sum
    25 * ;    
    
: clear-sky-score ( -- n ) ! pseudo code
    clear-sky-time-score clear-sky-fuel-score 8 * ;
    
: total-score ( -- n )
    [   hohmann-score 
        meet-and-greet-score 
        eccentric-score 
        clear-sky-score ] output>array sum ;

! other rules:        
! earth-collision? t = [ score: -1 for that scenario ] when
! remaining-fuel-on-task-end 0 < [ score: -1 for that scenario ] when

Annotation: ...

Author: r
Mode: factor
Date: Sat, 27 Jun 2009 16:35:50
Plain Text |
: clear-sky-score ( -- n ) ! pseudo code
    clear-sky-time-score clear-sky-fuel-score + 8 * ;

New Annotation

Summary:
Author:
Mode:
Body: