Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 6 7 [8] 9 10 ... 796

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

PsyberianHusky

  • Bay Watcher
  • The best at being the worst at video games.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #105 on: January 07, 2012, 08:15:56 pm »

Keep it up, I am somewhat with you. I am starting to stumble over the syntax... less.
You have put all this work into this, I would feel horrid if I didn't force myself to learn now.

I get the idea of what is going on with how Java is handling math, but I still know it is gonna bite me in the ass as soon as I try anything larger.

Surprisingly enough, I have experience working with robotics.  I can help you with that.
Stargrasper confirmed for superhuman
Logged
Thank you based dwarf.

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #106 on: January 07, 2012, 08:16:43 pm »

Most likely it's using UTF-16.
Strings are encoded in Unicode in C#.

So, anyone know a good map of Unicode characters?  It doesn't particularly matter, since I can put the characters themselves into my IDE instead of Unicode numbers, I just have some doubts about how extensible this is.

Likewise, I'm noticing that my roguelike's map drawing function is pretty damn slow, for such a program.  It uses two nested for-loops to determine the x/y position, reads a byte out of a provided 2d-array, then sends that information to a function.  The function interprets the byte according to my notes, and calls another function to write a specified character at the provided location with an interpreting system to tell it what color to write it in.  The result is that drawing a 59x21 map takes an appreciable fraction of a second, slow enough to watch the text wipe over the screen.  Obviously that would be unacceptable if I'm refreshing the screen with every activity, and I can only think of so many ways to expedite that process.  Anyone have an idea for how I can speed up the drawing, at least to a NetHack-fast blink?

I had this idea for cutting out the byte-interpreter by just making the map a 3D-array of bytes, with Z-0 being the Unicode number for the character and Z-1 being a byte to tell it what color to draw in, but on top of rewriting most of my drawing class (not a problem) I don't know the Unicode character set, and I think it's lacking a lot of stuff I want anyway.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #107 on: January 07, 2012, 08:49:26 pm »

However, considering we found out the general objective today, it's unlikely that I'll have to do it any time soon.

Well, when the times comes, feel free to ask.

Keep it up, I am somewhat with you. I am starting to stumble over the syntax... less.
You have put all this work into this, I would feel horrid if I didn't force myself to learn now.

I get the idea of what is going on with how Java is handling math, but I still know it is gonna bite me in the ass as soon as I try anything larger.

Surprisingly enough, I have experience working with robotics.  I can help you with that.
Stargrasper confirmed for superhuman

You're 'somewhat' with me?  What's catching you specifically?  Better to ask specific questions before I disappear for three hours to write more tutorial.  If I'm going too quickly (or too slowly), now would also be a fantastic time to say so.  Also if you want me to do anything differently, say so.  It's supposed to help you learn, and if it isn't fulfilling that purpose, it needs to change to do so.

Math will catch you.  Integer division especially.  That's now one of the first things I check for when math isn't working right.

And don't learn the language because I'm putting work into helping.  Learn it because you want to.  Otherwise you'll hate the ride.

Most likely it's using UTF-16.
Strings are encoded in Unicode in C#.

So, anyone know a good map of Unicode characters?  It doesn't particularly matter, since I can put the characters themselves into my IDE instead of Unicode numbers, I just have some doubts about how extensible this is.

Likewise, I'm noticing that my roguelike's map drawing function is pretty damn slow, for such a program.  It uses two nested for-loops to determine the x/y position, reads a byte out of a provided 2d-array, then sends that information to a function.  The function interprets the byte according to my notes, and calls another function to write a specified character at the provided location with an interpreting system to tell it what color to write it in.  The result is that drawing a 59x21 map takes an appreciable fraction of a second, slow enough to watch the text wipe over the screen.  Obviously that would be unacceptable if I'm refreshing the screen with every activity, and I can only think of so many ways to expedite that process.  Anyone have an idea for how I can speed up the drawing, at least to a NetHack-fast blink?

I had this idea for cutting out the byte-interpreter by just making the map a 3D-array of bytes, with Z-0 being the Unicode number for the character and Z-1 being a byte to tell it what color to draw in, but on top of rewriting most of my drawing class (not a problem) I don't know the Unicode character set, and I think it's lacking a lot of stuff I want anyway.

Will this serve your purposes for a map?

I'm not sure of the best way of speeding your system...I've never coded a roguelike nor worked with C# (though C# is basically Microsoft's version of Java).  Based on what you've said, I see no reason it should be running slowly.  Trace through your code and look for lines that do "work", checks, draws, etc.  Otherwise, I'd have to see the code.  The interpreter is the most likely cause based on what I'm guessing.  Let me know if that Unicode site isn't what you need.
Logged

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #108 on: January 07, 2012, 09:23:47 pm »

Will this serve your purposes for a map?

Let me know if that Unicode site isn't what you need.

Yeah, I can google "Unicode character map" myself.  That doesn't seem to contain whatever Unicode set it is that your basic American PC comes with, just every other one in existence.  And I need a Unicode map that includes characters like-
Code: [Select]
░░░░ - ASCII 176 ▒▒▒▒ - ASCII 177 ▓▓▓▓ - ASCII 178
-which none of them do, as far as I can tell.  Which makes no sense, because NotePad won't let me save a file containing those characters in anything but Unicode format.

As for the drawing program's speed, it became noticeably faster by just taking out the lines I added to print the X and Y positions to make sure it was working.  The only thing I can think of to take any more processing steps out of the drawing function would be my 3D byte array idea, which is what I would need the Unicode map for.


what program would be good for learning in? I never got around to trying programming (revision)

Everybody is going to tell you different things.  I originally learned with Java, and have taught myself more C# (which is very much like Java) in six days than I learned in two years of schooling.  Some people will tell you C++ is better, because it has more libraries and documentation, and runs on non-Windows systems, but learning to code in the first place is much more important than what language you learn in, and C++ is notoriously opaque.  Other people will recommend Python, which is a completely different can of worms I know nothing about.

And no, there is essentially you can write in your compiler that will fuck up your computer.  By the time you learn how to write programs that can do serious harm to an operating system, you'll know enough to not do it by accident anyway.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

PsyberianHusky

  • Bay Watcher
  • The best at being the worst at video games.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #109 on: January 07, 2012, 09:29:05 pm »

Na, I have been wanting to do this forever.

If I want to cast some numbers into a boolean value, is that possible, and  what would that look like?
Logged
Thank you based dwarf.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #110 on: January 07, 2012, 09:31:22 pm »

Likewise, I'm noticing that my roguelike's map drawing function is pretty damn slow, for such a program.  It uses two nested for-loops to determine the x/y position, reads a byte out of a provided 2d-array, then sends that information to a function.  The function interprets the byte according to my notes, and calls another function to write a specified character at the provided location with an interpreting system to tell it what color to write it in.  The result is that drawing a 59x21 map takes an appreciable fraction of a second, slow enough to watch the text wipe over the screen.  Obviously that would be unacceptable if I'm refreshing the screen with every activity, and I can only think of so many ways to expedite that process.  Anyone have an idea for how I can speed up the drawing, at least to a NetHack-fast blink?

I had this idea for cutting out the byte-interpreter by just making the map a 3D-array of bytes, with Z-0 being the Unicode number for the character and Z-1 being a byte to tell it what color to draw in, but on top of rewriting most of my drawing class (not a problem) I don't know the Unicode character set, and I think it's lacking a lot of stuff I want anyway.

That isn't so much anything you did, but rather the fact that writing to the console is slow in c#. There is nothing you can do about it.
Seriously, write a quick program to generate 10,000 random numbers, and it will run before you can blink. Have the same program print each number after it is generated, and suddenly you can time it with your watch. Nothing you can do with fix this, but you have options.

The first is to say Console.FuckThis() and use something else, such as libtcod. This is most often called the easy way.
The second way is to optimise what you write to the console. Never EVER just clear all text, instead just use Console.SetCursorPosition(x, y); to make sure you only write over what changes. Even this might be a little slow, but a lot better.


If I want to cast some numbers into a boolean value, is that possible, and  what would that look like?

Remind me, language of choice?

PsyberianHusky

  • Bay Watcher
  • The best at being the worst at video games.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #111 on: January 07, 2012, 09:34:39 pm »

@Max
Java
Logged
Thank you based dwarf.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #112 on: January 07, 2012, 09:38:22 pm »

I also have experience with robotics, but I'm sure my experience is much more limited. I only know how to program a VEX 2.0 Cortex.

If I do decide to do C/C++/Python tutorials, I'll skip the basics, which Max and Stargrasper have already covered. Most things are similar between similar languages, so I'll only bother bringing up the subtle differences.

Also any code I post here is licensed under the GNU Public License unless noted otherwise. I felt like I should bring this up after the copyright discussion. Feel free to use my code in your programming. Change it, experiment with it, do whatever it takes for you to learn.

Stargrasper, your tutorials, as well as any tutorials anyone decides to post here, are welcomed and encouraged. I'll be adding links to the OP later to make it easier to navigate.

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #113 on: January 07, 2012, 09:38:48 pm »

That isn't so much anything you did, but rather the fact that writing to the console is slow in c#. There is nothing you can do about it.
Seriously, write a quick program to generate 10,000 random numbers, and it will run before you can blink. Have the same program print each number after it is generated, and suddenly you can time it with your watch. Nothing you can do with fix this, but you have options.

Well.  That blows.  No wonder I've seen so few roguelikes written in C#.  Still a good language to learn programming practices with I guess.

The second way is to optimise what you write to the console. Never EVER just clear all text, instead just use Console.SetCursorPosition(x, y); to make sure you only write over what changes. Even this might be a little slow, but a lot better.

That was my intention, after watching it happen.  I do plan to have most of the screen stay in place as much as possible, with things like mobs moving around calling a function to replace the tile they left, and limit whole-screen refreshes to menu switching and such.  I see this will still be an inherent problem.

The first is to say Console.FuckThis() and use something else, such as libtcod. This is most often called the easy way.

I don't have any idea what libtcod means.  One of those "libraries" I hear so much about?

Wait, I actually have libtcod tabbed open from the other day.  What do I do with this thing?  I'm seeing a lot of references to Python and Linux on this site, which tells me it's something I'm not going to have the patience to deal with.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #114 on: January 07, 2012, 09:41:58 pm »

Yeah it's a library. Got tons of functions custom made for roguelikes and stuff in it.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #115 on: January 07, 2012, 09:44:15 pm »

That's probably because it's talking about a Python API and Linux packages. They're cool stuff.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #116 on: January 07, 2012, 09:47:26 pm »

Java
Fuck, does java have a thing for that?
Well I'm going to assume you want 1 to equal true, and 0 for false, right? In that cast, it is as quick as
myBool = (myInt == 1);

I don't have any idea what libtcod means.  One of those "libraries" I hear so much about?

Wait, I actually have libtcod tabbed open from the other day.  What do I do with this thing?  I'm seeing a lot of references to Python and Linux on this site, which tells me it's something I'm not going to have the patience to deal with.
Yes, it is one of these libraries.
There should be a c# version for you to get your hands on, as I recall. Download that.


Now, one you have that file, put it where you like, but remember the file location.
Now back in visual studio, on the left hand side, in your solution explorer, there should be a grey folder called 'references'.
This folder is where all your references to other things are. If you open it, there should be a shitton of things. This is because you are using all this cool shit from the .net framework.
Right click the folder, and 'add referance'
Go to the browse tab, and find that file you downloaded.
Click OK!
Ta da! You added a library! Now go surf porn for half an hour as a reward and you are a real programmer!

I would post screen shots, but my internet is STILL FUCKING CAPPED somehow, so uploading images takes a year, if at all.

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #117 on: January 07, 2012, 09:48:36 pm »

Aquizzar, have you tried this thread for help with your rougelike?
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #118 on: January 07, 2012, 09:50:12 pm »

Well there's third party C# wrappers for the doryen library, but I can't find any downloads for it.

That's probably just me, though.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #119 on: January 07, 2012, 09:52:58 pm »

Libtcod beta is available for C# and provides POV, dungeon generation, truecolour console-like output and dungeon generation tools amongst others.

I'm just going to assume that the link leads to what you need, because like I said, fuck my internets.
Bay12 seems to work ok, but then so do all sites I spend 90% of my time on.
Pages: 1 ... 6 7 [8] 9 10 ... 796