It's free to join Gamasutra!|Have a question? Want to know who runs this site? Here you go.|Targeting the game development market with your product or service? Get info on advertising here.||For altering your contact information or changing email subscription preferences.
Registered members can log in here.Back to the home page.

Search articles, jobs, buyers guide, and more.

By Guy W. Lecky-Thompson
Gamasutra
September 17, 1999

Letters to the Editor:
Write a letter
View all letters


Features

 

Contents

Introduction

Predictably Random Numbers

Name Generation Techniques

Generating Random Terrain

Plot Sequencing

Code Listings

Listing 1

Listing 2

Listing 3

Listing 4

Listing 5

Listing 4:
Tablegen.cpp

// Building a letter frequency table

// (c) 1999 Guy W. Lecky-Thompson

// All Rights Reserved

#include <stdlib.h>

#include <string.h>

void AddLetters(char * szWord, unsigned long ulTable[28][28])

{

int nWordLength, nFirstLetter, nLastLetter, nLetter;

// Decapitalise the word

for (nLetter = 0; nLetter < (int)strlen(szWord)-1;nLetter++)

tolower(szWord[nLetter]);

// Add the first, and last to the table

nWordLength = (int)strlen(szWord);

nFirstLetter = (szWord[0] - 'a') + 1;

nLastLetter = (szWord[nWordLength-1] - 'a') + 1;

ulTable[0][nFirstLetter]++; // Space followed by letter

ulTable[nLastLetter][27]++; // Letter followed by space

for (nLetter = 0; nLetter < nWordLength-2; nLetter++)

{

nFirstLetter = (szWord[nLetter] - 'a') + 1;

nLastLetter = (szWord[nLetter+1] - 'a') + 1;

ulTable[nFirstLetter][nLastLetter]++;

}

}


 

Listing 5


join | contact us | advertise | write | my profile
news | features | companies | jobs | resumes | education | product guide | projects | store



Copyright © 2003 CMP Media LLC

privacy policy
| terms of service