Captain Forever: URL decryption

A forum for good logic/math puzzles.

Moderators: jestingrabbit, Moderators General, Prelates

User avatar
Weeks
Hey Baby, wanna make a fortnight?
Posts: 1946
Joined: Sat Aug 23, 2008 12:41 am UTC
Location: Alien-lizard city, Panama

Captain Forever: URL decryption

Postby Weeks » Thu Jan 21, 2010 10:12 pm UTC

The game's called Captain Forever. You control a basic ship (called the command module) and obtain specialized parts to customize and improve your ship. Here's the link to the game: http://www.captainforever.com/captainforever.php

Once you start playing, you can export your ship to one of the formats listed. It includes all the ship parts you have attached to your ship, though I haven't verified if it records each part's state (i.e.: amount of energy left, in J).

Now the interesting part: some friends* and I have figured out a couple of things about it:
The URL for saved or "cloned" ships obeys a certain pattern:
http://www.captainforever.com/captainforever.php?cfe={code}, where {code} should be replaced with:
  1. nqlb, which provides with a standard command module (replacing n with another character yields different starting ships, but those yet tested are glitchy; replacing the rest of the sequence results in the ship appearing in different places at the beginning);
  2. a string of alphanumeric characters, which specifies the parts attached to the ship;
  3. a terminating character.

To get different starting ships one could just alter the code of part 2 (and maybe 3, I'm not sure what different terminating characters do). That's the part I'm most interested in.

Parts are categorized based on the NATO phonetic alphabet. Also they go in ascending order regarding overall performance: Alpha is the weakest/worst type of part, while Kilo is the strongest/best.

So to have a basic ship with a Kilo Booster in the back, one should enter:
http://www.captainforever.com/captainforever.php?cfe=nqlb4bb3lt
Basically, the code is segmented into five character parts, where the first character indicates the kind of part (laser, prismatic laser, booster, girder, blurst shield) and the second character indicates it's quality (alpha, bravo, etc.). I'm not sure about the other three. So in this example, 4 would be a booster, b would be kilo, b3l would indicate rear of the command module.

The thing is, for adding other parts, the code changes. It seems it takes the code for a part attached to the command module directly, then applies some sort of encryption. Apparently it is XOR encryption:
Spoiler:
The code changes based on position based on because the url has simple XOR encryption (I think) on it. Using this you can get the a second modules code if you know the code for what it would be if it where the first.
I know that's badly explained so I'll show show you what I mean.

Pretend you want a ship with just a kilo booster and a kilo laser (nqlb-4bb3l-iawnr)
We know that a ship with a kilo booster on the back is nqlb-4bb3l as it was helpfully posted earlier on.
We know that a ship with a kilo laser on the front is nqlb-dbbth as it was helpfully posted earlier on.
We XOR dbbth with the HEX 0D19151A1A (alpha laser in first XOR alpha laser in second ) giving us i{wnr
We wrap any characters that aren't alphanumeric, in this case { is at the end of the lower case letters so it is reasonable to assume it wraps to 'a' rather than '0'
We put it together getting nqlb-4bb3l-iawnr which I had previously derived through trial and error.
Thanks to xulaus for this info.


We figured out some codes for the basic parts.
Spoiler:

Code: Select all

nqlbdtbtht laser alpha (front)
nqlbdcbtht laser bravo (front)
nqlbdebtht laser charlie (front)
nqlbdbbtht laser kilo (front)

nqlbdtb3lt laser alpha (back)
nqlbdta2ln laser alpha (starboard)
nqlbdtnagn laser alpha (port)
nqlbdtbtht laser alpha (front)

nqlb4tb3lt booster alpha (back)
nqlb4ta2ln booster alpha (starboard)
nqlb4tnagn booster alpha (port)
nqlb4tbtht booster alpha (front)

nqlbqnb3lt girder alpha (back)
nqlbqna2ln girder alpha (starboard)
nqlbqnnagn girder alpha (port)
nqlbqnbtht girder alpha (front)

below: in brackets refers to nodes attached to the node immediately "above" it in bracket heirarchy (ie in one less pair of brackets), with the idea that it's impossible to attach something to the rear of anything but a command nodule. so "alpha girder, starboard (alpha laser, front)" has the laser pointing directly to starboard of the command nodule.

nqlbqnbtht : alpha girder, front
nqlbqnbthimwtr : alpha girder, front (alpha laser, front)
nqlbqnbthinxnu : alpha girder, front (alpha laser, port)
nqlbqnbthixwnf : alpha girder, front (alpha laser, starboard)
nqlbqna2ln : alpha girder, starboard
nqlbqna2lhhwbe : alpha girder, starboard (alpha laser, front)
nqlbqna2lhxwnr : alpha girder, starboard (alpha laser, port)
nqlbqna2lhxwa5 : alpha girder, starboard (alpha laser, starboard)
nqlbqnb3lt : alpha girder, rear
nqlbqnb3limw25 : alpha girder, rear (alpha laser, front)
nqlbqnb3lixwae : alpha girder, rear (alpha laser, port)
nqlbqnb3linxat : alpha girder, rear (alpha laser, starboard)
nqlbqnnagn : alpha girder, port
nqlbqnnaghhxbt : alpha girder, port (alpha laser, front)
nqlbqnnaghnxa5 : alpha girder, port (alpha laser, port)
nqlbqnnaghnxnr : alpha girder, port (alpha laser, starboard)


More stuffs:
Spoiler:
JBJ wrote:I've been trying to figure the URL scheme out.
I think the format is along the lines of (X)(YYY)(XX)(YYY)(XX)(YYY)(XX)(YYY)...(XX)(YYY)(T)
Where (XX) defines the module type, (YYY) indicates position/orientation, and (T) is a terminator but also seems to have some effect on position/orientation for the last module. The number of (YYY)'s seems to vary depending on the value, but are usually 3.

For example, this simple configuration nqlbqnnagn
Is the nemesis with an alpha girder attached to its port side.
n = nemesis command module
qlb = nemesis position/orientation
qn = alpha girder
nag = alpha girder position/orientation
n = terminator (has some effect on position/orientation)

If I change the qn to different values, I get a whole range of different items.
Another thing I've learned is that not all modules are the same. Playing with different values, I've gotten multiple variations of the same lasers/girders.
In the above example, changing qn to qa, qk, qm, or qq each gives me a Kilo class girder. The mass and durability of each is different.
qa = 30,000kg, 65,536,000 J
qk = 20,000kg, 4,096,000 J
qm = 25,000kg, 8,192,000 J
qq = 25,000kg, 32,768,000 J

Same thing for lasers and thrusters. Lasers don't seem to vary in weight. They are always 1,000kg.
Firepower and durability can be awesome. For example, qb gives a prismatic Kilo laser that fires an astounding 49,152,000 J (x3).

One fun ship I ended up with was this: Simple ship with massive booster and super laser. Code = nqlb46b3libwnr
The thruster produces 1,920,000 N, which gives a d(x/y) in the 900's at full thrust.
The laser is a Kilo class that fires a paltry 2,048,000 J, but does have a firing rate of 4Hz.
It doesn't corner well, but has amazing acceleration.


Let's see if we can get an awesome ship. =)

*In no particular order: LE4dGOLEM, TaintedDeity, Whelan, the tree, JBJ, xulaus, Wyvern, KrazyerKate, rath358 and nbonaparte.
suffer-cait wrote:One day I'm gun a go visit weeks and discover they're just a computer in a trashcan at an ice cream shop.
Kewangji wrote:I'd buy you chili ice cream if you were here, or some other incongruous sweet.
natraj wrote:i have a bizarre mental block against the very idea of people enjoying mint and chocolate together.

User avatar
Josephine
Posts: 2142
Joined: Wed Apr 08, 2009 5:53 am UTC

Re: Captain Forever: URL decryption

Postby Josephine » Mon Jan 25, 2010 9:28 am UTC

nothing, guys?
Belial wrote:Listen, what I'm saying is that he committed a felony with a zoo animal.

User avatar
Tunga
Posts: 23
Joined: Tue Aug 19, 2008 10:30 am UTC
Contact:

Re: Captain Forever: URL decryption

Postby Tunga » Mon Jan 25, 2010 1:12 pm UTC

I realise you could argue that the URL encryption is interesting regardless of the purpose but it doesn't seem like the kind of game that's it really worth cheating at.

I'm actually more interested in how to build a good ship. I always seem to end up with something that can't turn properly!

User avatar
LE4dGOLEM
is unique......wait, no!!!!
Posts: 5972
Joined: Thu Oct 12, 2006 7:10 pm UTC
Location: :uoıʇɐɔol

Re: Captain Forever: URL decryption

Postby LE4dGOLEM » Wed Jan 27, 2010 4:07 pm UTC

Put boosters on the front as well as the back, and make sure that boosters are always balanced.
And any game is worth cheating at, if it means a puzzle :P
Image Une See Fights - crayon super-ish hero webcomic!
doogly wrote:It would just be much better if it were not shitty.

ttnarg
Posts: 39
Joined: Tue Jan 05, 2010 5:50 pm UTC

Re: Captain Forever: URL decryption

Postby ttnarg » Fri Jan 29, 2010 10:55 am UTC

Edit2: All worked out.

Spoiler:

Code: Select all

0 = 00110   00000 = b
1 = 11010   00001 = w
2 = 01000   00010 = l
3 = 01100   00011 = g
4 = 11001   00100 = p
5 = 01001   00101 = s
a = 10000   00110 = 0
b = 00000   00111 = c
c = 00111   01000 = 2
d = 11011   01001 = 5
e = 01011   01010 = j
f = 10011   01011 = e
g = 00011   01100 = 3
h = 11101   01101 = i
i = 01101   01110 = y
j = 01010   01111 = t
k = 10010   10000 = a
l = 00010   10001 = v
m = 11100   10010 = k
n = 11111   10011 = f
o = 10100   10100 = o
p = 00100   10101 = r
q = 11000   10110 = z
r = 10101   10111 = u
s = 00101   11000 = q
t = 01111   11001 = 4
u = 10111   11010 = 1
v = 10001   11011 = d
w = 00001   11100 = m
x = 11110   11101 = h
y = 01110   11110 = x
z = 10110   11111 = n



some types:

Code: Select all

000-1111 green tri Gun
001-1111 green beam 
010-1111 green Truster
011-1111 Gun less CS   
100-1111 green shield
101-1111 info bubble
110-1111 green gun     
111-1111 command ship

001-0111 Girder 1-1 brovo
001-1011 Girder 1-1 charlie
001-1111 Girder 1-1 Alpha

001-0000 Girder 1-6 kilo
001-0001 Girder 1-3 hotel
001-0010 Girder 1-4 kilo
001-0011 Girder 1-2 delta
001-0100 Girder 1-5 kilo
001-0101 Girder 1-2 foxtrot
001-0110 Girder 1-4 juliet
001-0111 Girder 1-1 brovo
001-1000 Girder 1-5 kilo
001-1001 Girder 1-3 golf
001-1010 Girder 1-4 kilo
001-1011 Girder 1-1 charlie
001-1100 Girder 1-5 kilo
001-1101 Girder 1-2 echo
001-1110 Girder 1-3 India
001-1111 Girder 1-1 Alpha


start pos = (64, 64)

dir to link
^ 00
v 10
> 11
< 01

> X+
v Y+


Bit format
7 bits for Type
7 bits for Y pos
7 bits for X Pos
2 bits for Diration

Example:
A command ship with 2 Girder, 2 guns and 3 Thusters

Code: Select all

| |
X@X
^^^

Command Ship  Pos(64,64) Dir(v)
left Girder   Pos(63,64) Dir(>)
Right Girder  Pos(65,64) Dir(<)
Left Gun      Pos(63,63) Dir(v)
Right Gun     Pos(65,63) Dir(v)
Left thuster  Pos(63,65) Dir(^)
Mid thuster   Pos(64,65) Dir(^)
Right thuster Pos(65,65) Dir(^)

1111111 0000001 0000001 10
0011111 1111110 0000001 11
0011111 1000001 0000001 01
1101111 1111110 1111110 10
1101111 1000001 1111110 10
0101111 1111110 1000001 00
0101111 0000001 1000001 00
0101111 1000001 1000001 00

Group in blocks of 5

11111 11000 00010 00000 11000 11111 11111 10000
00011 10011 11110 00001 00000 01011 10111 11111
11011 11110 10110 11111 00000 11111 11010 01011
11111 11101 00000 10001 01111 00000 01100 00010
00101 11110 00001 10000 01001  <- (we padded the end with a 1 so we have a full group, we could use 0 but the games uses 1s)

look up the 5 bit groups and swap in the letters

nqlbqnna
gfxwbeun
dxznbn1e
nhbvtb3l
sxwa5

http://www.captainforever.com/captainfo ... vtb3lsxwa5


Nine step guide to working it out.
Spoiler:
Step one: look at the letters and numbers used in the code and see how meny there are and work out the number of bits per letter
Step two: make a number of diffent size ships so we can work out the number a bits per module
Step three: make a number of simlier ships with just one diffences at a time to work out which bit controls what
Step four: use make a ship such that the last module can be place faceing any diration and right number of modules such that the diraction code the only bits in the last letter of the URL, change the last letter in the URL going throw all of the range noting the diration of the last module
Step five: do the same with the base ship (cfe=nqlbd) this will be setting one bit of the Y pos but this dose not seem to change the starting ships pos.
Step six: use these 2 to work out the first 3 bits of each letter.
Step seven: make a number a simple ships with the first 4 alpha Girders and use these to work out some more of the bits when unknowen bits fall over know diration.
Step eight: After repeating step seven, about 4 times I was able to guess ever thing about what the bits in each ship should look like, which spead up filling in the bits
Step Nine: the final bits were filled in by sorting the table by the bits and match the unknowens with the gaps in the table.


Epic ship will be posted when I get around to making a tool to make one, I'm not going to work out anything that big by hand.

Also if anyone wants to post a full table of the types of modules that would be nice I only looked up a small percentage, there are a lot more.

ttnarg
Posts: 39
Joined: Tue Jan 05, 2010 5:50 pm UTC

Re: Captain Forever: URL decryption

Postby ttnarg » Sat Jan 30, 2010 9:49 pm UTC

I give you the XKCD battler cuuiser:
http://www.captainforever.com/captainfo ... bgkbob5agn

Code: Select all

http://www.captainforever.com/captainforever.php?cfe=
nqlbqna2lknxbyeopw5xnbcsxlbouuagkmvbjtfqw4n2assxmbmu32lkhybytxpw5ncbcsqkbougagkx
5bjtxqw4xoassd3bmub3llmwnoeaswwybu1sqgaaubihgxwa2en1wwtbn1cnhn2najllnx22eqsxvtnc
1smgaannzllxwuoen1xvyaqpsdhban2thlhxnoeoswwxnpps1ln2utfhghwq2eudwwyad1sdht2uq3lg
xxa2tmcxvttt1sxlaauukllnwtoed4xvnampshhaauqihlxxuoek0wwxt2pc4gn2ncuhlmv22tf4wwy2
u1c4mn2npylgmxq2ek0xvxte1shgbaudollxvnoehdxvn2opsxmaauoehlnytoe1cwwtu3pshgt2udrh
lhva2er1wwyqn1c1hn2u3jllhy22ezsxvyuc1sdgaanezllhvuoer1xvnqqpsmhbaumthlxynotxswwn
cppsnln2uffhlnvq2e4dwwtqd1smht2ul3lgmya2tvcxvyct1sqkaaugkllm5toev4xvxpmpsqhaauli
hlmyuoe40wwtd2pcmfn2uhuhlx522tx4wwtpu1sn3n2nkyllnzq2e40xvtde1c1fbauiolgh5notzdxv
xoopsd3aanjehlhztotrcwwxd3pc1ft2uirhln5bjefpw5t3assh3bmusagkn0byeapvwyb1psqlqaub
5hlmwdoeasyvtbr4snmu3uaelknx3yeosy5ynsds1lqoutfgknweked4y4tazsshmqmupjmkmxezeksv
5yt0cshlupudkhkxv3jeh4v4yqr4s1mu3u3elkhy3yexsy5tcsdsnlqouffgkm5ekev4y4ypzssqmqmu
kjmknzeze4sv5td0cs1kupuikhkh53jez4v4tor4sh3u3u1elkxz3yefsy5yesds4kqousfgkx4a2edc
xvtf2psxin2uzjllx4toem4wwtfc1shfaauzihln0q2em1xvt3kpshkt2u4vlln0coed0vwt3h1sxi2a
u4zhlx432edsyvtf0psx3u5b03gob4nzal1wjbet42wkahb0ehobz2jal4xjb3mc2wftibszlobzukag
pv1b3fd2w32rbsvmob4oyagcy1bejs2wiusb13log5nkaj1w1wetd20karb1emolz2yaj4x1woms20ft
sbrzgolzuza2cylwniq2pg24bnrgpwwdaacdylba102gh24bqymplxdaa30vkwtj02wguwbczmpbvo3a
g1vkw2hq20huwboigpgyo3a0cylbuiq2gg24bergpgvdaa5dylwq102ph24blympbydaaw0vkbcj02pf
uwbhzmpl5o3ay1vkbohq2giuwbjigpwzo3aicylweiq20f24brrgplwcoatqxkwbkp2cm2vb25hpwxco
appvlbnlp20lt5buvhpgwp2aeqvlb2f12wmt5bp5lpbxp2ajpxkwug12sl2vbdvlpwvcoasqxkbqkp2l
m2vbm5hplycoaypvlwclp2bkt5bgvhpb5p2awqvlwpf12c3t5bk5lpgzp2aspxkbdg12lk2vbivlblwf
obt1yawbxpbchqab23hbwxfobpcvbbnypb0gc2buohbgwm2bedvbb241bwhc2bptlbbxm2bj0yawu51b
sgqabdulbwvfobs1yabqxpblhqabm3hblyfobycvbwcypbbfc2bgohbb5m2bwdvbwp41bcic2bktlbgz
m2bs0yabd51blfqabiulbg5fobj1yawoxpbsiqab03hbbzfobgcvbbeypbsfc2b4ohbl4m2b3dvbbb41
bbgqaby3law4nkbp1wqbftdbgkaobyemaw02ybp4xqbmmsbgftpb5zgaw0uzbcpv2bmf4bl32mb5vhaw
4ojbccy2bfjcbliu3byelaw4ekbp4vqbfsdbgkbob5agn

User avatar
Josephine
Posts: 2142
Joined: Wed Apr 08, 2009 5:53 am UTC

Re: Captain Forever: URL decryption

Postby Josephine » Mon Feb 01, 2010 7:52 am UTC

wow. Damn. that works nicely. I was wondering how to figure out how to place a part in a specific spot. that ship is indestructible!
Belial wrote:Listen, what I'm saying is that he committed a felony with a zoo animal.

ttnarg
Posts: 39
Joined: Tue Jan 05, 2010 5:50 pm UTC

Re: Captain Forever: URL decryption

Postby ttnarg » Mon Feb 01, 2010 9:54 am UTC

how to place a part in a specific spot:
Spoiler:
here is the bit code for the command ship:
1111111 0000001 0000001 10

The first 7 bits is the type

the next 7 is the X pos the first bit have the least value ie 1, the next is 2 the next is 4, then 8, then 16, then 32, then 64
As you can see only the 64 bit is set giving it a position on 64 and the same for Y Pos
the last 2 bits is the diration pointing towards the link... well the back of the part, this part is not linked.

To position a part in front of this you need to lower the Y pos by 1.
this would be:
Type XPos(64) YPos(63) link part below this one
XXXXXXX 0000001 1111110 10

Above that one would be
XXXXXXX 0000001 0111110 10

Above that one would be
XXXXXXX 0000001 1011110 10


Your best bet to understanding this is to make a simple ship using the starting blocks export it and then decode it.

User avatar
Weeks
Hey Baby, wanna make a fortnight?
Posts: 1946
Joined: Sat Aug 23, 2008 12:41 am UTC
Location: Alien-lizard city, Panama

Re: Captain Forever: URL decryption

Postby Weeks » Mon Feb 01, 2010 3:58 pm UTC

ttnarg, you are very awesome. =D
suffer-cait wrote:One day I'm gun a go visit weeks and discover they're just a computer in a trashcan at an ice cream shop.
Kewangji wrote:I'd buy you chili ice cream if you were here, or some other incongruous sweet.
natraj wrote:i have a bizarre mental block against the very idea of people enjoying mint and chocolate together.

Ended
Posts: 1459
Joined: Fri Apr 20, 2007 3:27 pm UTC
Location: The Tower of Flints. (Also known as: England.)

Re: Captain Forever: URL decryption

Postby Ended » Mon Feb 01, 2010 8:23 pm UTC

Wow, I just noticed the lettering on the ship. Top work ttnarg!
Generally I try to make myself do things I instinctively avoid, in case they are awesome.
-dubsola

User avatar
Slpee
Posts: 69
Joined: Fri Jan 15, 2010 12:51 am UTC
Location: Cloud 9, just all the time.

Re: Captain Forever: URL decryption

Postby Slpee » Tue Feb 02, 2010 1:44 am UTC

nbonaparte wrote:wow. Damn. that works nicely. I was wondering how to figure out how to place a part in a specific spot. that ship is indestructible!



sadly..it is not

evidently it is bad to charge 5 peacekeepers, even in the battlecruiser
"Are you insinuating that a bunch of googly eyes hot-glued to a Cheeto constitutes a sapient being?"
Can't let you brew that Starbucks!


Image

User avatar
Josephine
Posts: 2142
Joined: Wed Apr 08, 2009 5:53 am UTC

Re: Captain Forever: URL decryption

Postby Josephine » Tue Feb 02, 2010 6:52 am UTC

yeah, I learned this. I got my entire front wall knocked off. Then the other side. then they broke through to the command module. I think those outer walls need thickening.
Belial wrote:Listen, what I'm saying is that he committed a felony with a zoo animal.

ttnarg
Posts: 39
Joined: Tue Jan 05, 2010 5:50 pm UTC

Re: Captain Forever: URL decryption

Postby ttnarg » Tue Feb 02, 2010 11:48 am UTC

Well the main thing about that ship is the letters in the middle so I wanted to use 1x1 size Girder which are weak. I could of used stronger ones for the out side ring but I spelt out xkcd in the middle and thats realy all I care about. If I wanted to make a strong ship I would of gone for a diffent lay out. The thursters and guns where only added as an after thought.

Edit: Maybe your right a strong ship would be good, also the writing on my first one is hard to read.
Keep watching this space.

User avatar
JBJ
Posts: 1263
Joined: Fri Dec 12, 2008 6:20 pm UTC
Location: a point or extent in space

Re: Captain Forever: URL decryption

Postby JBJ » Tue Feb 02, 2010 7:23 pm UTC

ttnarg, you rock!

I mapped out the module types. The repeat in groups of 16 in the following order:
Kilo / Hotel / Kilo / Delta / Kilo / Foxtrot / Juliet / Bravo / Kilo / Golf / Kilo / Charlie / Kilo / Echo / India / Alpha

0000000 - 0001111 = Prism Lasers
0010000 - 0011111 = Girders
0100000 - 0101111 = Boosters
0110000 - 0111111 = Command Modules
1000000 - 1001111 = Blurst shields
1010000 - 1011111 = Info Buoys
1100000 - 1101111 = Regular lasers
1110000 - 1111111 = Alpha Command Modules

The various Kilo class girders/lasers/boosters, are of various weight, power, shielding.
I've written a graphical ship building utility using ttnarg's methods with HTML and javascript. I'll have it posted here as soon as I polish it up.


Edit - As promised, here's the utility: (tested in Firefox 3.5 and IE 7. Javascript must be enabled)
Spoiler:

Code: Select all

<html>
<head>
<title>Cpt. Forever - Ship Building Utility</title>
</head>
<style>
   td{border:1px solid black; cursor:hand; text-align:center;}
</style>
<script Language="JavaScript">
   var ship_bit_code = '11111110000001000000110';
   
   function drawgrid()
   {
      
      var ghtm = '<table border=0>';
      for (y = 49; y < 79; y++)
         {
         ghtm += '<tr>';
         for (x = 44; x < 84; x++)
            {
            ghtm += '<td id=x' + x + 'y' + y + ' onClick=build(' + x + ',' + y + ');>&nbsp;&nbsp;&nbsp;</td>';
            }
         ghtm += '</tr>';
         }
      ghtm += '</table>';
      grid.innerHTML = ghtm;
      
      x64y64.innerHTML = '<font color=red style=background-color:red;><b>@</b></font>';
   }
   
   function build(xc, yc)
   {
      var type_code = module.value.substring(module.value.length - 7, module.value.length);
      
      ship_bit_code += type_code + d2b(xc) + d2b(yc) + attach.value;
      if(module.value.substring(0,1) == 'g')
         {
            if(attach.value == '01')
               for (i = 1; i <= module.value.substring(1,2); i++)
                  {
                     var oE = document.getElementById('x' + (xc+i-1) + 'y' + yc);
                     oE.innerHTML = '<font color=blue style=background-color:blue;><b>@</b></font>';
                  }
            if(attach.value == '11')
               for (i = 1; i <= module.value.substring(1,2); i++)
                  {
                     var oE = document.getElementById('x' + (xc-i+1) + 'y' + yc);
                     oE.innerHTML = '<font color=blue style=background-color:blue;><b>@</b></font>';
                  }
            if(attach.value == '00')
               for (i = 1; i <= module.value.substring(1,2); i++)
                  {
                     var oE = document.getElementById('x' + xc + 'y' + (yc+i-1));
                     oE.innerHTML = '<font color=blue style=background-color:blue;><b>@</b></font>';
                  }
            if(attach.value == '10')
                  for (i = 1; i <= module.value.substring(1,2); i++)
                  {
                     var oE = document.getElementById('x' + xc + 'y' + (yc-i+1));
                     oE.innerHTML = '<font color=blue style=background-color:blue;><b>@</b></font>';
                  }
         }
            
      if(module.value.substring(0,1) == 'l')
         {
            var oE = document.getElementById('x' + xc +'y' + yc);
            if(attach.value == '01')
               oE.innerHTML = '<font color=red><b>[=</b></font>';
            if(attach.value == '11')
               oE.innerHTML = '<font color=red><b>=]</b></font>';
            if(attach.value == '00')
               oE.innerHTML = '<font color=red><b>||</b></font>';
            if(attach.value == '10')
               oE.innerHTML = '<font color=red><b>||</b></font>';
         }
         
      if(module.value.substring(0,1) == 'b')
         {
            var oE = document.getElementById('x' + xc +'y' + yc);
            if(attach.value == '01')
               oE.innerHTML = '<font color=black><b>&lt;</b></font>';
            if(attach.value == '11')
               oE.innerHTML = '<font color=black><b>&gt;</b></font>';
            if(attach.value == '00')
               oE.innerHTML = '<font color=black><b>/\\<b></font>';
            if(attach.value == '10')
               oE.innerHTML = '<font color=black><b>\\/</b></font>';
         }
   }
   
   function make_url_string()
   {
      var diff = 5 - (ship_bit_code.length % 5);
      if (ship_bit_code.length % 5 > 0)
         for (i = 1; i <= diff; i++)
            ship_bit_code += '1';
      var url_code = '';
      var bc = '';
      var t = '';
      for (i = 0; i < ship_bit_code.length; i = i + 5)
      {
         bc = ship_bit_code.substring(i, i+5);
         if (bc == '00000') t = 'b';
         if (bc == '00001') t = 'w';
         if (bc == '00010') t = 'l';
         if (bc == '00011') t = 'g';
         if (bc == '00100') t = 'p';
         if (bc == '00101') t = 's';
         if (bc == '00110') t = '0';
         if (bc == '00111') t = 'c';
         if (bc == '01000') t = '2';
         if (bc == '01001') t = '5';
         if (bc == '01010') t = 'j';
         if (bc == '01011') t = 'e';
         if (bc == '01100') t = '3';
         if (bc == '01101') t = 'i';
         if (bc == '01110') t = 'y';
         if (bc == '01111') t = 't';
         if (bc == '10000') t = 'a';
         if (bc == '10001') t = 'v';
         if (bc == '10010') t = 'k';
         if (bc == '10011') t = 'f';
         if (bc == '10100') t = 'o';
         if (bc == '10101') t = 'r';
         if (bc == '10110') t = 'z';
         if (bc == '10111') t = 'u';
         if (bc == '11000') t = 'q';
         if (bc == '11001') t = '4';
         if (bc == '11010') t = '1';
         if (bc == '11011') t = 'd';
         if (bc == '11100') t = 'm';
         if (bc == '11101') t = 'h';
         if (bc == '11110') t = 'x';
         if (bc == '11111') t = 'n';
         url_code += t;
      }
      urlc.innerHTML = 'http://www.captainforever.com/captainforever.php?cfe=' + url_code;
      url_link.innerHTML = "<a href=http://www.captainforever.com/captainforever.php?cfe=" + url_code + ">Fly this ship</a>"
   }
   
   function d2b(n)
   {
      var b = '';
      if(n & 1) b+='1'; else b+='0';
      if(n & 2) b+='1'; else b+='0';
      if(n & 4) b+='1'; else b+='0';
      if(n & 8) b+='1'; else b+='0';
      if(n & 16) b+='1'; else b+='0';
      if(n & 32) b+='1'; else b+='0';
      if(n & 64) b+='1'; else b+='0';
      
      return b;
   }
</script>
<body onload="drawgrid();">
   <center><h2>Cpt. Forever - Ship Building Utility</h2>
   By JBJ of the xkcd forums<br>
   With extra special thanks to ttnarg for working out the URL encoding scheme
   <table>
   <tr>
      <td><div id="grid"></div></td>
      <td valign="top">Module Type
         <select id="module">
         <option selected>
         <option value="">-----------PRISM LASERS--------
         <option value="l0001000">Kilo  - 4 Hz /  6 MJ / 8 MJ
         <option value="l0000010">Kilo  - 4 Hz  / 768 KJ / 1 MJ
         <option value="l0000100">Kilo  - 2 Hz / 6 MJ / 4 MJ
         <option value="l0001010">Kilo - 2Hz / 768 KJ /  512 KJ
         <option value="l0000000">Kilo - 1Hz  / 49 MJ / 16 MJ
         <option value="l0001100">Kilo - 1Hz / 6 MJ / 2MJ
         <option value="l0000110">Juliet - 1Hz /  768 KJ / 256 KJ
         <option value="l0001110">India - 4Hz / 96 KJ /  128 KJ
         <option value="l0000001">Hotel - 2 Hz / 96 KJ / 64 KJ
         <option value="l0001001">Golf  - 1Hz / 96 KJ /  32 KJ
         <option value="l0000101">Foxtrot - 4Hz / 12 KJ / 16 KJ
         <option value="l0001101">Echo - 2Hz / 12 KJ / 8 KJ
         <option value="l0000011">Delta  - 1Hz / 12 KJ / 4000 J
         <option value="l0001011">Charlie - 4Hz / 1500 J /  2000 J
         <option value="l0000111">Bravo - 2Hz / 1500 J / 1000 J
         <option value="l0001111">Alpha - 1Hz / 1500 J / 500 J
         <option value="">-----------GIRDERS------------------
         <option value="g60010000">x6 Kilo - 65 MJ
         <option value="g50011000">x5 Kilo  - 32 MJ
         <option value="g50010100">x5 Kilo - 16 MJ
         <option value="g50011100">x5 Kilo  -  8 MJ
         <option value="g40010010">x4 Kilo - 4 MJ
         <option value="g40011010">x4 Kilo - 2 MJ
         <option value="g40010110">x4 Juliet - 1 MJ
         <option value="g30011110">x3 India -  512 KJ
         <option value="g30010001">x3 Hotel - 256 KJ
         <option value="g30011001">x3 Golf - 128 KJ
         <option value="g20010101">x2 Foxtrot - 64 KJ
         <option value="g20011101">x2 Echo -  32 KJ
         <option value="g20010011">x2 Delta - 16 KJ
         <option value="g10011011">x1 Charlie  - 8000 J
         <option value="g10010111">x1 Bravo - 4 KJ
         <option value="g10011111">x1 Alpha - 2000 J
         <option value = "">----------BOOSTERS-----------------
         <option value="b0100000">Kilo -  32 MJ / 1.9 MN
         <option value="b0101000">Kilo -  16 MJ / 1.8 MN
         <option value="b0100100">Kilo -   8 MJ / 1.6 MN
         <option value="b0101100">Kilo - 4 MJ / 1.5 MN
         <option value="b0100010">Kilo -  2 MJ / 1.4 MN
         <option value="b0101010"> Kilo - 1 MJ / 1.3 MN
         <option value="b0100110">Juliet -  512 KJ / 1.2 MN
         <option value="b0101110">India - 256 KJ / 1 MN
         <option value="b0100001">Hotel -  128 KJ / 960 KN
         <option value="b0101001">Golf  - 64 KJ / 840 KN
         <option value="b0100101">Foxtrot -  32 KJ / 720 KN
         <option value="b0101101">Echo - 16 KJ /  600KN
         <option value="b0100011">Delta -  8 KJ / 480 KN
         <option value="b0101011">Charlie - 4000 J / 360 KN
         <option value="b0100111">Bravo -  2000J / 240 KN
         <option value="b0101111">Alpha - 1000 J / 120 KN
         <!--
         <option value = "">----------COMMAND MODULES-----------------
         <option value="0101111">Alpha Booster
         <option value="0110000">Kilo CM
         <option value="0110001">Hotel
         <option value="0110010">Kilo
         <option value="0110011">Delta
         <option value="0110100">Kilo
         <option value="0110101">foxtrot
         <option value="0110110">Juliet
         <option value="0110111">Bravo
         <option value="0111000">Kilo Command Module
         <option value="0111001">Golf
         <option value="0111010">Kilo
         <option value="0111011">Charlie
         <option value="0111100">Kilo CM
         <option value="0111101">Echo CM
         <option value="0111110">India CM
         <option value="0111111">Alpha CM
         -->
         <option value = "">----------BLURST SHIELDS-----------------
         <option value="g61000000">x6 Kilo
         <option value="g51001000">x5 Kilo
         <option value="g51000100">x5 Kilo
         <option value="g51001100">x5 Kilo
         <option value="g41000010">x4 Kilo
         <option value="g41001010">x4 Kilo
         <option value="g41000110">x4 Juliet
         <option value="g31001110">x3 India
         <option value="g31000001">x3 Hotel
         <option value="g31001001">x3 Golf
         <option value="g21000101">x2 Foxtrot
         <option value="g21001101">x2 Echo
         <option value="g21000011">x2 Delta
         <option value="g11001011">x1 Charlie
         <option value="g11000111">x1 Bravo
         <option value="g11001111">x1 Alpha
         <!--<option value = "">----------INFO BUOYS-----------------
         <option value="l1010000">Info Buoy
         <option value="1010001">
         <option value="1010010">
         <option value="1010011">
         <option value="1010100">
         <option value="1010101">
         <option value="1010110">
         <option value="1010111">Info Buoy
         <option value="1011000">
         <option value="1011001">
         <option value="1011010">
         <option value="1011011">
         <option value="1011100">
         <option value="1011101">
         <option value="1011110">
         <option value="1011111">Info buoy
         -->
         <option value = "">----------LASERS-----------------
         <option value="l1101000">Kilo - 4 Hz / 2 MJ / 8MJ
         <option value="l1100010">Kilo - 4 Hz / 256 KJ  / 1MJ
         <option value="l1100100">Kilo - 2 Hz / 2 MJ / 4MJ
         <option value="l1101010">Kilo - 2 Hz / 256 KJ / 512KJ
         <option value="l1100000">Kilo -  1Hz / 16 MJ / 16 MJ
         <option value="l1101100">Kilo - 1 Hz / 2 MJ / 2MJ
         <option value="l1100110">Juliet - 1 Hz / 256 KJ / 256 KJ
         <option value="l1101110">India - 4 Hz / 32 KJ / 128 KJ
         <option value="l1100001">Hotel - 2Hz / 32 KJ / 64 KJ
         <option value="l1101001">Golf - 1 Hz / 32 KJ / 32KJ
         <option value="l1100101">Foxtrot - 4 Hz / 4,000J / 16KJ
         <option value="l1101101">Echo - 2 Hz / 4000 J / 8000J
         <option value="l1100011">Delta - 1 Hz / 4,000 J / 4,000 J
         <option value="l1101011">Charlie - 4Hz / 500J / 2000J
         <option value="l1100111">Bravo - 2 Hz / 500 J / 1000 J
         <option value="l1101111">Alpha - 1 Hz / 500 J / 500J
         <!--
         <option value = "">----------CM ALPHAS-----------------
         <option value="1110000">Command Module Alpha
         <option value="1110001">
         <option value="1110010">
         <option value="1110011">
         <option value="l1110100">Command Module Alpha
         <option value="1110101">
         <option value="1110110">
         <option value="1110111">
         <option value="1111000">
         <option value="1111001">
         <option value="1111010">
         <option value="1111011">
         <option value="1111100">
         <option value="1111101">
         <option value="1111110">Command Module Alpha
         <option value="1111111">Command Module Alpha
         -->
         
         
         </select>
         <p>
         
         Attachpoint of module
         <select id="attach">
         <option value="01">left
         <option value="11">right
         <option value="00">top
         <option value="10">bottom
         </select>
         <p>
         <button onClick="make_url_string();">Make URL</button>
         <p>
         <textarea id="urlc" cols=30 rows=10></textarea>
         <span id="url_link"></span>
         <p align="left">
         To Use: <br>
         The Command Module is the Red square in the center. To attach a module, select the module type from the drop down list.<br>
         Then select the orientation of the attachment point. For instance, if you want to attach a girder to the right side of the command module,
         the attachment point would be pointing to the left, so you would choose "Left". If you want to attach a laser that shoots straight ahead,
         the attachment point would be on the bottom, so you could choose "Bottom".
         <p align="left">
         Legend:<br>
         Lasers (Prism and regular): CLASS - FIRING RATE / POWER / SHIELD<br>
         Firing rate is measured in Hz. 1, 2, or 4 times per second.
         Power is rated in Joules. Shielding also measured in Joules.<br>
         Lasers will appear in red regardless of class and appear as: =], [=, or ||
         <p align="left">
         Girders (and Blurst Shields): LENGTH - CLASS - SHIELD<br>
         Length is how many units long the girder is. All girders a 1 unit in width. The script will automatically fills out the girder to the
         appropriate length. Girders appear as blue blocks regardless of class.<br>
         Shielding is measured in Joules and indicates how much damage the girder can take.<br>
         Blurst shileds repel all incoming fire and seem to take no damage regardless of class. Shielding omitted from Blurst descriptions.
         <p align="left">
         Boosters: CLASS - SHIELD - THRUST<br>
         Shielding like before is measured in Joules. Thrust is measured in Newtons.
         <p align="left">
         <b>There is no undo or delete. If you make a mistake, just refresh the page to reset.</b>
         
   </td>
</tr>
</table>
</center>
</body>
</html>
So, you sacked the cocky khaki Kicky Sack sock plucker?
The second cocky khaki Kicky Sack sock plucker I've sacked since the sixth sitting sheet slitter got sick.

ttnarg
Posts: 39
Joined: Tue Jan 05, 2010 5:50 pm UTC

Re: Captain Forever: URL decryption

Postby ttnarg » Tue Feb 02, 2010 10:22 pm UTC

XKCD battler cuuiser Mark 2:

This ship has Kilo gurders which have more mass so this ship is slower. but its can take more damage and also when it dose lose parts it dose not fail quite as badly.
Also the the writing is easyer to read.

http://www.captainforever.com/captainfo ... jbec52w3fs


Data for this ship (for my ref and any one who is intressed):
Spoiler:

Code: Select all


char *aszDir[size] ={
   ".vvvvvvvvvvvvvvvvvvvvvvvvv ",
   ">]]]>uuuuuuuuuuuuuuuuuuuuu<",
   ">]]]>uuuuuuuuuuuuuuuuuuuuu<",
   ">]]]>uuuuuuuuuuuuuuuuuuuuu<",
   ">]]]>vvvvvvvvvvvvvvvvvvvvv<",
   ">]]]>]]]>]]]>u<[[[<[[[<[[[<",
   ">]]]>u^^^^^^^u^^^^^^^u<[[[<",
   ">]]]>u< vvvvvuvvvvv >u<[[[<",
   ">]]]>u<>u]]]>v<[[[u<>u<[[[<",
   ">]]]>u<>uu^ ^u^ ^uu<>u<[[[<",
   ">]]]>u<>uu<<>u<< uu<>u<[[[<",
   ">]]]>v<>vu ^ u<< uv<>v<[[[<",
   ">]]]>]]]>vv vvv vv<[[[<[[[<",
   ">]]]>]]]>]]]>v<[[[<[[[<[[[<",
   ">]]]>]]]>^ ^^^^^ ^<[[[<[[[<",
   ">]]]>^<>^n<  n< >n^<>^<[[[<",
   ">]]]>n<>nn<  n< >nn<>n<[[[<",
   ">]]]>n<>nn vvnvv nn<>n<[[[<",
   ">]]]>n<>n]]]>^<[[[n<>n<[[[<",
   ">]]]>n< ^^^^^n^^^^^ >n<[[[<",
   ">]]]>nvvvvvvvnvvvvvvvn<[[[<",
   ">]]]>]]]>]]]>n<[[[<[[[<[[[<",
   ">^^^^^^^^^^^^^^^^^^^^^<[[[<",
   ">nnnnnnnnnnnnnnnnnnnnn<[[[<",
   ">nnnnnnnnnnnnnnnnnnnnn<[[[<",
   ">nnnnnnnnnnnnnnnnnnnnn<[[[<",
   ".^^^^^^^^^^^^^^^^^^^^^^^^^ "};


char *aszType[size] ={
   ".LLLLLLLLLLLLLLLLLLLLLLLLL ",
   "L]]]4uuuuuuuuuuuuuuuuuuuuuL",
   "L]]]4uuuuuuuuuuuuuuuuuuuuuL",
   "L]]]4uuuuuuuuuuuuuuuuuuuuuL",
   "L]]]4444444444444444444444L",
   "L]]]4]]]4]]]4u4[[[4[[[4[[[L",
   "L]]]4uTTTTTTTuTTTTTTTu4[[[L",
   "L]]]4uT TTTTTuTTTTT Tu4[[[L",
   "L]]]4uTTu]]]444[[[uTTu4[[[L",
   "L]]]4uTTuuG GuG GuuTTu4[[[L",
   "L]]]4uTTuuGGGuGG uuTTu4[[[L",
   "L]]]46TT4u G uGG u4TT64[[[L",
   "L]]]4]]]44G G4G G44[[[4[[[L",
   "L]]]4]]]4]]]4B4[[[4[[[4[[[L",
   "L]]]4]]]44 GG4GG 44[[[4[[[L",
   "L]]]46TT4nG  nG Gn4TT64[[[L",
   "L]]]4nTTnnG  nG GnnTTn4[[[L",
   "L]]]4nTTnn GGnGG nnTTn4[[[L",
   "L]]]4nTTn]]]444[[[nTTn4[[[L",
   "L]]]4nT TTTTTnTTTTT Tn4[[[L",
   "L]]]4nTTTTTTTnTTTTTTTn4[[[L",
   "L]]]4]]]4]]]4n4[[[4[[[4[[[L",
   "L4444444444444444444444[[[L",
   "Lnnnnnnnnnnnnnnnnnnnnn4[[[L",
   "Lnnnnnnnnnnnnnnnnnnnnn4[[[L",
   "Lnnnnnnnnnnnnnnnnnnnnn4[[[L",
   ".LLLLLLLLLLLLLLLLLLLLLLLLL "};

char *aszBuildOrder[size] ={
   ".AAAAAAAAAAAAAAAAAAAAAAAAA ",
   "A]]]6uuuuuuuuuuuuuuuuuuuuuA",
   "A]]]6uuuuuuuuuuuuuuuuuuuuuA",
   "A]]]6uuuuuuuuuuuuuuuuuuuuuA",
   "A]]]6566666666666666666666A",
   "A]]]6]]]4]]]3u3[[[4[[[5[[[A",
   "A]]]6u9999999u9999999u6[[[A",
   "A]]]6u9 99999u99999 9u6[[[A",
   "A]]]6u99u]]]323[[[u99u6[[[A",
   "A]]]6u99uu7 7u7 7uu99u6[[[A",
   "A]]]6u99uu787u78 uu99u6[[[A",
   "A]]]64994u 8 u78 u49946[[[A",
   "A]]]6]]]327 717 723[[[6[[[A",
   "A]]]6]]]2]]]101[[[2[[[6[[[A",
   "A]]]6]]]32 77177 23[[[6[[[A",
   "A]]]64994n7  n7 7n49946[[[A",
   "A]]]6n99nn7  n7 7nn99n6[[[A",
   "A]]]6n99nn 77n77 nn99n6[[[A",
   "A]]]6n99n]]]323[[[n99n6[[[A",
   "A]]]6n9 99999n99999 9n6[[[A",
   "A]]]6n9999999n9999999n6[[[A",
   "A]]]5]]]4]]]3n3[[[4[[[6[[[A",
   "A6666666666666666666656[[[A",
   "Annnnnnnnnnnnnnnnnnnnn6[[[A",
   "Annnnnnnnnnnnnnnnnnnnn6[[[A",
   "Annnnnnnnnnnnnnnnnnnnn6[[[A",
   ".AAAAAAAAAAAAAAAAAAAAAAAAA   "};


#define CommandShip "1111111"
#define BarGreen    "0011111"
#define BarYellow   "0010111"
#define BarOrange   "0011011"
#define Gun3xPower  "0000000"
#define Gun3xFast   "0001000"
#define BigBooster  "0100000"
#define Kilo6 "0010000"
#define Kilo5 "0010100"
#define Kilo4 "0010010"

case 'G': AddShipPart(BarGreen, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
case 'T': AddShipPart(BigBooster, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
case 'L': AddShipPart(Gun3xPower, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
case 'B': AddShipPart(CommandShip, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
               
case '6': AddShipPart(Kilo6, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
case '5': AddShipPart(Kilo5, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
case '4': AddShipPart(Kilo4, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;



XKCD battler cuuiser Mark 2 Lite: (less armour and there for faster)

http://www.captainforever.com/captainfo ... ogv3yaycvu


debug ship (for parts):
http://www.captainforever.com/captainfo ... 4nfbftw3lt
Last edited by ttnarg on Wed Feb 03, 2010 12:10 am UTC, edited 1 time in total.

User avatar
Josephine
Posts: 2142
Joined: Wed Apr 08, 2009 5:53 am UTC

Re: Captain Forever: URL decryption

Postby Josephine » Tue Feb 02, 2010 11:34 pm UTC

That's brilliant. I love killing 3 peacekeepers with one shot. When will they learn not to build long thin ships that one volley can destroy?
Belial wrote:Listen, what I'm saying is that he committed a felony with a zoo animal.

ttnarg
Posts: 39
Joined: Tue Jan 05, 2010 5:50 pm UTC

Re: Captain Forever: URL decryption

Postby ttnarg » Wed Feb 03, 2010 12:15 am UTC

JBJ I like you editor its a lot more user friendly then mine.
as you posted your code I guess I should be nice and post mine.

Its a little messy and was not ment for any one other then me.
Spoiler:

Code: Select all

#include "stdafx.h"


int nBufferSize = 0;
char acBuffer[1000];

int aanCheck[127][127];

char *aszLetterSearch[32] ={
   "0-00110","1-11010","2-01000","3-01100",
   "4-11001","5-01001","a-10000","b-00000",
   "c-00111","d-11011","e-01011","f-10011",
   "g-00011","h-11101","i-01101","j-01010",
   "k-10010","l-00010","m-11100","n-11111",
   "o-10100","p-00100","q-11000","r-10101",
   "s-00101","t-01111","u-10111","v-10001",
   "w-00001","x-11110","y-01110","z-10110"};


void Panic()
{
   printf("Panic Panic Panic\n");
   int *pnBaseMemory = 0;
   *pnBaseMemory = 0;
}


char FindLetter(char *szFind)
{
   for (int nLoop = 0; nLoop<32; nLoop++)
   {
      if ((szFind[0] == aszLetterSearch[nLoop][2+0]) &&
         (szFind[1] == aszLetterSearch[nLoop][2+1]) &&
         (szFind[2] == aszLetterSearch[nLoop][2+2]) &&
         (szFind[3] == aszLetterSearch[nLoop][2+3]) &&
         (szFind[4] == aszLetterSearch[nLoop][2+4]))
      {
         return aszLetterSearch[nLoop][0];
      }
   }
   return '?';
}


void DumpBuffer()
{
   int nBufferStartOffset = 0;
   int nNumOfLetters = nBufferSize/5;
   for (int nIndex=0; nIndex<nNumOfLetters; nIndex++)
   {
      char sz5bits[6];
      sz5bits[0] = acBuffer[nBufferStartOffset];
      sz5bits[1] = acBuffer[nBufferStartOffset+1];
      sz5bits[2] = acBuffer[nBufferStartOffset+2];
      sz5bits[3] = acBuffer[nBufferStartOffset+3];
      sz5bits[4] = acBuffer[nBufferStartOffset+4];
      sz5bits[5] = 0;

      printf("%c", FindLetter(sz5bits));
      nBufferStartOffset += 5;
      nBufferSize -= 5;
   }

   if (nBufferStartOffset != 0)
   {
      for (int nIndex=0; nIndex<nBufferSize; nIndex++)
      {
         acBuffer[nIndex] = acBuffer[nIndex+nBufferStartOffset];
      }
   }
}


void AddBitToBuffer(char cBit)
{
   if ((cBit != '0') && (cBit != '1'))
      return;

   acBuffer[nBufferSize] = cBit;
   nBufferSize++;
}


void PadAndDumpBuffer()
{
   DumpBuffer();
   while (nBufferSize != 0)
   {
      AddBitToBuffer('1');
      DumpBuffer();
   }
   printf("\n");
}


void AddBitStringToBuffer(char *szBits)
{
   int nIndex = 0;
   while (szBits[nIndex] != 0)
   {
      AddBitToBuffer(szBits[nIndex]);
      nIndex++;
   }
}


void AddBitNumToBuffer(int nNum, int nNumOfBits)
{
   for (int nLoop=0; nLoop<nNumOfBits; nLoop++)
   {
      if (nNum%2 == 1)
         AddBitToBuffer('1');
      else
         AddBitToBuffer('0');
      nNum = nNum/2;
   }
}

void AddDirToBuffer(char cDir)
{
   switch (cDir)
   {
      case '^': AddBitStringToBuffer("00"); break;
      case 'v': AddBitStringToBuffer("10"); break;
      case '>': AddBitStringToBuffer("11"); break;
      case '<': AddBitStringToBuffer("01"); break;
   }
}

void AddShipPart(char *szType, int nXPos, int nYPos, char cDir)
{
//   printf("\nAdding part %s, %d, %d, %c\n", szType, nXPos, nYPos, cDir);

   if (aanCheck[nXPos][nYPos] != 0)
      Panic();

   aanCheck[nXPos][nYPos]++;

   AddBitStringToBuffer(szType);
   AddBitNumToBuffer(nXPos,7);
   AddBitNumToBuffer(nYPos,7);
   AddDirToBuffer(cDir);
   DumpBuffer();
}


#define CommandShip "1111111"
#define BarGreen    "0011111"
#define BarYellow   "0010111"
#define BarOrange   "0011011"

#define Gun3xPower  "0000000"
#define Gun3xFast   "0001000"
#define BigBooster  "0100000"

#define Kilo6      "0010000"
#define Kilo5      "0010100"
#define Kilo4      "0010010"


#define size 27
#define hsize 13 //(int)(size/2)

char *aszDir[size] ={
   "                           ",
   "                           ",
   "                           ",
   "                           ",
   "     vvvvvvvvvvvvvvvvv     ",
   "    >]]]>]]]>u<[[[<[[[<    ",
   "    >u^^^^^^^u^^^^^^^u<    ",
   "    >u< vvvvvuvvvvv >u<    ",
   "    >u<>u]]]>v<[[[u<>u<    ",
   "    >u<>uu^ ^u^ ^uu<>u<    ",
   "    >u<>uu<<>u<< uu<>u<    ",
   "    >vvvvu ^ u<< uvvvv<    ",
   "    >]]]>vv vvv vv<[[[<    ",
   "    >]]]>]]]>v<[[[<[[[<    ",
   "    >]]]>^ ^^^^^ ^<[[[<    ",
   "    >^^^^n<  n< >n^^^^<    ",
   "    >n<>nn<  n< >nn<>n<    ",
   "    >n<>nn vvnvv nn<>n<    ",
   "    >n<>n]]]>^<[[[n<>n<    ",
   "    >n< ^^^^^n^^^^^ >n<    ",
   "    >nvvvvvvvnvvvvvvvn<    ",
   "    >]]]>]]]>n<[[[<[[[<    ",
   "     ^^^^^^^^^^^^^^^^^     ",
   "                           ",
   "                           ",
   "                           ",
   "                           "};

char *aszType[size] ={
   "                           ",
   "                           ",
   "                           ",
   "                           ",
   "     LLLLLLLLLLLLLLLLL     ",
   "    L]]]4]]]4u4[[[4[[[L    ",
   "    LuTTTTTTTuTTTTTTTuL    ",
   "    LuT TTTTTuTTTTT TuL    ",
   "    LuTTu]]]444[[[uTTuL    ",
   "    LuTTuuG GuG GuuTTuL    ",
   "    LuTTuuGGGuGG uuTTuL    ",
   "    L6TT4u G uGG u4TT6L    ",
   "    L]]]44G G4G G44[[[L    ",
   "    L]]]4]]]4B4[[[4[[[L    ",
   "    L]]]44 GG4GG 44[[[L    ",
   "    L6TT4nG  nG Gn4TT6L    ",
   "    LnTTnnG  nG GnnTTnL    ",
   "    LnTTnn GGnGG nnTTnL    ",
   "    LnTTn]]]444[[[nTTnL    ",
   "    LnT TTTTTnTTTTT TnL    ",
   "    LnTTTTTTTnTTTTTTTnL    ",
   "    L]]]4]]]4n4[[[4[[[L    ",
   "     LLLLLLLLLLLLLLLLL     ",
   "                           ",
   "                           ",
   "                           ",
   "                           "};

char *aszBuildOrder[size] ={
   "                           ",
   "                           ",
   "                           ",
   "                           ",
   "     AAAAAAAAAAAAAAAAA     ",
   "    A]]]4]]]3u3[[[4[[[A    ",
   "    Au9999999u9999999uA    ",
   "    Au9 99999u99999 9uA    ",
   "    Au99u]]]323[[[u99uA    ",
   "    Au99uu7 7u7 7uu99uA    ",
   "    Au99uu787u78 uu99uA    ",
   "    A4994u 8 u78 u4994A    ",
   "    A]]]327 717 723[[[A    ",
   "    A]]]2]]]101[[[2[[[A    ",
   "    A]]]32 77177 23[[[A    ",
   "    A4994n7  n7 7n4994A    ",
   "    An99nn7  n7 7nn99nA    ",
   "    An99nn 77n77 nn99nA    ",
   "    An99n]]]323[[[n99nA    ",
   "    An9 99999n99999 9nA    ",
   "    An9999999n9999999nA    ",
   "    A]]]4]]]3n3[[[4[[[A    ",
   "     AAAAAAAAAAAAAAAAA     ",
   "                           ",
   "                           ",
   "                           ",
   "                           "};




void Build(char cOrder)
{
   for (int x=0; x<size; x++)
      for (int y=0; y<size; y++)
      {
         if (aszBuildOrder[y][x] == cOrder)
         {
            switch (aszType[y][x])
            {
               case 'G': AddShipPart(BarGreen, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
               case 'T': AddShipPart(BigBooster, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
               case 'L': AddShipPart(Gun3xPower, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
               case 'B': AddShipPart(CommandShip, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
               
               case '6': AddShipPart(Kilo6, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
               case '5': AddShipPart(Kilo5, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;
               case '4': AddShipPart(Kilo4, 64-hsize+x, 64-hsize+y, aszDir[y][x]); break;

            }
         }
      }
}


#define debugShip false


int _tmain(int argc, _TCHAR* argv[])
{

   for (int x=0; x<128; x++)
      for (int y=0; y<128; y++)
      {
         aanCheck[x][y] = 0;
      }

   if (!debugShip)
   {
      Build('0');
      Build('1');
      Build('2');
      Build('3');
      Build('4');
      Build('5');
      Build('6');
      Build('7');
      Build('8');
      Build('9');
      Build('A');
   }
   else
   {
   /*
      000-gun x3
      100-Shields
      010-bosster
      110-Guns
      001-bars
      101-Info
      011-gunless CS - strong to week
      111-CS
   */
      AddShipPart(CommandShip, 64, 64, 'v');

      for (int lp=0; lp<16; lp++)
      {
         AddShipPart(BarOrange, 64+lp+1, 64, '<');
         AddShipPart(BarOrange, 64-lp-1, 64, '>');
      }

      for (int lp=0; lp<16; lp++)
      {
         AddBitStringToBuffer("001");
         AddBitNumToBuffer(lp,4);
         AddBitNumToBuffer(64+lp+1,7);
         AddBitNumToBuffer(63,7);
         AddDirToBuffer('v');
         DumpBuffer();
      }

      for (int lp=0; lp<16; lp++)
      {
         AddBitStringToBuffer("000");
         AddBitNumToBuffer(lp,4);
         AddBitNumToBuffer(64-lp-1,7);
         AddBitNumToBuffer(65,7);
         AddDirToBuffer('^');
         DumpBuffer();
      }

      for (int lp=0; lp<16; lp++)
      {
         AddBitStringToBuffer("010");
         AddBitNumToBuffer(lp,4);
         AddBitNumToBuffer(64-lp-1,7);
         AddBitNumToBuffer(63,7);
         AddDirToBuffer('v');
         DumpBuffer();
      }

      for (int lp=0; lp<16; lp++)
      {
         AddBitStringToBuffer("110");
         AddBitNumToBuffer(lp,4);
         AddBitNumToBuffer(64+lp+1,7);
         AddBitNumToBuffer(65,7);
         AddDirToBuffer('^');
         DumpBuffer();
      }
   }
   
   PadAndDumpBuffer();

   while (true);
   return 0;
}


If I had an array of part lenghts I could remove the need for a build order table but it was easyer to fill out a table then right an automatic system.
Last edited by ttnarg on Wed Feb 03, 2010 12:50 am UTC, edited 1 time in total.

User avatar
Levi
Posts: 1294
Joined: Tue Oct 14, 2008 1:12 am UTC

Re: Captain Forever: URL decryption

Postby Levi » Wed Feb 03, 2010 12:21 am UTC

Are the Kilo guns and thrusters from the for-pay version? The highest I saw were white, but I did see Kilo Girders on the peacekeepers.

ttnarg
Posts: 39
Joined: Tue Jan 05, 2010 5:50 pm UTC

Re: Captain Forever: URL decryption

Postby ttnarg » Wed Feb 03, 2010 12:41 am UTC

Levi wrote:Are the Kilo guns and thrusters from the for-pay version? The highest I saw were white, but I did see Kilo Girders on the peacekeepers.


Dont know the part Type is a 7 bit number both me (and I guess JbJ) just went throw all of them. I posted my debug ship that lists 1/2 the parts, the 1/2 that I use the other 1/2 is a bit odd and I dont think they are ment to be used. On the captain forever web page there are pictures of parts I have not seen so I guess they are from the paid for vertion. It must use a diffent coding system as there is no room for new part in this one unless it swaps out some of the stange parts.

User avatar
hintss
Posts: 1294
Joined: Wed Nov 25, 2009 7:19 am UTC
Contact:

Re: Captain Forever: URL decryption

Postby hintss » Thu Feb 04, 2010 6:45 am UTC

thanks for letting me know about captain forever :D

User avatar
hintss
Posts: 1294
Joined: Wed Nov 25, 2009 7:19 am UTC
Contact:

Re: Captain Forever: URL decryption

Postby hintss » Sat Feb 06, 2010 12:59 am UTC

can't fight addiction to game...

gabi83tm
Posts: 1
Joined: Tue Mar 30, 2010 4:21 pm UTC

Re: Captain Forever: URL decryption

Postby gabi83tm » Tue Mar 30, 2010 4:27 pm UTC

JBJ wrote:ttnarg, you rock!

As promised, here's the utility.


I made an account here just to thank you and ttnarg. So... Thanks!!!

P.S. Also, I can't remember the last time that I used multiple exclamation marks :)

LoveBirdBrown
Posts: 1
Joined: Thu Jan 06, 2011 10:26 pm UTC

Re: Captain Forever: URL decryption

Postby LoveBirdBrown » Thu Jan 06, 2011 10:29 pm UTC

I must fail at something... But how does one actually use the ship building utility? All I see is a bunch of code in the spoiler section. Javascript is enabled, and I tried in both browsers, but I have zero idea how to use or even run it.

User avatar
snowyowl
Posts: 464
Joined: Tue Jun 23, 2009 7:36 pm UTC

Re: Captain Forever: URL decryption

Postby snowyowl » Fri Jan 21, 2011 10:24 pm UTC

JBJ's utility is HTML code. Copy it to a text file, rename the text file to "captainforeverutility.htm" (or something like that, as long as it ends in htm). Then open it in your web browser.

ttnarg's is C++ code. If you have a C++ compiler, copy and paste the code into it. If you don't... well, you could get a free one, but it'll be much faster to just use JBJ's code.

Kilo-class parts are available in the normal game. Kiling a Peacekeeper ship drops them - assuming you don't shoot them with a solid wall of annihilation that destroys the drops as well as the enemies.
The preceding comment is an automated response.

User avatar
liberonscien
-ce
Posts: 121
Joined: Thu Jan 21, 2016 7:04 pm UTC
Contact:

Re: Captain Forever: URL decryption

Postby liberonscien » Fri Apr 01, 2016 5:46 am UTC

This game is pretty fun.

Has anyone made any machines?
Warning: This user is currently questioning its beliefs. This user offers its sincerest apologies if it accidentally offends another user. This user never offends others on purpose and may accidentally offend other users because it lacks knowledge regarding how to be a normal human.


Return to “Logic Puzzles”

Who is online

Users browsing this forum: No registered users and 6 guests