Let's get programmy!

If you have some randomness to share that you can't post elsewhere, this is the place to do it.

Is Assembly the best programming language?

Yes
3
9%
Oh God my eyes
3
9%
Oh God my brain
12
38%
I perform unholy incantations to keep Assembly at bay
4
13%
Real men write binaries by hand
10
31%
 
Total votes: 32
Callid
User avatar

Ratio vincit omnia.

Posts: 1433

Re: Let's get programmy!

Postby Callid » September 26th, 2012, 4:13 pm

Hmm, I do wonder, is there a Java library that lets you do stuff similar to that?

Code: Select all

.txt-file:
task = You have been tasked by $taskGiver to $$taskDesc. $tgGender will reward you with $$reward.
taskDesc = $verb $number $object
reward = $=gold $/Simplified - of course, reward might not only be gold
gold = $number+gp $/Note the difference from "$number gp"!


Call:
String[] arg = {"task", "taskGiver=the Duke", "tgGender="+duke.getNominativePronoun(), "taskDesc.verb = kill",
      "taskDesc.object = the King", "task.reward.number = 1000"}; //Note that it's not task.reward.gold.number
System.out.println(UnknownLibrary.getLine(arg));

Output:
You have been tasked by the Duke to kill the King. He will reward you with 1000gp.
If  ;), :D, ;D, ::), :P, :-X, :o or >:D are attached, that paragraph may not be 100% serious. Seriously.
This link provides further information.


Callid Conia Pact - Petitions - Archive
Akonyl
Community Hero
User avatar
Posts: 4200

Re: Let's get programmy!

Postby Akonyl » September 26th, 2012, 4:18 pm

I doubt it, but I don't see why you would need a library for that, it seems fairly trivial if you just use string.Replace().
Callid
User avatar

Ratio vincit omnia.

Posts: 1433

Re: Let's get programmy!

Postby Callid » September 26th, 2012, 6:55 pm

Akonyl wrote:I doubt it, but I don't see why you would need a library for that, it seems fairly trivial if you just use string.Replace().
Only the top level would be all that easy. Interpretation of other stuff, like the $= operator or $++ would be a bit more complicated. In any case, as my friend was kind of like "Yeah, sounds interesting; you don't bother, I'll write that!", I'm not the one programming it anyway. I just wondered if something like this already existed, so he wouldn't have to write anything at all ::)
If  ;), :D, ;D, ::), :P, :-X, :o or >:D are attached, that paragraph may not be 100% serious. Seriously.
This link provides further information.


Callid Conia Pact - Petitions - Archive
monsi
User avatar

I love sarcasm

Posts: 145

Contact:

Re: Let's get programmy!

Postby monsi » September 26th, 2012, 6:58 pm

If he wants, he can just put it in a class, and just call it whenever needed. :x
Last edited by monsi on September 26th, 2012, 10:02 pm, edited 1 time in total.
Image
Image
Akonyl
Community Hero
User avatar
Posts: 4200

Re: Let's get programmy!

Postby Akonyl » September 26th, 2012, 10:08 pm

Callid wrote:
Akonyl wrote:I doubt it, but I don't see why you would need a library for that, it seems fairly trivial if you just use string.Replace().
Only the top level would be all that easy. Interpretation of other stuff, like the $= operator or $++ would be a bit more complicated. In any case, as my friend was kind of like "Yeah, sounds interesting; you don't bother, I'll write that!", I'm not the one programming it anyway. I just wondered if something like this already existed, so he wouldn't have to write anything at all ::)

what would you need $++ for? I still feel like you're overcomplicating this for yourself, as you could basically just do something like (in pseudocode)

Code: Select all

define Map args;
args["task"]="You have been tasked by $taskGiver to $taskDesc. $tgGender will reward you with $reward."
args["taskDesc"]="$taskVerb $taskObject";
args["taskGiver"]="the Duke";
args["tgGender"]=duke.getNominativePronoun(); //which in this case we'll say resolves to "He"
args["verb"]="kill";
args["taskVerb"]="kill";
args["taskObject"]="the King";
args["reward"]=AsGp(amount); //which in this case we'll say is "1000 gp".

String output = "$task";
while(output.Contains('$')) //or however you want to smartly detect that you're done with replacing stuff
{
  for each key in args[]
    String replacer = "$" + key;
    output = output.Replace(replacer,args[key]);
}

makes a map from your variable names with their values, then replaces values in the string until there's nothing left to replace. So, each iteration of the loop would (roughly) go:

"$task"
"You have been tasked by $taskGiver to $taskDesc. $tgGender will reward you with $reward."
"You have been tasked by the Duke to $taskVerb $taskObject. He will reward you with 1000 gp."
"You have been tasked by the Duke to kill the King. He will reward you with 1000 gp."
Callid
User avatar

Ratio vincit omnia.

Posts: 1433

Re: Let's get programmy!

Postby Callid » September 27th, 2012, 2:03 pm

$++ means the next character is erased. I left it out in my example above (for simplification), but it's necessary as otherwise the output, due to taskDesc.number being empty, would be:

Code: Select all

(...)tasked to kill  the King.(...)

I also planned for $+n, $-- and $-n (n being a whole number).
There is also $% to actually write a $ ;)

And it seems my friend has actually successfully written the program now, so :P

EDIT:

Code: Select all

welcome = Welcome to this little game of mine. Press 1 to start a new game, or write "load" in order to load a saved game.
version = Game version: {version}, database version: 0.1.0

//save
save.enterName = Please enter the filename of the savegame.
save.failed = Saving the game as "{filename}" failed. Please enter another filename, try again or write "q" to cancel.
save.success = Game "{filename}" successfully saved!

//load
load.enterName = Please enter the name of the file you want to load the game from.
load.notExistant = "{filename}" does not exist. Please try again or write "q" to cancel.
load.failed = "{filename}" could not be loaded. Please try again or write "q" to cancel.
load.castingError = An error occured while trying to load "{filename}". The file might be of an old version of the game, damaged or otherwise incompatible. Please enter another filename, try again or write "q" to cancel.
load.success = "{filename}" successfully loaded!

//minor errors
error.minor.invalidTime = An error seems to have occured, as the time of day has become invalid ({time}). The game will try to fix the issue by skipping ahead to the morning of the next day. Please report this error to the developers nonetheless.
error.minor.noGame = Neither has a saved game been loaded, not has a new one been started, so there is no game running yet!

//help
help.1 = Apart from whatever input is currently expected, the following commands are available at any time:
help.2 = i, info - displays information on the game and slave
help.3 = s, save - saves the current game to file
help.4 = l, load - loads a game from a file
help.5 = h, help - accesses the help
help.6 = version - displays the current vesion of the game
help.7 = quit - ends the program

(Also, I apparently can't spell "occurred" :x)
Last edited by Callid on September 27th, 2012, 9:16 pm, edited 1 time in total.
If  ;), :D, ;D, ::), :P, :-X, :o or >:D are attached, that paragraph may not be 100% serious. Seriously.
This link provides further information.


Callid Conia Pact - Petitions - Archive
Kirbypepe
User avatar

Wonder what I'll turn into =D

Posts: 135

Contact:

Re: Let's get programmy!

Postby Kirbypepe » September 28th, 2012, 10:38 am

Okay..... So I have a question. I've scoured the internet to find a way to find where exactly the memory leak is happening, to no avail. I was wondering if any of you could help me find out why exactly an activity in android stays in memory (along with the bitmaps it's holding[this is where the largest chunk of memory is]) and doesn't release at least some of the memory upon leaving the screen into another activity. If I was programming in native Java for android I'm sure I'd have more of an insight but we are using Xamarin's Mono for Android libraries that wrap the android ones for use in C#.
Howdy Everyone=]

Things are fantastic. How about for you?

Thats cool.

Wait I just realized, who am I talking to????
Akonyl
Community Hero
User avatar
Posts: 4200

Re: Let's get programmy!

Postby Akonyl » September 28th, 2012, 1:01 pm

Callid wrote:$++ means the next character is erased. I left it out in my example above (for simplification), but it's necessary as otherwise the output, due to taskDesc.number being empty, would be:

Code: Select all

(...)tasked to kill  the King.(...)


then just run .Replace("  "," "); on the string until all instances of multiple spaces are gone as well, unless you're using extra spaces for formatting. And yeah, you could always include escape sequences to write $s, which I just left out to not have to write more, but either way I still think it's a relatively simple problem :P

and sorry kirby, don't have any android experience so I can't help ya much there. And is it an actual memory leak (in that mem usage goes up) or just that it's holding onto stuff longer than you want it to? I would think that android apps would have some way of knowing if they were the foreground or not, possibly you could free the data yourself when you no longer become the focus?
Kirbypepe
User avatar

Wonder what I'll turn into =D

Posts: 135

Contact:

Re: Let's get programmy!

Postby Kirbypepe » September 28th, 2012, 1:26 pm

Well see the activities (Screens) all have a lifecycle and it's within the lifecycle where the programming logic happens. (i.e. OnCreate, OnStop, OnDestroy). The on destroy of the activity is getting called. however the resources don't seem to be released. I have used the Eclipse Memory Analyzer to check and it's still holding onto the resource. However calling the garbage collector more often seemed to make a difference, but not enough to say it's fixed. Since on the Galaxy S3 the app size can be 60MB we like hug that limit a lot.
Howdy Everyone=]

Things are fantastic. How about for you?

Thats cool.

Wait I just realized, who am I talking to????
Akonyl
Community Hero
User avatar
Posts: 4200

Re: Let's get programmy!

Postby Akonyl » September 28th, 2012, 2:16 pm

have you actually run into any issues due to the memory not being immediately freed? Because garbage collectors aren't instantaneous, so it might just not be running until it needs to for performance. And is 60MB really that bad for a S3? I thought they had a lot more memory than that.
Kirbypepe
User avatar

Wonder what I'll turn into =D

Posts: 135

Contact:

Re: Let's get programmy!

Postby Kirbypepe » September 28th, 2012, 6:53 pm

Well see when going from one screen to the next thats 37MB on it's own and that's just the home screen and the next screen in. Going 1 more screen puts us at 54-59MB....... that's because the GC's aren't releasing the memory instantaneous. If we try to go one more we crash. The GC doesn't collect. and well no but that's the limit we have 60MB. =\
Howdy Everyone=]

Things are fantastic. How about for you?

Thats cool.

Wait I just realized, who am I talking to????
ranger
Community Villain
Posts: 3588

Re: Let's get programmy!

Postby ranger » September 29th, 2012, 5:04 am

holy hype systems class is hyping ruining my weekends
Image
Image
Callid
User avatar

Ratio vincit omnia.

Posts: 1433

Re: Let's get programmy!

Postby Callid » September 29th, 2012, 9:18 am

*is totally happy to have succeeded in making his game (partially) mod(d?)able* :D

actions.txt: Actions and their properties
action.java: The action method (called when the action is executed); will be compiled at runtime
lines.txt: Which output the action is supposed to have (strictly speaking optional, but makes things much more clear)
If  ;), :D, ;D, ::), :P, :-X, :o or >:D are attached, that paragraph may not be 100% serious. Seriously.
This link provides further information.


Callid Conia Pact - Petitions - Archive
redangelran
User avatar

inlove with a mystery geek || is stalking someone

Posts: 1530

Re: Let's get programmy!

Postby redangelran » October 29th, 2012, 10:07 am

Callid wrote:*is totally happy to have succeeded in making his game (partially) mod(d?)able* :D

actions.txt: Actions and their properties
action.java: The action method (called when the action is executed); will be compiled at runtime
lines.txt: Which output the action is supposed to have (strictly speaking optional, but makes things much more clear)


congrats! same here. I just finished our special project, which I think isnt really special. (I found lots of source codes over the net -_-)
"I don't mind waiting for people. Because the longer you wait, when you do meet, you'll be more happy."
-Mouri Ran

"Is a reason necessary? I don't know why you would kill someone but as for saving someone-- a logical mind isn't needed, right?"
-Kudo Shinichi

My Twitter||My MAL
-super stupid case fanatic, i'm waiting for you ♥-
Kogorou
User avatar

*drinking beer and playing guitar*

Posts: 1131

Contact:

Re: Let's get programmy!

Postby Kogorou » October 29th, 2012, 3:23 pm

@redangelran
What did you do?

Who is online

Users browsing this forum: MSN [Bot] and 15 guests

cron