| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| Script Challenge - Amtrak https://mail.black-squirrel.com/viewtopic.php?f=15&t=25641 |
Page 1 of 4 |
| Author: | ElderProphet [ Fri Feb 05, 2010 1:05 am ] |
| Post subject: | Script Challenge - Amtrak |
Years ago, I wrote a quick Amtrak script. I was amazed at how efficiently it could be done from a "lines of code" standpoint, though it took many more lines to make it turn efficient. Let's have a little friendy competition to see just how small an amtrak script can be made to be. I know we can do get it down under 30 lines of code. Or gasp... 20? For now, we'll not worry too much about turn-efficiency, but it needs to stick to the MSLs, and completely surround them with figs. If it lays a few extra figs or backtracks some, no biggie. We'll assume a starting point of Stardock, and that all Class 0's are known (read: in the database). We can also assume enough starting figs on our ship so as not to need a refill. Bonus points for turn efficiency. One gotcha to watch out for... it can't attempt to lay a fig in FedSpace... OUCH! Edit: I just wrote a quick, very unsafe, 31-liner, which I'll post tomorrow, but that isn't even with much effort. I'm guessing we can trim it way down. Enjoy, +EP+ |
|
| Author: | Helix [ Fri Feb 05, 2010 1:21 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
Can we call another script to save lines of code? For instance, call a surround script. Helix |
|
| Author: | Maniac [ Fri Feb 05, 2010 5:51 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
Helix wrote: Can we call another script to save lines of code? For instance, call a surround script. Helix I get Second place My script is Load ShortestAmtrackIntheUniverse.ts halt |
|
| Author: | Parrothead [ Fri Feb 05, 2010 11:53 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
For an amtrak to work you need to surround All of fedspace with figs (sectors 1 - 10) not just the msl's. |
|
| Author: | ElderProphet [ Fri Feb 05, 2010 7:13 pm ] |
| Post subject: | Re: Script Challenge - Amtrak |
Clearly, it has to be a proper amtrak, meaning fed (1-10 & SD) and the MSLs (SD<->1, SD<->AC, SD<->Rylos, Rylos<->AC) must be fully encased by figs. No, you can't link to an external script, but you can integrate it and access it via gosub. Surely, someone wants to take a stab at it, right? |
|
| Author: | mob [ Fri Feb 05, 2010 8:00 pm ] |
| Post subject: | Re: Script Challenge - Amtrak |
yes let the monsters awake!! Dont give us your example yet! |
|
| Author: | Kaus [ Fri Feb 05, 2010 10:12 pm ] |
| Post subject: | Re: Script Challenge - Amtrak |
Ill bite, but it will be acouple of days till ill have the time to take a stab. Like parrot id prefer if you wait to post your 33 line. Maybe a deadline of Monday? What's the starting sector as a standard? |
|
| Author: | ElderProphet [ Sat Feb 06, 2010 12:42 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
The starting point is Stardock. I'll hold off on my post till you guys have had a little time to work on it. I did a little outside-the-box thinking and shaved a few more lines, and I'm sure many more will come off before it's done. That is what I enjoy, approaching a problem from every angle till you end up with something you're surprised by. I wrote a 19-line version that almost worked! And I bet the end result will be even smaller. |
|
| Author: | Singularity [ Sat Feb 06, 2010 1:21 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
Ok, a few thoughts from EP, a little work... I've gotten this. Now, who can beat it? Code: setVar $targets " 1 2 3 4 5 6 7 8 9 10 1 " & STARDOCK & " " & ALPHACENTAURI & " " & STARDOCK & " " & RYLOS & " " & STARDOCK & " " & RYLOS & " " & ALPHACENTAURI & " " & RYLOS & " " & STARDOCK & " " setVar $step 1 :step getWord $targets $next_step $step "%%%%" if ($next_step <> "%%%%") getCourse $path CURRENTSECTOR $target setVar $i 2 while ($i <= ($path + 1)) send "mz" & $path[$i] & "*nn* z a 99999 * j x n f q z 1 * z c d z * " setVar $c 1 while ($c <= SECTOR.WARPCOUNT[$path[$i]]) setVar $targets $targets & " " & SECTOR.WARPS[$path[$i]][$c] add $c 1 end add $i 1 end add $step 1 goto :step end |
|
| Author: | Mind Dagger [ Sat Feb 06, 2010 2:48 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
Wow, that is a nice little script. I do see one way to shorten it up one line since undeclared variables can be considered to have a value of zero. Code: setVar $targets " 1 2 3 4 5 6 7 8 9 10 1 " & STARDOCK & " " & ALPHACENTAURI & " " & STARDOCK & " " & RYLOS & " " & STARDOCK & " " & RYLOS & " " & ALPHACENTAURI & " " & RYLOS & " " & STARDOCK & " " :step getWord $targets $next_step ($step + 1) "%%%%" if ($next_step <> "%%%%") getCourse $path CURRENTSECTOR $target setVar $i 2 while ($i <= ($path + 1)) send "mz" & $path[$i] & "*nn* z a 99999 * j x n f q z 1 * z c d z * " setVar $c 1 while ($c <= SECTOR.WARPCOUNT[$path[$i]]) setVar $targets $targets & " " & SECTOR.WARPS[$path[$i]][$c] add $c 1 end add $i 1 end add $step 1 goto :step end |
|
| Author: | Singularity [ Sat Feb 06, 2010 3:27 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
Really? Hrm. I don't see a way to forgo initializing $i, since it would grow to random sizes depending on the course. And I don't see a way to avoid initializing $c, since it would grow for the same reason. Care to share? |
|
| Author: | Promethius [ Sat Feb 06, 2010 5:03 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
It is the "step" var used in getWord $targets $next_step ($step) "%%%%" that MD is talking about. You init it as 1 a couple of lines before that. |
|
| Author: | Maniac [ Sat Feb 06, 2010 5:48 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
Singularity wrote: Ok, a few thoughts from EP, a little work... I've gotten this. Now, who can beat it? Code: setVar $targets " 1 2 3 4 5 6 7 8 9 10 1 " & STARDOCK & " " & ALPHACENTAURI & " " & STARDOCK & " " & RYLOS & " " & STARDOCK & " " & RYLOS & " " & ALPHACENTAURI & " " & RYLOS & " " & STARDOCK & " " setVar $step 1 :step getWord $targets $next_step $step "%%%%" if ($next_step <> "%%%%") getCourse $path CURRENTSECTOR $target setVar $i 2 while ($i <= ($path + 1)) send "mz" & $path[$i] & "*nn* z a 99999 * j x n f q z 1 * z c d z * " setVar $c 1 while ($c <= SECTOR.WARPCOUNT[$path[$i]]) setVar $targets $targets & " " & SECTOR.WARPS[$path[$i]][$c] add $c 1 end add $i 1 end add $step 1 goto :step end Couple quick thoughts before going to work? I thought MSL's were between 1-SD 1-AC 1-Ry and AC-SD-RY I don't see the path between 1 and anywhere but SD I also don't see the sentinel "%%%%" being in the targets string But maybe my brain cell in charge of logical thinking has died due to my use of alcohol. |
|
| Author: | Singularity [ Sat Feb 06, 2010 6:23 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
Promethius wrote: It is the "step" var used in getWord $targets $next_step ($step) "%%%%" that MD is talking about. You init it as 1 a couple of lines before that. Ohh... ok. Good catch. Change made... Code: setVar $targets " 1 2 3 4 5 6 7 8 9 10 1 " & STARDOCK & " " & ALPHACENTAURI & " " & STARDOCK & " " & RYLOS & " " & STARDOCK & " " & RYLOS & " " & ALPHACENTAURI & " " & RYLOS & " " & STARDOCK & " " :step add $step 1 getWord $targets $next_step $step "%%%%" if ($next_step <> "%%%%") getCourse $path CURRENTSECTOR $next_step setVar $i 2 while ($i <= ($path + 1)) send "mz" & $path[$i] & "*nn* z a 99999 * j x n f q z 1 * z c d z * " setVar $c 1 while ($c <= SECTOR.WARPCOUNT[$path[$i]]) setVar $targets $targets & " " & SECTOR.WARPS[$path[$i]][$c] add $c 1 end add $i 1 end goto :step end Quote: I thought MSL's were between 1-SD 1-AC 1-Ry and AC-SD-RY I don't see the path between 1 and anywhere but SD I also don't see the sentinel "%%%%" being in the targets string 1 to AC, 1 to Ry (and back) isn't part of the msl, is it? I believe it's 1 to dock, dock to alpha, dock to rylos, rylos to alpha. If this turns out to be wrong, I can add to the targets string easily enough. %%%% Isn't in the targets string on purpose, getWord has a default value that you can assign. Take a look... http://www.navhaz.com/files/script.html#CMD_27 Ok, so 18 lines. Come on, someone can beat it... |
|
| Author: | Vid Kid [ Sat Feb 06, 2010 8:16 am ] |
| Post subject: | Re: Script Challenge - Amtrak |
The MSL is tera to dock , dock to tera then (trianglate dock , alpha , rylos) : dock to rylos and back. : dock to alpha and back. : rylos to alpha and back. Amtrack is all the sectors around the edge of all these sectors plus sector's around 1 though 10. |
|
| Page 1 of 4 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|