Technology Tree Analyser

You know what would be a handy program? A prog that let you enter in the TechIDs for techs and it would tell you whether that was a valid path or not.

For example, here's a tech path that made it to the final frontier:

120|1|7|127|121|129|63|95|41|41|128|33|14|19|12|45|107|108|104|104|134|135|60|38|39|43|24|48|22|36|93|96|110|116|67|15|76|77|117|28|30|44|46|35|78|79|140|80|81|138|84|82|83|85|88|89

The question is, can you really make it to the final frontier that quickly? With nearly 200 techs, seems like it woudl require more techs to get there.

1,607 views 2 replies
Reply #1 Top
A prog that lets you enter TechIDs to determine the actual path? Why not just display the existing valid path using this:

$maxtechno =0;

@targv=@ARGV;

# First, get the list of technologies.
while (($line = <>)) {
    if ($line =~ m/TECH *(\d+) *(\w+)/i) {
	$techno = $1;
	if ($1>$maxtechno) {
	    $maxtechno = $1;
	}
	$current_tech = $2;
	
	if ($techno != 999) {
	    $techlist[$techno] = $current_tech;
	    $techhash{$current_tech} = $techno;
	}
    }
    
}

@ARGV = @targv;

# Build the Technology list tree.
while ($line = <>) {
    if ($line =~ m/TECH *(\d+) *(\w+)/i) {
	$techno = $1;
	$current_tech = $2;
	$reqsize=0;
	
    }
    
    if ($techno != 999) {
	if ($line =~ m/Tech_Requirement *\"(\w+)/i) {
	    $requires[$techno][$reqsize] = $techhash{$1};
	    $reqsize++;	
	    $refcount[$techhash{$1}]++;
	}
	if ($line =~ m/Tech_Requirement_ID *(\d+)/i) {
	    $requires[$techno][$reqsize] = $1;
	    $reqsize++;
	    $refcount[$1]++;
	}
	if ($line =~ m/Research_Cost *(\d+)/i) {
	    $cost[$techlist]=$1;
	}
    }
}

# Now, strip away unneeded techs.
for ($i=0; $i<$maxtechno; $i++) {
    if ($refcount[$i]==0 && $techlist[$i]) {
	if ($techlist[$i] ne "FinalFrontier") {
	    $j = $i + 1;
 	    for ($k=0; $requires[$i][$k] != 0; $k++) {
		$refcount[$requires[$i][$k]]--;
		if ($requires[$i][$k]-1< $j ) {
		    $j=$requires[$i][$k] - 1;
		}
	    }
	    undef $techlist[$i];
	    $i = $j;
	}
    }

}

# Now, dump the list of technologies.
display_tech ($techhash{"FinalFrontier"},0);

sub display_tech {
    my $k;
    if ($shown[$_[0]] != 1) {
	#$shown[$_[0]]=1; #Uncomment line to compress tech tree
	for ($k=0; $requires[$_[0]][$k] != 0; $k++) {
	    display_tech ($requires[$_[0]][$k], $_[1]+1);
	}
	for ($i=0; $i<$_[1]; $i++) {
	    if ($i % 2) {
		print " ";
	    } else {
		print "|";
	    }
	}
	print "$techlist[$_[0]] ($_[0])\n";
    }
}


If the AI players let you, can research the following 48 techs (down from 54):
118|3|120|2|33|34|49|119|102|54|51|56|53|122|129|63|37|38|39|4|40|41|42|43|24|48|22|44|46|35|78|79|80|81|84|36|64|69|70|76|77|28|30|82|83|85|88|89

If you desire, you could accellerate your tech victory even further by researching the technologies that give an additional boost to Research. Those techs are unlikely to deviate from the smallest path by any significant amount...

BTW, you have a minor mistake in the tech path that was typed in - it's somewhat difficult to research tech #104 after researching tech #104. Same with #41 after #41.

[Message Edited]
[Message Edited]
[Message Edited]
Reply #2 Top
bump


~SDC~