Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 391 392 [393] 394 395 ... 796

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

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5880 on: May 18, 2014, 08:55:57 pm »

What do you mean by size?

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5881 on: May 18, 2014, 08:59:15 pm »

What do you mean by size?
How large they are in bytes. From my understanding and what testing I have done the size of the modulus determines the size of the file that I am able to encrypt.   
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5882 on: May 18, 2014, 09:04:03 pm »

I believe it should be equal to size(first number)+size(second number) at most.
Logged

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5883 on: May 18, 2014, 11:38:38 pm »

If by size you mean the size including padding in memory then it's size(Type) which for integers is a word (or two for 64 bit). Type is the run-time type of the product.

If you want to exclude padding: ceiling(ln(firstNumber*secondNumber)/ln(2)) bits or ceiling(ln(firstNumber*secondNumber)/ln(8 )) bytes (assuming unsigned numbers)

Where of course, ceiling(ln(firstNumber*secondNumber)/ln(2)) = ceiling(ln(firstNumber)/ln(2) + ln(secondNumber)/ln(2))  <= ceiling(ln(firstNumber)/ln(2)) + ceiling(ln(secondNumber)/ln(2)) = size(firstNumber) + size(secondNumber) where size() here excludes padding.
« Last Edit: May 18, 2014, 11:45:27 pm by da_nang »
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

Kassire

  • Bay Watcher
  • The damning skull motif
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5884 on: May 19, 2014, 02:27:40 pm »

Am I an idiot? I've been working with the unity3d 2d tools (Sample assets) and for some reason the box collider 2d won't work as I'm trying to have the player be on the ground and the player is just clipping through the ground.

Some things to try:

  • Are the player and the ground on the same layer?
  • Are either colliders marked as a trigger (triggers won't physically collide with anything)
  • Are you accidently mixing 2d and 3d colliders/rigidbodies
  • Is everything scaled properly? i.e. no microscopic player and floors. (compare it to a default cube, which is 1m x 1m x 1m)
Thanks for the help, now its working
Logged
All shall be well, and all shall be well and all manner of thing shall be well

flame99

  • Bay Watcher
  • Lady Stardust & her songs of darkness and disgrace
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5885 on: May 21, 2014, 10:38:38 am »

Well, I've become proficient enough in Python that I might as well post something here. As for actual questions, does anyone know if there's a better way to handle commands in a Zork-style adventure game than just using raw_input() and checking if it matches any commands stored?
Logged
It/its, they/them, in order of preference.

Not gay as in happy, queer as in fuck you.

gigaraptor487

  • Bay Watcher
  • Escaped Lunatic now civilised
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5886 on: May 21, 2014, 11:43:19 am »

Maybe you could create a dictionary file of nouns and verbs and then do comparisons on them and do resultant output based on the contents of the file. For example, writing 'move north' may move the player one element up the map array.

It may be overly complex as it may become somewhat of a language in it's own right but It would be useful as It would be easier to modify universally.
Logged
Hehe, you thought there would be an interesting sig here

I now run a program which brings old multiplayer games back to life : click

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5887 on: May 21, 2014, 12:20:40 pm »

Having tried myself, making a command parser is a mayor PITA.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5888 on: May 21, 2014, 12:32:47 pm »

Having tried myself, making a command parser is a mayor PITA.

Maybe I'll do that to keep myself busy at home. Sounds fun!

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5889 on: May 21, 2014, 12:39:40 pm »

LOOP THROUGH THE TEXT FORWARD WHILE LOOKING FOR SOMETHING THEN LOOP BACKWARD TO VERIFY IT THEN LOOP FORWARD AGAIN TO FIND SOMETHING MORE FITTING THEN REPEAT. That's what it feels like.

Maybe I just suck at coding :P
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

flame99

  • Bay Watcher
  • Lady Stardust & her songs of darkness and disgrace
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5890 on: May 21, 2014, 12:45:40 pm »

Maybe you could create a dictionary file of nouns and verbs and then do comparisons on them and do resultant output based on the contents of the file. For example, writing 'move north' may move the player one element up the map array.

It may be overly complex as it may become somewhat of a language in it's own right but It would be useful as It would be easier to modify universally.
...Okay, I'm just going to stick with raw_input() now.
Logged
It/its, they/them, in order of preference.

Not gay as in happy, queer as in fuck you.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5891 on: May 21, 2014, 12:54:58 pm »

You could do something similar to regex.

GET <thing> FROM <place>

And check to see if THING and PLACE exist through a list of keywords tied to the things. Then you only need so many generic commands that deal with items and the like.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5892 on: May 21, 2014, 02:24:36 pm »

Having tried myself, making a command parser is a mayor PITA.

I made a text parser a while back for materials in DF. Ask for a material, it gives you that in liquid form.

It's kinda dumb. IIRC "dwarf eye" gives you blue jay egg yolk or something.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5893 on: May 21, 2014, 02:26:12 pm »

Having tried myself, making a command parser is a mayor PITA.

I made a text parser a while back for materials in DF. Ask for a material, it gives you that in liquid form.

It's kinda dumb. IIRC "dwarf eye" gives you blue jay egg yolk or something.

Now I must make Dwarf Eye Drop Soup(tm) a thing in Dwarf Fortress.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #5894 on: May 21, 2014, 02:43:19 pm »

I made a text parser from scratch. Yes it's as tedious as it sounds. The trick is to split the process of parsing the text into two parts.

1.) The raw text typed by the player is sent to the parser class, which separates the text into several possible forms:
Code: [Select]
verb
Code: [Select]
verb noun
Code: [Select]
verb noun preposition nounOf course there are other potential forms, but these are the most common. The way mine recognized verbs, nouns, etc. is through a set of words I defined and gave to the parser as input. The words (nouns or verbs) are given a name, and a set of alternate names. If the parser finds one of the alternate names in the text, it replaces it with the main name. This way your code only has to refer to the main name of the noun or verb, while the parser handles synonyms. It looked like this:
Code: [Select]
addAction("get");
setAltNames(4, "pick up", "take", "swipe", "yoink");

2.) The parser class passes the nouns, verbs and prepositions it found to whatever function will interpret it. The way I did this was make interpreting functions for items and the "room" the player is currently in. If neither of these can interpret the player's intent, it falls through to a general interpreting function. This is where you put error messages and special cases.
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
Pages: 1 ... 391 392 [393] 394 395 ... 796