Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 508 509 [510] 511 512 ... 796

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

Sergarr

  • Bay Watcher
  • (9) airheaded baka (9)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7635 on: August 07, 2015, 04:31:13 am »

I just spent about 15 minutes typing up a question to ask in this thread, stopping after every assertion I made in my description of the problem when I realized it might not be true, testing the assertion, narrowing down my idea of the problem as a result, and then deleting that part of the post. I deleted the entire post this way and answered my own question.

I think I'll add "write fake forum post" to my list of debug tools now.
Huh, I do that (writing fake forum posts) all the time, when I want to write some stupid emotionally relieving thing, but don't actually want everyone else to know about it.
Logged
._.

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7636 on: August 07, 2015, 06:08:10 am »

there you have it

http://blog.codinghorror.com/rubber-duck-problem-solving/

also you can read the whole blog, it's interesting (well, who doesn't know him by today? it's like being in science and not knowing who Newton is and what he did)
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7637 on: August 07, 2015, 07:11:22 am »

(well, who doesn't know him by today? it's like being in science and not knowing who Newton is and what he did)
Newton? Never heard of him. ???
Thanks for the link, seems interesting enough.
Logged
Taste my Paci-Fist

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7638 on: August 08, 2015, 07:18:25 am »

I always stumble across links to Coding Horror while reading programming-related things, read it for an hour or two, and then forget what it was called when I want to read more. There's a lot of good stuff in there that I didn't really consider.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Uristides

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7639 on: August 08, 2015, 11:21:19 am »

I just spent about 15 minutes typing up a question to ask in this thread, stopping after every assertion I made in my description of the problem when I realized it might not be true, testing the assertion, narrowing down my idea of the problem as a result, and then deleting that part of the post. I deleted the entire post this way and answered my own question.

I think I'll add "write fake forum post" to my list of debug tools now.
Time to buy yourself a rubber duck.

edit: well darn, that's what I get for not refreshing the page before answering
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7640 on: August 08, 2015, 01:45:44 pm »

Typing up questions motivates me to solve my own problems, but in a different way. I want to be absolutely sure that I didn't make an embarrassingly obvious mistake before I ask somebody :P Last night I was doing something involving raycasts in Unity and was having trouble. I was about to ask when I realized that a piece of my scene didn't have a collider.

In my defense though, there was a small bit of my scene that did appear as if raycasts were working. There was a partial overlap with some stuff that I had added in the Editor, so I was probably clicking through to that collider, yet it appeared as if I were successfully clicking on the mesh that had no collider.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #7641 on: August 09, 2015, 07:49:00 am »

also you can read the whole blog, it's interesting
I have no choice, his blog posts are as link-filled as tvtropes articles. I had like 9 tabs open at some point.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7642 on: August 10, 2015, 01:30:07 pm »

After renaming my Poslin operations to something more readable I started to reimplement the standard library. Then I decided that this was stupid and instead started using replace-regexp in Emacs instead.
But it's still a painful process, when every replacement looks something like this:
Code: [Select]
M-x replace-regexp
\(^\| \)operation-name-here\( \|$\)
\1new-operation-name-here\2
Is there an easier way? Some program I can just provide a table with all the words to replace that then does the replacing?
Logged
Taste my Paci-Fist

breadman

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7643 on: August 10, 2015, 04:51:04 pm »

Is there an easier way? Some program I can just provide a table with all the words to replace that then does the replacing?

It seems like there should be such a program, but I'm not finding one.  I suppose it's possible to whip up something with Perl, though.

Meanwhile, word boundary sequences should simplify the manual process:

Code: [Select]
M-x replace-regexp
\<operation-name-here\>
new-operation-name-here
Logged
Quote from: Kevin Wayne, in r.g.r.n
Is a "diety" the being pictured by one of those extremely skinny aboriginal statues?

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7644 on: August 10, 2015, 05:11:08 pm »

Well, our first assignment in C++ class was to write such a program. And most of the people in this class have never coded before, except a previous semester using Unity/C#. So maybe that's why no such program exists, because it's seen as too low level.

BTW I haven't really used emacs, but is it possible to pull in those actual commands from a file? If so, it would be trivial to make a program that outputs the commands themselves and saves you a lot of typing and/or coding.
« Last Edit: August 10, 2015, 05:14:26 pm by Reelya »
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7645 on: August 10, 2015, 06:23:08 pm »

After renaming my Poslin operations to something more readable I started to reimplement the standard library. Then I decided that this was stupid and instead started using replace-regexp in Emacs instead.
But it's still a painful process, when every replacement looks something like this:
Code: [Select]
M-x replace-regexp
\(^\| \)operation-name-here\( \|$\)
\1new-operation-name-here\2
Is there an easier way? Some program I can just provide a table with all the words to replace that then does the replacing?
May I recommend regexxer (available in your local package manager) for what you're trying to do? It's an incredible tool that can do in-place regex matching and substitution in multiple files at once. You'll be done in literally no time. Note that regexxer uses Perl regex notation, so you write \b for word boundaries.
« Last Edit: August 10, 2015, 06:27:19 pm by MagmaMcFry »
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7646 on: August 11, 2015, 02:31:18 am »

Is there an easier way? Some program I can just provide a table with all the words to replace that then does the replacing?

It seems like there should be such a program, but I'm not finding one.  I suppose it's possible to whip up something with Perl, though.

Meanwhile, word boundary sequences should simplify the manual process:

Code: [Select]
M-x replace-regexp
\<operation-name-here\>
new-operation-name-here
Hey, thanks! I missed that one. I tried it with \(\b\), but that was ugly and matched hyphens.

BTW I haven't really used emacs, but is it possible to pull in those actual commands from a file? If so, it would be trivial to make a program that outputs the commands themselves and saves you a lot of typing and/or coding.
You can actually program your own commands, using Emacs Lisp, but I was hoping for an easier solution. I'd have to learn Emacs Lisp, and as far as I know that doesn't have lexical scope, which sounds scary. But I should probably learn it either way…

May I recommend regexxer (available in your local package manager) for what you're trying to do? It's an incredible tool that can do in-place regex matching and substitution in multiple files at once. You'll be done in literally no time. Note that regexxer uses Perl regex notation, so you write \b for word boundaries.
That sounds awesome. I'll have a look.
Logged
Taste my Paci-Fist

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7647 on: August 11, 2015, 05:19:04 am »

So,
Code: [Select]
\<name\>
matches the name in
Code: [Select]
foo-name-bar
which means I can't do it that way without changing the Emacs parse tables.

I'll use regexxer. Perl regular expressions only use whitespace as word delimiters, as far as I can remember.


Edit:
Perl regular expressions don't only use whitespace/file-end/file-beginning as word delimiters. There is no such boundary type, for whatever reason. Also, inside of [], ^ has a different meaning.
So I have to use
Code: [Select]
(^|\s)\Qold-name\E(\s|$)
\1new-name\2
Only that capture groups don't seem to function in the replacement string in regexxer. I also tried with
Code: [Select]
\g1new-name\g2
and
Code: [Select]
\g{1}new-name\g{2}
Neither works, the \g is just interpreted as a g. It does work inside the search regex, though. Of course that doesn't help me at all.

I guess I'll whip something up with cl-ppcre that just steps through all the different poslin tokens and asks me whether to replace them and with what.
« Last Edit: August 11, 2015, 06:34:40 am by Antsan »
Logged
Taste my Paci-Fist

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7648 on: August 11, 2015, 06:46:38 am »

I'll use regexxer. Perl regular expressions only use whitespace as word delimiters, as far as I can remember.

Edit:
Perl regular expressions don't only use whitespace/file-end/file-beginning as word delimiters. There is no such boundary type, for whatever reason. Also, inside of [], ^ has a different meaning.
So I have to use
Code: [Select]
(^|\s)\Qold-name\E(\s|$)
\1new-name\2
Only that capture groups don't seem to function in the replacement string in regexxer.

Perl's got your back. If you want to match certain character classes before or after your actual search string without actually including them in a string (or if you just generally want to have custom word boundaries), you can use Perl's positive and negative look-ahead and look-behind assertions. For example, if you want to match a string surrounded by whitespace, but not the actual whitespace, you could write (?<=\s)YOURSTRINGHERE(?=\s). This will match YOURSTRINGHERE surrounded by whitespace, but it won't mess with the whitespace when replacing. If you need it to work work at the beginning or end of your text, use (?<!\S)YOURSTRINGHERE(?!\S), this will match if non-whitespace characters are neither before nor after YOURSTRINGHERE.

EDIT: You may want to have word boundaries at punctuation symbols too. In that case, it's best to define a character class that contains exactly the characters that are part of your words. In your case, [\w\-] should do the trick. \w is all the alphanumerical characters (also underscore), and the \- is a hyphen. So the expressions you want are (?<=[\w\-])old-name(?=[\w\-]) or alternatively (?<![^\w\-])old-name(?![^\w\-]).
« Last Edit: August 11, 2015, 06:53:10 am by MagmaMcFry »
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7649 on: August 11, 2015, 07:19:43 am »

Nah, I really want nothing but whitespace/line-delimiters as word boundaries. There is no punctuation in poslin. One of the rules of poslin is that any token always must be surrounded by whitespace (where line beginnings/endings count as whitespace).

Thanks for the look-ahead/-behind stuff!

Funnily enough I'm almost done with my program. Best thing is: I won't need to write the regexes again. I can just import them from the poslin code.
Logged
Taste my Paci-Fist
Pages: 1 ... 508 509 [510] 511 512 ... 796