I need help with a game decode program. 
Author Message
 I need help with a game decode program.

 I'm new (very new) to programing cobol. I am trying to write this
program (for a game) that would decode grid numbers to alphabetical
numbers. Here is the link to the post.

This is how it works.

  1 2 3 4 5 6
1 A F K P U Z
2 B G L Q V
3 C H M R W
4 D I N S X
5 E J O T Y

Fragment 6873

452315452324431413114515223543
553521243341322413114515354314
154353355132144315425124431544
353315513414154332552434221335
443324132434451532322422153413
153534154523114544514141322415
442434213543331145243534113414
243414352434224435331131154445
231541433513154444141544134324
121514231543151144354345352113
323544151444554445153353232413
233335521544214335331143151134
144523153412111331453524454443
151132244555

"The third category of implicate order would require some underlying
cosmic intelligence one that supplies information and in doing so
makes the process described here a sort of closed system which moves
from are and then back to its reality."

If you look at the fragemnts break em up in pairs of DIGITS, for each
pair digit 1 designates the row coordinate and 2 the column....
TADA....

Note: I do not want to get in to a discussion about how I can or can
not do this. If you can help me fine if you can not please keep it to
yourself.



Sat, 06 Aug 2005 04:32:35 GMT  
 I need help with a game decode program.


Quote:
> Note: I do not want to get in to a discussion about how I can or can
> not do this. If you can help me fine if you can not please keep it to
> yourself.

If you are doing in COBOL because you want practice with COBOL, then you should
welcome such a discussion.  Otherwise, my question is "Why COBOL?   I tend not
to associate COBOL with game programming.


Sat, 06 Aug 2005 04:58:25 GMT  
 I need help with a game decode program.

Quote:

> I'm new (very new) to programing cobol. I am trying to write this
>program (for a game) that would decode grid numbers to alphabetical
>numbers. Here is the link to the post.

>This is how it works.

>  1 2 3 4 5 6
>1 A F K P U Z
>2 B G L Q V
>3 C H M R W
>4 D I N S X
>5 E J O T Y

>[encoded] 452315452324431413114515223543 ...
>[decoded] "The third category of ...

>If you look at the fragemnts break em up in pairs of DIGITS, for each
>pair digit 1 designates the row coordinate and 2 the column....

Decoding the letters is easy. Set up a two-dimensional array and use the two
digits to subscript into it.

The hard part is figuring out where to insert spaces between words. You didn't
ask how, so I won't answer that part.

FYI, this type of cipher, called 'monoalphabetic substitution', is the easiest
cipher in the world to break. It is broken by analyzing how frequently each
letter is used. In English, the most frequently used letters are E, T, O, A, N,
I, R, and S. That knowledge plus a dictionary file for checking assumptions plus
some reiterative programming can break a cipher like this in milliseconds. If
you want to get serious about encryption, think LONG KEYS where each key byte is
xor'd with an input byte before advancing to the next input byte AND key byte.
Rotating the key is an important concept here.  If the key is longer than the
input, called a 'one-time pad', it's absolutely unbreakable. If the key is
longer than 100 bits, it would take hundreds of years to break because the only
way is brute-force i.e. trying every possible key. The number of possible keys
doubles for each bit in the key.

Here is the COBOL you requested:

01  key-values.
     05  filler value 'AFKPUZ'     pic  x(06).
     ...
01  key-table redefines key-values.
     05  filler occurs 5.
          10  decode occurs  6    pic  x(01).

move 1 to n-out
perform varying n from 1 by 2 until n > message-length
     move input-digit (n) to first-digit
     move input-digit (n + 1) to second-digit
     move decode (second-digit, first-digit) to cleartext (n-out)
     add 1 to n-out
end-perform

Robert



Sat, 06 Aug 2005 07:50:43 GMT  
 I need help with a game decode program.

Quote:
> Note: I do not want to get in to a discussion about how I can or can
> not do this.

Then why did you ask for help if you do not want people to tell you
how you can do it (or not).

Quote:
> If you can help me fine if you can not please keep it to yourself.

Please don't try to tell others whether they may or may not post here.


Sat, 06 Aug 2005 11:37:26 GMT  
 I need help with a game decode program.


Quote:

>> Note: I do not want to get in to a discussion about how I can or can
>> not do this.

>Then why did you ask for help if you do not want people to tell you
>how you can do it (or not).

Someone told me in a previous post that it was not practical to do
this in cobol. " Intriguing. But I wouldn't use Cobol for such a
problem. String manipulation is the first requirement, and C would
even be better than Cobol for that. Cobol is definitely oriented
towards business data processing, not text, and the reason's not easy
to explain - until you hit a problem like this."
Quote:

>> If you can help me fine if you can not please keep it to yourself.

>Please don't try to tell others whether they may or may not post here.

You are absolutely right about that I would be annoyed too. Lately it
seems whenever I post something it turns in to a flame war. I just
want it to be about learning Cobol and not about moods or attitudes,
it makes us weaker as a community and takes away from the experience.


Sat, 06 Aug 2005 16:16:12 GMT  
 I need help with a game decode program.
On Mon, 17 Feb 2003 20:58:25 GMT, "Howard Brazee"

Quote:


>> Note: I do not want to get in to a discussion about how I can or can
>> not do this. If you can help me fine if you can not please keep it to
>> yourself.

>If you are doing in COBOL because you want practice with COBOL, then you should
>welcome such a discussion.  Otherwise, my question is "Why COBOL?   I tend not
>to associate COBOL with game programming.

In my mind COBOL just makes sense I can grasp the concepts better and
it is perfect for data manipulation.


Sat, 06 Aug 2005 16:21:44 GMT  
 I need help with a game decode program.


Quote:

>> I'm new (very new) to programing cobol. I am trying to write this
>>program (for a game) that would decode grid numbers to alphabetical
>>numbers. Here is the link to the post.

>>This is how it works.

>>  1 2 3 4 5 6
>>1 A F K P U Z
>>2 B G L Q V
>>3 C H M R W
>>4 D I N S X
>>5 E J O T Y

>>[encoded] 452315452324431413114515223543 ...

>>[decoded] "The third category of ...

>>If you look at the fragemnts break em up in pairs of DIGITS, for each
>>pair digit 1 designates the row coordinate and 2 the column....

>Decoding the letters is easy. Set up a two-dimensional array and use the two
>digits to subscript into it.

>The hard part is figuring out where to insert spaces between words. You didn't
>ask how, so I won't answer that part.

>FYI, this type of cipher, called 'monoalphabetic substitution', is the easiest
>cipher in the world to break. It is broken by analyzing how frequently each
>letter is used. In English, the most frequently used letters are E, T, O, A, N,
>I, R, and S. That knowledge plus a dictionary file for checking assumptions plus
>some reiterative programming can break a cipher like this in milliseconds. If
>you want to get serious about encryption, think LONG KEYS where each key byte is
>xor'd with an input byte before advancing to the next input byte AND key byte.
>Rotating the key is an important concept here.  If the key is longer than the
>input, called a 'one-time pad', it's absolutely unbreakable. If the key is
>longer than 100 bits, it would take hundreds of years to break because the only
>way is brute-force i.e. trying every possible key. The number of possible keys
>doubles for each bit in the key.

>Here is the COBOL you requested:

>01  key-values.
>     05  filler value 'AFKPUZ'     pic  x(06).
>     ...
>01  key-table redefines key-values.
>     05  filler occurs 5.
>          10  decode occurs  6    pic  x(01).

>move 1 to n-out
>perform varying n from 1 by 2 until n > message-length
>     move input-digit (n) to first-digit
>     move input-digit (n + 1) to second-digit
>     move decode (second-digit, first-digit) to cleartext (n-out)
>     add 1 to n-out
>end-perform

>Robert

Thank you very much.


Sat, 06 Aug 2005 16:22:36 GMT  
 I need help with a game decode program.

Quote:

> I just want it to be about learning Cobol...

OK. Here's a short tale and a cute COBOL program prompted by your tale
of a monoalphabetic substitution cipher. A few years ago, a small
university in western Canada published a encrypted message in the form
of a newspaper style cryptogram which when decoded said roughly "To
win a scholarship to our university, add up all the decimal digits in
the numbers from one to one million and send the answer to the
following address:"

Here's the short program that does the trick. Note the creative use of
REDEFINES and the lack of any explicit output format conversion such
as FORMAT, string$ or sprintf() which would be found in other
programming languages.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. LETH.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. 8088.
       OBJECT-COMPUTER. 8088.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 T PIC 9(8) VALUE ZERO.
       01 I PIC 9(7).
       01 FILLER REDEFINES I.
         02 D PIC 9 OCCURS 7 TIMES.
       PROCEDURE DIVISION.
       MAIN.
           PERFORM SUB VARYING I FROM 1 BY 1
               UNTIL I IS GREATER THAN 1000000.
           DISPLAY T.
           STOP RUN.
       SUB.
           ADD D(1) D(2) D(3) D(4) D(5) D(6) D(7) TO T.



Sun, 07 Aug 2005 01:43:36 GMT  
 I need help with a game decode program.

Quote:
> Someone told me in a previous post that it was not practical to do
> this in cobol. " Intriguing. But I wouldn't use Cobol for such a
> problem. String manipulation is the first requirement, and C would
> even be better than Cobol for that.

Actually it is simple character manipulation and table lookups and
Cobol is quite good at that.

Quote:
> Cobol is definitely oriented
> towards business data processing, not text, and the reason's not easy
> to explain - until you hit a problem like this."

Consider this:  The input 'string' is a series of numbers: 23451621..

In Cobol you could define this as:

      01  Input-String.
          03  Input-Char            OCCURS 100.
           05 Input-number          PIC 99.

and use this directly as a table index in a perform loop:

      PERFORM
          VARYING i FROM 1 BY 1
            UNTIL i > somelength
               OR Input-Char(i) < "11"

          MOVE Input-Number(i)        TO Input-Index
          MOVE Lookup(Input-index)    TO Plain-Text(i)
      END-PERFORM    

The Lookup would occur 99 with most having space, the 26 letters being
placed as required.

There is no 'string manipulation', it isn't even 'text' manipulation.



Sun, 07 Aug 2005 03:13:24 GMT  
 I need help with a game decode program.

Quote:

> OK. Here's a short tale and a cute COBOL program prompted by your tale
> of a monoalphabetic substitution cipher. A few years ago, a small
> university in western Canada published a encrypted message in the form
> of a newspaper style cryptogram which when decoded said roughly "To
> win a scholarship to our university, add up all the decimal digits in
> the numbers from one to one million and send the answer to the
> following address:"

The numbers between 000,000 and 999,999 give you 6,000,000 digits
which are distributed evenly among 0's, 1's, etc., for 600,000 of
each.  Their total would be 600,000 times the sum of the numbers
from 0 to 9 (which is 9 * (9 + 1) / 2, or 45), or 27,000,000.

Add the 1 from 1,000,000, and you've got 27,000,001.

(I ran the COBOL program, and the numbers agree.)

Louis Krupp



Sun, 07 Aug 2005 03:24:05 GMT  
 I need help with a game decode program.


Quote:

>> OK. Here's a short tale and a cute COBOL program prompted by your tale
>> of a monoalphabetic substitution cipher. A few years ago, a small
>> university in western Canada published a encrypted message in the form
>> of a newspaper style cryptogram which when decoded said roughly "To
>> win a scholarship to our university, add up all the decimal digits in
>> the numbers from one to one million and send the answer to the
>> following address:"

>The numbers between 000,000 and 999,999 give you 6,000,000 digits
>which are distributed evenly among 0's, 1's, etc., for 600,000 of
>each.  Their total would be 600,000 times the sum of the numbers
>from 0 to 9 (which is 9 * (9 + 1) / 2, or 45), or 27,000,000.

Didn't Gauss do something like this when he was but a wee sprout?

DD



Sun, 07 Aug 2005 04:13:19 GMT  
 I need help with a game decode program.


Quote:

> Didn't Gauss do something like this when he was but a wee sprout?

Supposedly his teacher, to keep him quiet, told him to add the numbers from
1 to 100. Instantly he announced "5050."

(100+1 = 101, 99+2 = 101, etc. there are 50 such pairs. 50 x 101 = 5050).

Gauss was 27 at the time.

(Just kidding on the last)



Sun, 07 Aug 2005 04:40:51 GMT  
 I need help with a game decode program.

Quote:

> >The numbers between 000,000 and 999,999 give you 6,000,000 digits
> >which are distributed evenly among 0's, 1's, etc., for 600,000 of
> >each.  Their total would be 600,000 times the sum of the numbers
> >from 0 to 9 (which is 9 * (9 + 1) / 2, or 45), or 27,000,000.

> Didn't Gauss do something like this when he was but a wee sprout?

Similar.  It didn't have the complexity of digits (which likely wouldn't have
deterred Gauss).

I keep getting his story mixed up with Pascal's triangle.  Still most school
kids love the story of Karl Gauss and his "punishment".



Sun, 07 Aug 2005 04:47:05 GMT  
 I need help with a game decode program.

Quote:

> Didn't Gauss do something like this when he was but a wee sprout?

And he couldn't run a COBOL program to check his work.

I've always been told that "One may easily prove ..." translates to
"One did.  His name was Gauss."

Louis



Sun, 07 Aug 2005 05:14:08 GMT  
 I need help with a game decode program.


Quote:

>> Didn't Gauss do something like this when he was but a wee sprout?

>And he couldn't run a COBOL program to check his work.

Durned ASM bare-metal codin' snobs!

Quote:

>I've always been told that "One may easily prove ..." translates to
>"One did.  His name was Gauss."

Hmmmmm... with all due respect for The Greats... Euler?

DD



Sun, 07 Aug 2005 09:05:24 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. Need help with Chomp (a game for scheme)--Using Dr. Scheme to Program

2. TSR: Need help decoding keystrokes

3. Need help : G.711 a-law coding and decoding

4. Need help decoding IEEE format!!

5. NEEDED: Advice on tools for games programming

6. Battleship game program - HELP!

7. GAME PROGRAMMING HELP!

8. Making Game In VRML 2.0 - Need Help With AI

9. Posting again : help needed, ideas for 2 player network game + 3d graphics

10. HELP?: Game world needed for Light Princess

11. Life game in prolog - need urgent help!!!!

12. Need help completing a tcl net game!

 

 
Powered by phpBB® Forum Software