Trade Wars 2117

If you have a new game running on your server, you can announce it in here.

User avatar
TheMightyDude
Site Admin
Posts: 311
Joined: Thu Apr 17, 2014 09:15 UTC

Re: Trade Wars 2117

Post by TheMightyDude » Wed May 24, 2017 23:01 UTC

JokerAce wrote: Cool, thanks. No rush. Enjoy your program.
Ok, so 20 turns every hour, hmmm.

That might be an issue.
I would of set $sched_ticks to like 1 (every 60 seconds) which makes things easier.
I would then set $turns_per_tick to 20 (I.e. your 20 turns) still fine so far.
Now here is the gotcha, $sched_turns would need to be set to 60 (i.e. the 60th tick, so every hour), sadly $sched_turns also controls towing, xenobe.

So it would take an hour for a ship to be towed etc, there might also be other issues.

A way around that would be for you to do the above and also add another config setting called $sched_tow and set it to 2, you might be able to set it to 1 (every 60 seconds check and tow all required ships)

You will also have to update create_universe.php to use $sched_tow just for the towing side of the code.

That "should" work, but don't quote me on it.
TheMightyDude::Blacknova Development.
Development Blog YouTube Dev Channel Twitter Twitch

User avatar
TheMightyDude
Site Admin
Posts: 311
Joined: Thu Apr 17, 2014 09:15 UTC

Re: Trade Wars 2117

Post by TheMightyDude » Wed May 24, 2017 23:32 UTC

JokerAce wrote: :)

It does pose a challenge. I'm a glutton for punishment. I have a thing for solving problems.

I ran into the upper limits of BIGINT in the database so I've been going through trying to covert the references to decimal instead (no actual decimals though).
It was working really well but then I found a bug that makes it so when a port is fully stocked on Energy, it rolls the selling price to a negative integer so the port pays you to buy it.

I have yet to go digging for that issue.

Another one I noticed, before the BIGINT changes, is that after combat, when you salvage a ship, you get XXXXXXXXX.X credits.
Which means that somewhere in the code it's allowing decimals into the calculation of the credits and paying the player with that decimal.
I'm guessing that BIGINT or decimal(64, 0) {or whatever you use, the X,0 makes it drop the everything after the decimal} will round that figure off when paying into the players ship credits, but I haven't looked yet so that could be causing other issues too.

Writing the game was a huge accomplishment so needing to debug here and there isn't too bad but, as I'm sure you know, it's always a challenge to understand what was done and why before you break stuff trying to fix other stuff.

Did you manage to perfect that cron schedule verification code that you were working on this morning?
Yeah, I am not happy with the current code and haven't been for a while now.

I have also halted coding for now due to something that "might" be happening around this time next year if everything works out.
Cannot really say too much atm, but its not a bad thing.

When I look at the BNT code my OCD kicks in wanting me to fix it :P

As for the 64bit numbers (i.e. BIGINT) being maxed out, yep, we have had that issue for a while now, we did for a while move over to DOUBLES or DECIMAL (cannot remember) which can have larger numbers but at a cost to its accuracy, so we moved back to BIGINT's.

As far as I am aware we are using BIGINT(20), but yeah the 0 is the amount of decimal points.

There are a few files us devs refused to touch one of them is traderoute.php that's one huge file that does a lot.

As for the scheduler checker, well it works so far, but I want to add more stuff to it first.
TheMightyDude::Blacknova Development.
Development Blog YouTube Dev Channel Twitter Twitch

JokerAce
Posts: 17
Joined: Thu Apr 27, 2017 05:01 UTC

Re: Trade Wars 2117

Post by JokerAce » Wed May 24, 2017 23:36 UTC

TheMightyDude wrote:
JokerAce wrote: Cool, thanks. No rush. Enjoy your program.
Ok, so 20 turns every hour, hmmm.

That might be an issue.
I would of set $sched_ticks to like 1 (every 60 seconds) which makes things easier.
I would then set $turns_per_tick to 20 (I.e. your 20 turns) still fine so far.
Now here is the gotcha, $sched_turns would need to be set to 60 (i.e. the 60th tick, so every hour), sadly $sched_turns also controls towing, xenobe.

So it would take an hour for a ship to be towed etc, there might also be other issues.

A way around that would be for you to do the above and also add another config setting called $sched_tow and set it to 2, you might be able to set it to 1 (every 60 seconds check and tow all required ships)

You will also have to update create_universe.php to use $sched_tow just for the towing side of the code.

That "should" work, but don't quote me on it.
Wow... That was more complicated than I expected. ☺
It's still quite doable though and if it works, it might provide a pathway for many similar modifications. At the very least it separates the bundle which may come in handy in other scenarios.


Did you see the DB related post I made about 4 posts ago in response to your comment that you hated this code?

While I'm so fortunate as to be able to pick your brain a little, I wondered if you had any comment.


I think I'm going to put my modified version on Github, is it cool if I make it public?
The only catch is that many of the modifications I have made were directly to the Db so I'd have to go back and modify the php to generate the tables with those mods during install.... I think.

User avatar
TheMightyDude
Site Admin
Posts: 311
Joined: Thu Apr 17, 2014 09:15 UTC

Re: Trade Wars 2117

Post by TheMightyDude » Thu May 25, 2017 00:40 UTC

JokerAce wrote: Wow... That was more complicated than I expected. ☺
It's still quite doable though and if it works, it might provide a pathway for many similar modifications. At the very least it separates the bundle which may come in handy in other scenarios.


Did you see the DB related post I made about 4 posts ago in response to your comment that you hated this code?

While I'm so fortunate as to be able to pick your brain a little, I wondered if you had any comment.


I think I'm going to put my modified version on Github, is it cool if I make it public?
The only catch is that many of the modifications I have made were directly to the Db so I'd have to go back and modify the php to generate the tables with those mods during install.... I think.
Well when I said I hated the code, I was referring to how buggy it is and how much of a pain it is to add stuff to it.

I started to add plugin code where you could add in features that hooked into parts of the game, shown below:

Image

Parts of that plugin code is still there, but it wasn't complete, I did plan to re-code it once the main game was cleaned up and recoded, but sadly that never happened.

To-do with your DB question are you referring to your Port issue?
If so then you need to clamp the values like the following:

Code: Select all

$newValue = 90000;

// clamp newValue to a range of 0 to 100,000.
$clampedValue = ClampValue(0, 100000, $newValue);

// Clamp function within minValue and maxValues.
function ClampValue($minValue, $maxValue, $value)
{
    return max($minValue, min($maxValue, $value));
}
With the above function you can set the min and max allowed value range for a number :)

As for putting your code on GitHub, as long as all the code is publically available including and importantly your changes you "should" be fine.
You might have to include the licence file as well as well as keeping to the set licence type.

Current look for the Scheduler Checker so far...

Image

So its getting there.
The only issue is if you are not checking it, it could go out of sync and then later on go back into sync and you wouldn't be aware of it.
But there are ways around that, but would require more changes to the game and more chances to break something.
TheMightyDude::Blacknova Development.
Development Blog YouTube Dev Channel Twitter Twitch

retrodigital
Posts: 10
Joined: Sun Feb 26, 2017 21:42 UTC

Re: Trade Wars 2117

Post by retrodigital » Thu May 25, 2017 02:50 UTC

JokerAce wrote:
TheMightyDude wrote:When you first run the page, say the main index page: http://bnt.jokersworld.com/index.php you will see the timer go negative then back to the value set in the config which is 300 seconds i.e. 5 mins.

When ever it displays a negative number when the page is first refreshed, scheduler has either missed the last update or its not being called I.e. cron not calling scheduler or there is errors in the code.

I have just refreshed it loads of times and it rolled over, and started working, so my guesses are that one of the shed_xxxx files are breaking some place.

So the Apache error logs will need to be looked at.
Okay, awesome. Thanks for that info. I'll look into it and try to figure out what's going wrong.

If one of the scheduler timing values in config is out of bounds, could that cause this condition? That's my first guess since that's the last seemingly related stuff I was messing with recently.
I don't know for sure on this but I'd almost assume your cronjob would have to run as often as your specified tick rate.. Mine is 1 minute and I have my cronjob set to run every 1 minute. If I'm wrong I'm sure someone would know for sure.

Also I had a heck of a time getting scheduler.php to run using cron.. Not sure if its a bug or what but the only way I have successfully run mine using cron was to us the command like this:

lynx -lss=/path_to/lss_file/lynx.lss "https://www.url.com/scheduler.php?swordfish=password" >/dev/null 2>&1

running it via PHP directly never worked for me and no idea why at this point.

JokerAce
Posts: 17
Joined: Thu Apr 27, 2017 05:01 UTC

Re: Trade Wars 2117

Post by JokerAce » Thu May 25, 2017 03:56 UTC

retrodigital wrote:
JokerAce wrote:
TheMightyDude wrote:When you first run the page, say the main index page: http://bnt.jokersworld.com/index.php you will see the timer go negative then back to the value set in the config which is 300 seconds i.e. 5 mins.

When ever it displays a negative number when the page is first refreshed, scheduler has either missed the last update or its not being called I.e. cron not calling scheduler or there is errors in the code.

I have just refreshed it loads of times and it rolled over, and started working, so my guesses are that one of the shed_xxxx files are breaking some place.

So the Apache error logs will need to be looked at.
Okay, awesome. Thanks for that info. I'll look into it and try to figure out what's going wrong.

If one of the scheduler timing values in config is out of bounds, could that cause this condition? That's my first guess since that's the last seemingly related stuff I was messing with recently.
I don't know for sure on this but I'd almost assume your cronjob would have to run as often as your specified tick rate.. Mine is 1 minute and I have my cronjob set to run every 1 minute. If I'm wrong I'm sure someone would know for sure.

Also I had a heck of a time getting scheduler.php to run using cron.. Not sure if its a bug or what but the only way I have successfully run mine using cron was to us the command like this:

lynx -lss=/path_to/lss_file/lynx.lss "https://www.url.com/scheduler.php?swordfish=password" >/dev/null 2>&1

running it via PHP directly never worked for me and no idea why at this point.
Yes, I'll have to change the cron cycle rate when I make the change to 1 minute cycles.

I had no problem with cron using:
/usr/bin/lynx --dump http://WEBSITE.COM/BLACKNOVA/scheduler. ... h=PASSWORD> /dev/null

You can also use wget as an alternative. I haven't look up the lss switches you're using so not sure what they would be doing.

I think that I understand as well as possible the logic behind the scheduler after today's help.

If I didn't have to get up at 4am, I'd be hacking away right now. But tomorrow I'll get to it and report back to you guys on the results.

TheMightyDude has my head filled with visions of gumdrops now. Ideas to take this a little further.
I'm going to implement some of the ideas and see where that leaves things.

@TheMightyDude - Where do you stand on your v2 project?
Maybe after I patch up my instance and get that going, we should hack at some of those ideas. ☺

I learn constantly and I enjoy when I can plug away at something and get some results. I've spent over 20yrs in IT and some things are a bit boring at this point but the thing I love is there is always more to learn.

Plus I was a hardcore Trade Wars junky since I was about 8 years old. It's amazing how something that seems so relatively simple could be so well constructed and so entertaining that we still seek the same or similar entertainment over 30 years later.

I'd better go pass out before I get some ideas. ☺

JokerAce
Posts: 17
Joined: Thu Apr 27, 2017 05:01 UTC

Re: Trade Wars 2117

Post by JokerAce » Thu May 25, 2017 06:33 UTC

TheMightyDude wrote: To-do with your DB question are you referring to your Port issue?
If so then you need to clamp the values like the following:

Code: Select all

$newValue = 90000;

// clamp newValue to a range of 0 to 100,000.
$clampedValue = ClampValue(0, 100000, $newValue);

// Clamp function within minValue and maxValues.
function ClampValue($minValue, $maxValue, $value)
{
    return max($minValue, min($maxValue, $value));
} 
With the above function you can set the min and max allowed value range for a number :)
Would it be easier to correct the negative using abs()

Ex:

Code: Select all

<!DOCTYPE html>
<html>
<body>

<?php
echo(abs(6.7) . "<br>");
echo(abs(-6.7) . "<br>");
echo(abs(-3) . "<br>");
echo(abs(3));
?>

</body>
</html>
The output then would be:
6.7
6.7
3
3

No negative numbers result and it wouldn't limit the math output artificially.

Would this be a viable way to simplify the correction?
I haven't looked at the code yet but I'm guessing it would mean only minor changes would be needed versus clamping.

You'll know better than I but that's where my thinking and researching took me.

User avatar
TheMightyDude
Site Admin
Posts: 311
Joined: Thu Apr 17, 2014 09:15 UTC

Re: Trade Wars 2117

Post by TheMightyDude » Thu May 25, 2017 14:27 UTC

JokerAce wrote: Yes, I'll have to change the cron cycle rate when I make the change to 1 minute cycles.

I had no problem with cron using:
/usr/bin/lynx --dump http://WEBSITE.COM/BLACKNOVA/scheduler. ... h=PASSWORD> /dev/null

You can also use wget as an alternative. I haven't look up the lss switches you're using so not sure what they would be doing.

I think that I understand as well as possible the logic behind the scheduler after today's help.

If I didn't have to get up at 4am, I'd be hacking away right now. But tomorrow I'll get to it and report back to you guys on the results.

TheMightyDude has my head filled with visions of gumdrops now. Ideas to take this a little further.
I'm going to implement some of the ideas and see where that leaves things.

@TheMightyDude - Where do you stand on your v2 project?
Maybe after I patch up my instance and get that going, we should hack at some of those ideas. ☺

I learn constantly and I enjoy when I can plug away at something and get some results. I've spent over 20yrs in IT and some things are a bit boring at this point but the thing I love is there is always more to learn.

Plus I was a hardcore Trade Wars junky since I was about 8 years old. It's amazing how something that seems so relatively simple could be so well constructed and so entertaining that we still seek the same or similar entertainment over 30 years later.

I'd better go pass out before I get some ideas. ☺
The command line for cron should work as how we show it in the INSTALL file and also what is shown above, I have always used that without any issues at all.

As with BNT v2 I still have plans for 2 versions, sadly they have been put on hold until next year, hopefully there will be some great news before then on why the delay.

Anyway the 2 versions were as follows:
  1. Exact same version recoded to use the Unity Engine for both Windows, Mac and Linux.
    A WebGL version "might" also be created for playing in a browser at a later date if possible.
  2. A completely new version based in the BNT Universe but as a MMO aspect, real-time updating, first person shooter, space simulation shooter, with Quest Hubs, a range of different Factions, Races, Ship Classes, Resources, XP Levelling System, PvP Combat Areas and so on.
Granted the second one would take very long to do and might have financial issues due to the hardware involved, so I would have to look into ways to get some regular income to pay for the hardware, whether it be a subscription or built in micro transactions.
But until then I was going to try and create a version like what we have now so that we keep our what we have left user base.

I know I said two versions, but there could be a third version which "could" be a version in between the two, I have not really looked into that as yet.
TheMightyDude::Blacknova Development.
Development Blog YouTube Dev Channel Twitter Twitch

User avatar
TheMightyDude
Site Admin
Posts: 311
Joined: Thu Apr 17, 2014 09:15 UTC

Re: Trade Wars 2117

Post by TheMightyDude » Thu May 25, 2017 15:08 UTC

JokerAce wrote: Would it be easier to correct the negative using abs()

...

No negative numbers result and it wouldn't limit the math output artificially.

Would this be a viable way to simplify the correction?
I haven't looked at the code yet but I'm guessing it would mean only minor changes would be needed versus clamping.

You'll know better than I but that's where my thinking and researching took me.
While that might work in most cases, using a clamp would give you more control over the actual value range, using ABS(...) would only make all values positive, this might work ok for now, but might cause issues later on, which might be why we never used it.

Like suppose the value got that high say 1 value more than the BIGINT (-9,223,372,036,854,775,807 to 9,223,372,036,854,775,807)
Soooo using the max value (i.e. 9,223,372,036,854,775,807 + 1) that will not equal 9,223,372,036,854,775,808, in fact it would equal 9.2233720368548E+18 which is 9,223,372,036,854,800,000.

So if you have the max value 9,223,372,036,854,775,807 you could add 1 or 10 or even 1000 it would still equal 9.2233720368548E+18 which is 9,223,372,036,854,800,000.

Using a calculator on my PC 9,223,372,036,854,775,807 + 1 equals -9,223,372,036,854,775,808, sadly on PHP it doesn't it equals 9.2233720368548E+18 which is where the issue lies.

This was some of the issues we have had with large numbers.

Also using either the Clamp or ABS versions, you are not resolving the issue, you are just sweeping it under the rug.
You really need to find out what's causing the actual issue and fix that.

What needs to really be done is lower everything and stop it getting that high in the first place and also putting in an absolute max value and when it hits that value it goes no higher.
TheMightyDude::Blacknova Development.
Development Blog YouTube Dev Channel Twitter Twitch

JokerAce
Posts: 17
Joined: Thu Apr 27, 2017 05:01 UTC

Re: Trade Wars 2117

Post by JokerAce » Thu May 25, 2017 15:23 UTC

TheMightyDude wrote: Anyway the 2 versions were as follows:
  1. Exact same version recoded to use the Unity Engine for both Windows, Mac and Linux.
    A WebGL version "might" also be created for playing in a browser at a later date if possible.
  2. A completely new version based in the BNT Universe but as a MMO aspect, real-time updating, first person shooter, space simulation shooter, with Quest Hubs, a range of different Factions, Races, Ship Classes, Resources, XP Levelling System, PvP Combat Areas and so on.
Granted the second one would take very long to do and might have financial issues due to the hardware involved, so I would have to look into ways to get some regular income to pay for the hardware, whether it be a subscription or built in micro transactions.
But until then I was going to try and create a version like what we have now so that we keep our what we have left user base.

I know I said two versions, but there could be a third version which "could" be a version in between the two, I have not really looked into that as yet.
The first sounds doable and a bit more graphical than the text based roots of BNT.

The second, I would leave the infrastructure to Steam. There'd be no affordable way to host that type of game. I'm pretty sure Steam will host your game and take a piece from your sales.
That way would make the game much closer to reality.
It sounds a bit like that vaporware Star Citizen.

I would be glad to contribute where I can if you want to clean up this version and add some new features. Haggling, Federation activity, better AI for Xenobes with procedural spawning... Increase the NPC dialogue and add some less than predictable behaviors, better player engagement and interaction.
Perhaps In-game billboards for real world advertisers to help pay for it. Like you'd see in your car driving down the highway, not obnoxious banner ads or anything. Make it add to the flavor of the game rather than detract. Perhaps add some visual elements like HTML5 transitions when you are traveling, etc.

That's a pretty big list of ideas but I'm sure some of them are usable and possible to implement without excessive time consumption and learning curves.

Haggling, Feds, Xenobe activity would, personally be the highest on my list beyond a game that works without hiccups.

I wonder if there's any other web based language that would allow for using pre-built APIs to do some of the heavy lifting such as the AI and authentication (although PHP can be used for that.)
That may involve moving some of the work to the client with a small executable or something.

Okay, now I'm just thinking out loud and typing.

Are any of these ideas in line with the idea you have of building another game similar to this to bridge the gap and maintain interest?

Post Reply