chiark / gitweb /
Ooops. Fix changelog file so it's actually correct.
[rocl] / elite-tantalus
CommitLineData
74bdd262 1#! /usr/bin/tclsh
2#
3# $Id$
4
5package require "elite" "1.0.1"
6package require "vector" "1.0.0"
7package require "graph" "1.0.0"
8
9set gg {1 2 3 4 5 6 7 8}
10set maxdist 80
11set minratio 10
12
13for {set i 0} {$i < [llength $argv]} {incr i} {
14 set a [lindex $argv $i]
15 switch -glob -- $a {
16 "-maxdist" {
17 incr i
18 set maxdist [expr {int([lindex $argv $i] * 10)}]
19 }
20 "-minratio" {
21 incr i
22 set minratio [lindex $argv $i]
23 }
24 "--" {
25 incr i
26 break
27 }
28 "-*" {
29 puts stderr "usage: $argv0 \[-maxdist DIST\] \[-minratio RATIO\] \[GALAXY\] ..."
30 exit 1
31 }
32 default {
33 break
34 }
35 }
36}
37
38if {[llength $argv] > $i} {
39 set gg [lrange $argv $i end]
40}
41
42foreach g $gg {
43 destructure {. gs} [parse-galaxy-spec $g]
44 set l [elite-galaxylist $gs]
45 set i 0
46 foreach {w x y} $l {
47 set index($w) $i
48 incr i
49 }
50 elite-adjacency a $l
51 set v [vector {256 256} -1]
52 foreach {w x y} $l {
53 set i $index($w)
54 foreach {ww xx yy} $a($w) {
55 set j $index($ww)
56 $v set $i $j [elite-distance $x $y $xx $yy]
57 }
58 $v set $i $i 0
59 }
60 destructure {lv pv} [graph-shortest-path $v]
61
62 elite-adjacency b $l $maxdist
63 foreach {w x y} $l {
64 set i $index($w)
65 foreach {ww xx yy} $b($w) {
66 set d [elite-distance $x $y $xx $yy]
67 if {$d <= 70 || [string compare $w $ww] > 0} { continue }
68 set j $index($ww)
69 set dd [$lv get $i $j]
70 set r [expr {$dd/"$d.0"}]
71 if {$r >= $minratio} {
72 puts "$g: [worldname $w] -> [worldname $ww]: $d $dd ($r)"
73 }
74 }
75 }
76 $v destroy
77 $lv destroy
78 $pv destroy
79}
80