Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 468 469 [470] 471 472 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 909492 times)

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7035 on: February 26, 2015, 04:07:40 pm »

but if you want to iterate over a specific range and that doesn't exactly coincide with any data structure you're still going to need to specify start and stop conditions. What if index 0 is reserved for a null condition and you don't want to actually process that index?
Then you'd have "a valid reason for index shenanigans". :P
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7036 on: February 27, 2015, 05:32:00 am »

I started using Unity and I'm running some maze generation code I wrote. It runs in a split second in Visual C# but takes 8 seconds to gen even a small maze inside Unity. Is this just what you have to put up with, or are there some optimization tricks that can get at least passable performance from Unity's C#?

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7037 on: February 27, 2015, 08:51:03 pm »

My ex-boss created a Rube Goldberg machine of a set of batch scripts. These scripts download log files from s3 using s3cmd, split said files based on information contained within using LogParser and LogParser SQL, convert one of the split logs into a csv using LogParser and more LogParser SQL, and finally updates a MS SQL server using that csv, LogParser, and another application of LogParser SQL. Each of these separate steps is a different .bat controlled with a different Windows scheduled task. One of your steps didn't complete in time? Too bad! He saw no problem with any of this.

Given I have called this person my ex-boss and I'm currently complaining about his code, you can probably make two guesses - 1, this eldritch machination doesn't work anymore, and 2, I (and another team member) are tasked with fixing it. You would be correct.

My team uses Linux at work, so I didn't get to just modify the bat scripts and sql files with new paths, etc. Instead, I got to toss out the bats, rewrite the relevant portions in bash, update all of the sql files with correct paths, and then get LogParser running in Wine as it's the only program fit for the task. I've not been allowed to rewrite by the new big boss, however - this isn't a new feature and the old code "works" so he can't sell it as a sexy new thing to the people who pay us. We're just finding out what's wrong with the code (hint: it's the entire first paragraph) and fixing it. My compatriot and I may just say screw it and rewrite it behind his back.

Quick primer on batch files: You either can't easily reuse code or he didn't know how. That means stuff like the following is duplicated across every single .bat file (and, surprisingly, was not miscopied or modified in any of them so they all function more or less the same).
Code: [Select]
:GetMyTimeStamp
:: Subroutine to get timestamp for output log files, in order to isolate files compressed by gzip

FOR /f "tokens=1-4 delims=/ " %%i IN ("%date%") DO (
  SET dow=%%i
  SET month=%%j
  SET day=%%k
  SET year=%%l
)

FOR /f "tokens=1-4 delims=.: " %%i IN ("%time%") DO (
 SET hour=%%i
 SET minute=%%j
 SET second=%%k
 SET hundredth=%%l
)

IF %hour% LSS 10 SET hour=0%hour%

SET MyTimeStamp=%year%%month%%day%%hour%%minute%%second%
GOTO:EOF

It has since been replaced with the following in my new and improved bash script:
Code: [Select]
MyTimeStamp=$(date +"%y%m%d%H%M%S")

It's not exactly equivalent, but it's close enough. I mean it's still horrible and we can't wait until we redo it the right way, but I'll take the latter over the former any day of the week. You ever have to figure out what "SET thing=%otherthing:~-6%" does without having access to a Windows command prompt? I did, and it required some careful Googling.
« Last Edit: March 02, 2015, 06:46:57 am by Mephisto »
Logged

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7038 on: February 28, 2015, 04:08:49 am »

You ever have to figure out what "SET thing=%otherthing:~-6%" does without having access to a Windows command prompt? I did, and it required some careful Googling.
I'm going to guess, strip off the last 6 characters of otherthing and assign that to thing?
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7039 on: February 28, 2015, 08:13:13 am »

You ever have to figure out what "SET thing=%otherthing:~-6%" does without having access to a Windows command prompt? I did, and it required some careful Googling.
I'm going to guess, strip off the last 6 characters of otherthing and assign that to thing?
That's right. It probably should have been more obvious but none of us are shell programmers.
Logged

Uristides

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7040 on: March 02, 2015, 03:06:56 am »

You ever have to figure out what "SET thing=%otherthing:~-6%" does without having access to a Windows command prompt? I did, and it required some careful Googling.
Since you were already using wine to run the logrotate thing, couldn't you use wineconsole to play around with the original batch file? I'm not sure how useable it is, but at least that example you gave worked ok here.
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7041 on: March 02, 2015, 06:49:27 am »

You ever have to figure out what "SET thing=%otherthing:~-6%" does without having access to a Windows command prompt? I did, and it required some careful Googling.
Since you were already using wine to run the logrotate thing, couldn't you use wineconsole to play around with the original batch file? I'm not sure how useable it is, but at least that example you gave worked ok here.

That was one of the easier bits to translate, but yes I could have. I wasn't to the point of running LogParser (sorry, I somehow managed to mistype the program in all seven occurrences - we do use LogRotate, but not in this instance) so I hadn't installed Wine yet.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #7042 on: March 07, 2015, 10:13:41 pm »

Space Invaders: Expert Mode



This is what happens if the minimum and maxiumum delays between each ship shooting is set to 0 (typo in a JSON file + default value is 0 = boom). The game just spams bullets endlessly, and the central event queue completely floods with create bullet events.

Kinda surprised the games logic tick even runs since this should essentially be an endless loop of creating bullets, but it must manage to break out often enough for about 5fps xD

I mean, this is a Bullet Hell variation on Space Invaders I've made anyway, but there are some limits...
« Last Edit: March 07, 2015, 10:28:13 pm by MorleyDev »
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7043 on: March 07, 2015, 10:25:24 pm »

Alternative Title: My CPU is Hotter than Hell
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Uristides

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7044 on: March 08, 2015, 06:29:32 am »

Now put a 1px hitbox on the player ship and an arcane scoring system and make it Space Invaders Bullet Hell edition  :P
Logged

NobodyPro

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7045 on: March 08, 2015, 10:59:08 pm »

I just spent two hours debugging lists when my problem was a random number generator that was generating between 1 and x when I needed a number between 0 and x. I should have realised this earlier when the actor in position 0 always won the simulation.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7046 on: March 08, 2015, 11:24:35 pm »

The same thing happened to me with Unity, because I didn't realize Unity's Random.Range(low, high) function only returned a number in the range "low" to "high - 1".

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7047 on: March 09, 2015, 12:20:20 am »

Yeah, for a 3d noise function I got from the internet, I had to do and tell it to do a million different values to get an accurate range
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #7048 on: March 09, 2015, 01:33:45 pm »

Now put a 1px hitbox on the player ship and an arcane scoring system and make it Space Invaders Bullet Hell edition  :P

The hitbox for the player is only the size of a bullet, it's that bright part in the middle of the player ship :)

Digging into the code, I thought I had it loop until it had to wait for a bullet but I was mistaken.  So 1 per frame per entity, logic runs at 100 frames per second, 50 entities, random speed range, random angles of fire...yeeeah, that's about 5000 bullets a second being created and flying over the screen....So your typical Japanese Bullet Hell game, really :)

Huh, now I want to recreate and profile this and see where the longest running functions are. To the "Wow VS actually has a nice profiler for C++"-mobile!
« Last Edit: March 09, 2015, 01:47:20 pm by MorleyDev »
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7049 on: March 09, 2015, 05:37:15 pm »

Hm. Is there a profiler type thing for Python?

...

In any case, I thought I'd share this thing that I made when I was bored:
Spoiler (click to show/hide)
It's an animated sine wave using random colours, positioning, rate, and so on.

E: This is embedded in a separate game I'm working on, hence the window title. It's in the same program because I'm lazy and couldn't be bothered rewriting the libtcod code for rendering the screen.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.
Pages: 1 ... 468 469 [470] 471 472 ... 796