## My projects and demos

Show off your games, demos and other (playable) creations.
Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

### Re: My projects and demos

Thanks very much for the links and examples from your work Zorg. That helps a whole bunch.

Update:

One important part of the program, that aids in immersion is having a rich list of names for NPCs. It can also be used to give the player a name if the player can't decide for himself. My method was to search google for a name list. Luckily there are many. Unfortunately the data is not often in the best format for using in a table.

Assuming someone else might want to do this, I will explain the method that I used to extract and prepare the list for use in the program. Because nobody wants to manually edit 7000 lines of information.. Sed is the answer.

First I copy and paste the name list into a file. This unfortunately contained information I didn't need at the moment, like ranking and frequency.
The first thing to do is remove all non alphabet characters from the file.

Code: Select all

sed 's/[^a-zA-Z]//g' girlnames.txt > girlnames2.txt

Now I have a file (girlnames2.txt), that contains a big list of names. Only problem is putting them into a table now I still need to add quote marks. That could get old after 4k of names... But luckly Sed again will save me much work.

Code: Select all

sed 's/.*/\"&\",/g' girlnames2.txt > girlnames3.txt

Your notice also that I wanted to make sure that the comma was added to the end of the line. Now I have the data in a form I can use in lua. (with a little work on the last line) Your remove the last comma and add a curly brace at the start and the end. There you now have your table.

finally I remove the intermediate files that I have used. and I do the same thing with the boys names. I also did this with the surname list.

I now have a list of names in a series of tables that I can randomly assign in the game. Thousands upon thousands of names and when coupled with Surnames you have to play a lot of games to get a repeat name.

Female first names
fname.txt
Male first names
mnames.txt
White surnames
white_surnames.txt
Last edited by Pangit on Thu Jul 21, 2016 12:00 pm, edited 4 times in total.

Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

### Re: My projects and demos

Today's update:

Code: Select all

math.randomseed( os.time() )

function newPerson(p,q)
local object = {}

object.name = p
object.age = q
object.bama = math.random(1000000,200000000)

function object:sayName()
print(object.name)
end
function object:sayBama()
print(object.bama)
end
return object
end

local bill = newPerson("Bill", 18)
local ted = newPerson("Ted", 18)

print(bill.age)
ted.sayName()
print("Teds Bama ID = ")
ted.sayBama()
print("Bills Bama ID = ")
bill.sayBama()

It is not to much, but spent the night messing with writing MOD files lol. So today wanted to get back to doing some of the game code - just for a break. You can see that the stats from the character generation would just get plugged in here eventually. (instead of just bama, name, age - your have all of the characteristics plugged in also.)

Got the NPC and player ID working. One of the ways the game logic works is assigning a ID to each character in the game. This is how you can send and receive email, use bank accounts, access personal vaults, get paid ect.. Kind of like a social security number.

Next thing is to get a table generated of all the NPCs IDs for easy lookup afterwards. This would be used in saving the state of the game.

Will get the bank account code finished and then plug in the character generation code and things will start to be a bit more interesting.

When the game starts it generates an ID for each character in the game (this avoids people cheating by collecting the IDs from previous play through. As now each time you start a new game the IDs are generated fresh. I was kinda on the fence about doing it this way. Because it prevents people doing cool things like Wiki pages on the game if everything is generated on the fly. But it does make it somewhat more realistic and you can't cheat as bad doing it this way.

The ID is then linked to bank accounts you can open with the various game banks. Just like in real life there are multiple banks that a player or NPC can open an account with. The ID is used to key an account to a player. It also enables transmission of funds from things like the PAX terminals or atms in game.

I wanted to create a real functioning economy, I always disliked games where money that was spent in game just seemed to go into a bottomless pit. Therefore when you buy and sell goods - you pay a tax to the play you are in. That is then used to pay for items that the location purchases. It should create a more realistic game economy.

One nice way to prompt the players to go to a new area is to drop hints of a tax haven ect, better paying jobs. Stuff like that. Trying now to figure out how to implement a economy that wont break but makes sense and fuels the quest/job market. That was something that frustrated me about RPGs was how the shops in game just seemed to get tons of stuff without paying for it, there appeared to be no logistics taking place. I wanted it to be possible that NPCs could trade with the stores and affect the inventory.

The main thing with the quest/job economy in game is if the NPCs can also take part that creates an interesting situation where they can develop/acquire wealth and affect the game world. Make it seem more of a living space and bring rational outcomes to what vendors are selling in a region.

The main thing is making the game world responsive to how a player wants to play. It always seemed unreasonable to me why as a player you couldn't just grind or operate a store if you wanted to.. I think it would be possible to implement this in the game. Especially if I can get the NPCs working properly.

When you think about the typical quests/jobs you get in RPGs most of them are not to demanding. Like take for example a fetch quest. The NPC would just need to go to a location, pick up an item and come back. You could generate hundreds of these and have the NPCs go and acquire the resources needed by the vendors this way. Giving the NPCs something to do and also creating realistic inventory allocations.

In neuromancer this was how it was used..

Your see that next to each character in the game you have there ID number. This is used by the security forces to issue warrants of arrest, its how they know if a person has been put on a watch list or needs to be arrested/liquidated. Who can access what areas ect. It was quite a clever way to implement this as there would be a list of IDs and if your ID was on the list then you were able to enter that area/obtain a widget ect..

One of the best things in Neuromancer was you were able to hack the security forces system and add a persons name to a arrest list. Then the security forces would arrest them if they were encountered in the game.

Tonight's update:

Here are some more of the surnames lists..

Mixed race surnames:
mixedrace_surnames.txt
Black surnames:
black_surnames.txt
Latino surnames:
latino_surnames.txt
by my back of the napkin calculations with 5200 first names, and 24,000 surnames that gives enough variation to make any game pretty realistic and distinct.

Assuming repeats first names are possible according to one on-line calculator.

1,254,460,238,282,924,094,746,061,852,057,131,823,119,397,222,380,275,620,532,983 permutations...

one novemdecillion, two hundred fifty-four octodecillion, four hundred sixty septendecillion, two hundred thirty-eight sexdecillion, two hundred eighty-two quindecillion, nine hundred twenty-four quattuordecillion, ninety-four tredecillion, seven hundred forty-six duodecillion, sixty-one undecillion, eight hundred fifty-two decillion, fifty-seven nonillion, one hundred thirty-one octillion, eight hundred twenty-three septillion, one hundred nineteen sextillion, three hundred ninety-seven quintillion, two hundred twenty-two quadrillion, three hundred eighty trillion, two hundred seventy-five billion, six hundred twenty million, five hundred thirty-two thousand, nine hundred eighty-three

whitebear
Citizen
Posts: 86
Joined: Sun Mar 15, 2009 1:50 am

### Re: My projects and demos

A note about using math.random(). When you set the seed, the algorithm starts from beginning and often the first few iterations are close to being the same. I suggest poping few random numbers before using it for randomization.

zorg
Party member
Posts: 3004
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: My projects and demos

Better yet, just use love.math.random instead, that's not OS dependent.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

### Re: My projects and demos

whitebear wrote:A note about using math.random(). When you set the seed, the algorithm starts from beginning and often the first few iterations are close to being the same. I suggest poping few random numbers before using it for randomization.
zorg wrote:Better yet, just use love.math.random instead, that's not OS dependent.
Thanks for the advice guys, I will amend the code to use love.maths.random. whitebear, cheers for the info on maths.random I will bear that in mind for when I am using lua.

Code: Select all

love.math.setRandomSeed( os.time() )

function newPerson(p,q)
local object = {}

object.name = p
object.age = q
object.bama = love.math.random(1000000,200000000)

function object:sayName()
print(object.name)
end
function object:sayBama()
print(object.bama)
end
return object
end

local bill = newPerson("Bill", 18)
local ted = newPerson("Ted", 18)

print(bill.age)
ted.sayName()
print("Teds Bama ID = ")
ted.sayBama()
print("Bills Bama ID = ")
bill.sayBama()

I did a test run with just the female first name list + white surname list and generated 100,000 names. Just as a sanity check to confirm randomness.
test.txt
Seems to work just fine.

Will work on this today to implement the rest of the tables.

Next thing is to pair it with the bama ID, then build a npc table for use in the game. This will hold the bama ID, the first name, second name, a table of characteristics, and location info, inventory] then pretty much that's a big part of the program done.

So I thought - mmm that 100,000 is nice but that's not modelling Metro Manila. You got to think there are just over 30 million. If you were to implement a realistic banking/communication grid.. well. lets just say that idea occurred to me and I tried as a test 22 million names. It is still running. has managed to get to 122mb, so back of the napkin calculations I am looking at 308mb of data.

This takes forever to calculate. I was thinking of trying it in C to see if I can improve the speed...

Anyway - interesting test. Sadly it looks like I'll never have 22 million npcs in game lol... but 100,000 I think will be enough to give realism and create an economy in game without it making the machine so slow its unplayable.

#WhereIsMyQuantumComputerDude

Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

### Re: My projects and demos

Today's update:

Time to make the name function into its own library. While its easier to test when its all in one file its no fun going through tens of thousands of lines just to generate a name. So the task today is breaking the name function out of the main.lua file into its own file and checking the program works.

Probably will finalize how the function parameters work also so your have more fine grain control over what names you get back.

Baby steps but slowly things are getting done.

Here is the main.lua
Still got a bunch of junk from previous playing. But you can see the new module.. (name)

Code: Select all

name = require('name')
love.math.setRandomSeed( os.time() )

for i=1,1000 do
local testbama = love.math.random(1000000,200000000)
local test = name.newName()
print("["..i.."] "..test.second..","..test.first.."\t\t"..testbama)

end


here is the name library module...

name.lua

Code: Select all

module(..., package.seeall)

function newName()

local name = {}
--local namelist = {"Anna", "Gemma", "Heidi", "Thess", "Patricia", "Zoe"}

local namelist = {
"AARON",
"ABBEY",
"ABBIE",
"ABBY",
"ABIGAIL",
-- snip snip.. obviously this is not the whole file..
"ZENAIDA",
"ZENIA",
"ZENOBIA",
"ZETTA",
"ZINA",
"ZITA",
"ZOE",
"ZOFIA",
"ZOILA",
"ZOLA",
"ZONA",
"ZONIA",
"ZORA",
"ZORAIDA",
"ZULA",
"ZULEMA",
"ZULMA"
}

local namelist_Surname_White = {
"SMITH",
"JOHNSON",
"MILLER",
"BROWN",
"JONES",
"WILLIAMS",
"DAVIS",
-- snip snip, you get the idea. I can't include the whole file because of post restrictions. But check out the attached file later.
}
name.newInd =love.math.random(1,4275)
name.newInd_Sur = love.math.random(1,3999)
name.first = namelist[name.newInd]
name.second = namelist_Surname_White[name.newInd_Sur]
--print(name.first)
return name

end

Nasty but still its the first attempt and it works. Will add in the other ethnic lists and male names later. Like I said will get the parameters a bit more fine grained so the program can request exactly what it needs.

At the moment its just generating random numbers for the bama-id that is not correct as its technically possible to get duplicates that way. better that it takes from a table of possible ids selected at random. That each time a id is taken by the system it is removed from the available pool and assigned to the NPC or player.

The next step will be building the NPC table.
name_bama.png (19.11 KiB) Viewed 1693 times
Here is a weird thing - in the game the largest bama-id was only a few tens of millions. Given what the population would have been at that time. I assume that they recycled the numbers after death.

Tonight's update:

Well it was one of those days where time just seemed to escape me. Still while not a great deal got done today. I did added x/y starting position for the NPC generation. Later on tonight - will get the table insert function working then the NPC table is done. (at the moment its just generating random x,y positions and spewing them out to the console. But hey its a test.

Next thing will be to add a bank account balance and number to each npc. Each person has at least one bank account so they can pay taxes, collect wages, transact in game. Will be interesting at that point to set up the monitor functions to be a big old snoop at the NPCs account details.

Still enough of my jibber jabber.
name_bama_x_y.png (25.62 KiB) Viewed 1678 times
Now I hear what your saying - Why didn't I assign a zone location also. Well as it was a test I didn't implement that yet. But sure eventually it will have each npc being divided into zones then having an x,y on the tilemap. and of-course depending on what tilemap they find themselves placed there will be certain parts that are not possible to travel on.

What is starting to bug me now is weeks ago I had the code for character stat generation done and I have been so idle I have yet to put this into the program. Each npc will have its table of stats/characteristics that can be used by the engine to calculate outcomes. still its pretty easy to do. I guess I have just been putting it off.

Nit-picky I know but I wish i could get the data columns to line up on the console printout.

Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

### Re: My projects and demos

Today's Update:

Another baby step, you can see now I add the characteristics for each NPC. each time the game starts you have new statistics that influence how the NPC acts and interacts with others in the game. As you can see by the number of junk character stats I might need to tweak the rolls to make them able to function within the game world (way to many characters seem to have <4 for stats that can cripple there ability to function.

Anyway for now. Have the name, ID, location and stats for NPCs being generated.

Like I said last night, this day will be focused on getting the table insert working as at the moment the code just spits these random rolls into space each time it cycles through the for loop.
name_bama_x_y_stats.png (22.46 KiB) Viewed 1655 times
Still on the plus side just have 1000 npcs in a zone, with there character rolls, (have yet to assign skills but thats not a big deal..) I think you can have a very rich interaction with this kind of crowd. And what's more its going to be different every time you start the game.

table.insert works just as you would expect it too. Not sure how this would scale to working with larger groups of npcs but it seems to be functioning just fine with 1000 npcs at the moment.

This was the next stage getting a table that can be accessed in game that holds the information on all of the NPCs, the stats, where they are, and ID.

Next will add the banking information and message ID then with the exception on inventory for NPCs (just another table.) that's pretty much it for the NPCs except for things like movement scripts ect..
npcTable_v_0.1.png (15.12 KiB) Viewed 1640 times

Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

### Re: My projects and demos

map.png (7.11 KiB) Viewed 1632 times
Got a tilemap done in tiled for testing. Unfortunately isometric tile building is a little beyond me at the moment so its going to have to be top down view. But its just for testing anyhow. Plenty of time to learn.
map2.png (6.18 KiB) Viewed 1632 times
Here is my rather poor attempt at a metro train lol.

Anyway for working out the timings for the stations, making sure that npcs and players can travel between zones it will be fine. I can always work on assets at a later date. Important thing is getting the game actually running, then work on the beauty side of things. Although it is a bit sad it looks like a early 80s spectrum game sob...

So getting back to the screen - this is the station platform. Where players and NPCs can travel between zones. The zone blocks travel until a train is in the station. then characters can transfer to the carriage zone.

They can only get to the platform having bought a ticket before at another screen, gone through a gate. This area is only operational during certain times of the day (its not a 24 hour service.) so sometimes players and NPCs would have to find other ways to transfer zones out of hours.

There are two basic types of areas in the station - secure and non-secure. The secure areas are areas of the station you can only reach after using a ticket and passing the gate. No vendors operate in this area. And only passengers and staff are allowed.

The non-secure areas are commercial, and open to the public. This is where players could trade, talk to vendors and if they wanted to travel buy a ticket to ride. There would be certain times when the vendors were closed (early morning.)

So even this little area needs a fair amount of coding to make it work. But the nice thing is once one station is done it can become the base class for all the stations in the game. So its worth getting it right.
map4.png (45.07 KiB) Viewed 1628 times
Your see here each station has a north and south bound track. Unfortunately I haven't made enough tiles to make the station platform intresting, but that will come later.

pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

### Re: My projects and demos

Looking good so far man, I'd personally try and keep the spectrum feel to it but that's what cyberpunk makes me think of. Its a bit like minidisk for me, yesterdays future today!

Code: Select all

if not wearTheseGlasses() then
chewing_on_trashcan = true
end

Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

### Re: My projects and demos

pedrosgali wrote:Looking good so far man, I'd personally try and keep the spectrum feel to it but that's what cyberpunk makes me think of. Its a bit like minidisk for me, yesterdays future today!
Cheers fella, I see what your saying about the art style. As I am just testing the game at this point I'll leave it simple and see if it grows on me.
station2.png (36.6 KiB) Viewed 1595 times
got to get the station floor tiles seamlessly matching and a few more assets but its starting to come together.

Having slept on this, Will have another crack at the floor tiles to make them more realistic. (and a lot lighter).

Today's update:

Well spent more time than I should messing around pixel editing. Ah well it is Sunday. Will have a break then finish off the name module. perhaps will get a tile set from open game art or some similar place to test STI and check everything is working. While playing with assets is fun I feel I could be getting more work done on the actual game. Well spent the rest of the day checking out gameboy sprite sheets trying to figure out how they expressed so much with so little.

That however didn't finish the name module. So will crack on with that tonight. Multi-ethnic names are coming. And coincidently will be my first love library.

### Who is online

Users browsing this forum: No registered users and 28 guests