Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> RGSS Development Tools, Version 0.2 Released - NOT FOR NOVICES
Should the Vector Class Go?
You cannot see the results of the poll until you have voted. Please login and cast your vote to see the results of this poll.
Total Votes: 8
Guests cannot vote 
Adrien.
post Dec 15 2011, 10:24 AM
Post #1


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




Ruby Development Tools
Not for novices!


Welcome to my first ever script compilation posted here on RRR. This is a big deal for me because usually I spend all my time in java or what have you, or if I am not busy at work I am busy working on War of the Souls trying to make that the first game I ever finish in RPG maker VX

So lets get down to what this is all about:

Version: 0.2.2 -> Download
Latest and Greatest: Development Branch
Author: Adam Balan (Adrien.)
License: GPL 3.0


History Lesson
  • Version 0.1.0 Init Release
  • Version 0.1.1 Bug Fixes
  • Version 0.2.0 Updated API, Deleted Files, Cleaned up the Project
  • Version 0.2.1 Finally Deleted Convert To Array
  • Version 0.2.2 - Added Sort, Recursive, exists?(object) - to vector, Data Types Impl, Abstract methods


Why/What?

RPG Maker VX RGSS Development Tools or RGSS Dev Tools is a set of scripts that are meant to be used by developers that ports some functionality from the core code base that is Ruby over to the existing RGSS2, 3 and 1 framework. Things like Vector Class, Singleton Module, Sync Enumerator and so on.

Some Scripts are of my own creation like the error Module and the sort module. This compilation of scripts is meant to be used by developers to bring over into their own scripts to create, enhance and extend their development experience in creating scripts for the average person to use.
The reason for its development is very, very simple: To create tools for developers to make their lives easier.


What do I get when I download Version: 0.2.1

When you go and download the project up above you get the following files along with all test files and the license and even the core source code its self. If you download from the Latest and Greatest You get the source, the license and the test suites but not the project.

  • Vector Class
  • Singleton Module
  • Error Module
  • Synce Enum Class
  • Data Types Impl
  • Abstract Methods
  • Sort Module
  • Recursive Module


API: API Blog
Blog: RGSS Dev
Contribute?: Helping Out

Credits: (please credit me when using) along with: night5h4d3, Ruby Core
Special Thanks: YanFly, Yami, Kread-EX for: Inspiration.

Questions? Comments? Concerns?

Note: This set of scripts is no longer supported on RMRK.


This post has been edited by Adrien.: Dec 18 2011, 03:09 PM


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Dec 15 2011, 10:44 AM
Post #2


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Approved because it does work, but without wanting to sound negative (although I know I will anyways), aside from the Singleton class in some marginal cases, I don't see how it would be more beneficial to use a Vector over an Array. I mean, your vector is basically an array with another name, which returns (@elements) an array and use array methods. Your @array instance variables isn't even used and the to_array method copies all the objects inside @elements into @ar even though @elements is already an array. O_o

The SyncEnum is a good idea, but it isn't thread safe.

Also, camelCase in Ruby is bad practice. One of the reasons is that it slows down the interpreter when an uppercase letter is used for anything else but modules, classes and constants. But even without that, it just screams "look at me I'm different".

Okay, rereading my post, I'm much harsher than I wanted to be, but hey, at least you got an honest opinion.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 15 2011, 11:30 AM
Post #3


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




version 0.2.1 is uploaded and comes with a few very important fixes.


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Dec 15 2011, 11:54 AM
Post #4


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Have you even read my post?


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 15 2011, 12:27 PM
Post #5


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




QUOTE (Kread-EX @ Dec 15 2011, 12:54 PM) *
Have you even read my post?


I did. You were harsh, I accept that and I'm sorry my script offended you. I apologize for any inconvenience I have brought to this forum and this section of the forum. I just thought I would try my hand at creating useful tools for developers but I see now from your post that I have done nothing more then posted a laughing stock.

I will continue to support and update this topic with future versions which I hope to add new content and scripts and fix any issues people find in using these scripts. I have tested the vector class and does what it is suppose to do. if you find a better way of doing things please submit a patch (making sure to submit test cases)

Again I apologize for the atrocity it seems I brought here to RRR. I was simply trying to use what i know of ruby to help people out in creating scripts and being useful member of the community.

I deeply apologize Kread-EX I meant no disrespect.

Notes:

Updated OP


This post has been edited by Adrien.: Dec 15 2011, 12:30 PM


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Dec 15 2011, 12:33 PM
Post #6


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




No, you don't understand. I'm not asking you to apologize or remove your script.

I am a scripter, hence I love tools making my life easier. What I really want to know is how any of this would help me. Why use a vector over an array?

I understand you find the RGSS library lackluster compared to the full Ruby lib. But ask you this question: how much of the full library really helps in making a game?


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 15 2011, 01:27 PM
Post #7


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




QUOTE (Kread-EX @ Dec 15 2011, 01:33 PM) *
No, you don't understand. I'm not asking you to apologize or remove your script.

I am a scripter, hence I love tools making my life easier. What I really want to know is how any of this would help me. Why use a vector over an array?

I understand you find the RGSS library lackluster compared to the full Ruby lib. But ask you this question: how much of the full library really helps in making a game?



I dunno when you'd want to use a vector over an array. that's like asking in general programming why use this over that. Its there if you want to use it, I wanted to see if I could port the poorly designed vector class n ruby core over and I could (with obvious help) it was my first ever script in ruby...

as for how much more I want ported over. I really want threads. but I don't see any realistic reason for porting c files and ruby files over for something I cant see being used (i have this idea of putting parallel processes on a thread....dumbest idea ever don't /troll me for it)

I am dipping my toes into trying to help the community and in learning ruby. coming from a language where you have to make things into objects to "every thing is an object" is hard work for me. but its gotten way easier. I do plan to bring some more OO based objects over that manage to help in manipulating data. I was planning to just stop here and say 0.2.1 is final and its done, but i dunno how much more. I am just trying to not get submerged by all the people who are saying or have said or may say "this is pointless, your code is crap, why do you code likeThis and not like_this....your a pathetic excuse" (not every one is like your Kread. Your mean but nice....)

What else would you as a developer like to see brought over if anything at all? or what direction do you want to see RGSS Dev tools go?

I assumed by me posting this script I was insulting you or that you were laughing hysterically and approved this so the masses could run me out of RRR - I apologize.

in my attempt to start over with RRR and other forums I am just trying to get my foot wet in other waters and play with scripting and coding....


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Dec 15 2011, 02:05 PM
Post #8


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




QUOTE (Adrien. @ Dec 15 2011, 10:27 PM) *
I dunno when you'd want to use a vector over an array. that's like asking in general programming why use this over that.
The thing is, as of now, your vector is pretty much an array with less features. Therefore there is absolutely no reason to use it.
How should I put this... when you code something and release it publicly, you do it for others to use, so you have to think about a reason why they would want to use it. If you can't even find yourself a reason to use your code, it becomes problematic.

QUOTE (Adrien. @ Dec 15 2011, 10:27 PM) *
as for how much more I want ported over. I really want threads.
Ruby threads are inefficient in RM (at least until VX, I haven't tested them in Ace) so in order to manage multithreading, you need to externalize everything in a DLL. Huge work, and no necessarily worth it.

QUOTE (Adrien. @ Dec 15 2011, 10:27 PM) *
I am dipping my toes into trying to help the community and in learning ruby. coming from a language where you have to make things into objects to "every thing is an object" is hard work for me. but its gotten way easier. I do plan to bring some more OO based objects over that manage to help in manipulating data. I was planning to just stop here and say 0.2.1 is final and its done, but i dunno how much more.
There's one thing you need to remember: RPG Maker is a tool to make games. The Ruby library is not only UNIX-oriented, but also intended for a wide scope of applications, and not everything the lib has to offer will have a use in this case. Unlike you're like berka, who clearly states he just scripts for the fun and doesn't care if it's useful or not, you shouldn't lose the sight of that goal.
Especially if you're targeting other scripters, like this seems to be the case here, you have to put yourself in our shoes when we actually write scripts meant to be used in games.

If I can advise you a good start, it would be to roam the support forums and try to fix problems found by the members. Some are complex but others are simple, and this could be useful to you in order to know RGSS better.

QUOTE (Adrien. @ Dec 15 2011, 10:27 PM) *
What else would you as a developer like to see brought over if anything at all? or what direction do you want to see RGSS Dev tools go?
At a personal level? There's nothing really in the default library I really miss. If anything, the problem lies more in how Enterbrain wrote the scripts themselves (fortunately, they made a big effort for RGSS3) and the limitations of the base engine like the graphics rendering (written in C++). What I miss are actually certain extensions (.so files), which can't be rewritten in Ruby without losing too much on a performance side. So I dunno.

QUOTE (Adrien. @ Dec 15 2011, 10:27 PM) *
I assumed by me posting this script I was insulting you or that you were laughing hysterically and approved this so the masses could run me out of RRR - I apologize.
It's not insulting, I'm just critiquing, which is normal. I approved it because it doesn't violate any of the rules.

QUOTE (Adrien. @ Dec 15 2011, 10:27 PM) *
in my attempt to start over with RRR and other forums I am just trying to get my foot wet in other waters and play with scripting and coding....
I said that earlier, you should start by the helping the support forums or if you have trouble understanding fully other people's code, writing simple snippers usable in game - like altered menus or something. Scripting tools require more experience, because, as previously said, you need to put yourself in the other scripters' shoes, therefore knowing what kind of problems they run into.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 15 2011, 02:36 PM
Post #9


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




I will still continue to support this thread, this "library" and what not. as what we have discussed in length here is important I don't want to just throw away everything Ive done. one question you didn't answer is:

in which direction would you like to see this library of scripts go in order to better suite yours and others needs. Currently I had one main goal: port features from ruby that I think would be helpful for developers in developing their scripts.

I guess what I am saying is I want to take this already developed library in a direction that is useful to the community because if I am not mistaken it sounds like your saying:


"cool......but......useless...."

update: OP made prettier

This post has been edited by Adrien.: Dec 15 2011, 11:08 PM


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Dec 15 2011, 11:39 PM
Post #10


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




I did answer your question: in the basic Ruby library, I can't think of anything. Outside of the library, this is another matter. For instance, it's a real pain in the ass to create new windows and scenes sometimes. Something to make the process faster would be helpful.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 16 2011, 10:13 AM
Post #11


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




I wouldn't even know where to begin with that. I mean you technically - from looking at the code: Window_Base.new(params) and theirs your window. Like Im not sure what more you would want.

That and this project is supported between Ace and VX so what ever core RGSS stuff you want in terms of easier development has to be globally acceptable between both. and Since I don't have ACE's English help file or English Scripts I am at a downside. Unless everything is the same in terms of what you want

This post has been edited by Adrien.: Dec 16 2011, 10:48 AM


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Dec 17 2011, 04:20 PM
Post #12


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




What Kread-Ex means is not that he want's this lib to make window/scene creation easier, but rather RGSS/2/3 itself was written is insufficient; and I don't think he means creation of the objects so much as for example - a window that isn't square is a pain, or a window that doesn't use the windowskin template.

Apart from that, I say the concept certainly has merit; however, the vector class is ultimately an unnecessary addition to RGSS/2/3. Why? Simply due to the fact that ruby's array functions as that of a vector.

Consider the common differences between an array and vector in most (if not all) compiled languages:

Array:
1)Size of array need to be declared in advance.
2)Once declared array can't grow in size.
3)Array can store primitive data types.like int,char,...

Vector:
1) No need to declare the size of vector. You may give its size & you may not.
2) Vector can always grow in size if you start adding more element to it than your declared size.
3) Vector can store only object references. Storing primitive data types is not possible in case of vectors.

Then consider the features of a ruby array by default:
1) Size of array can be declared in advance, or left blank
2) Ruby array can be grown by either setting an element out of it's original range or using 'push()'
3) Ruby array stores objects (this includes int, char, etc due to ruby's use of objects for everything such as fixnum, bignum, etc etc)


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 18 2011, 03:15 PM
Post #13


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




I am beginning to think that I would have been better off if I created a simple menu. I'm also beginning to think I have disrespected the greater community of scriptors both professional and hobbyists and for that I am truly sorry it was never my intention.

Since every one is so concerned with the Vector Class. its modeled after the Action Script 3.0 vector class with roots in rubys vector class and java's (very little foot hold in java's)

I know the differences between a an array and a vector. there is no question in that, I prefer a vector over an array personally. I think if you want to be personal or even professional about it None of the scripts I provide are a "useful" addition to the RGSS, 2 or 3 platform and developers don't need any thing more then what Enterbain has provided them with how ever its one of those "nice to have"

I don't like RGSS2, I don't like how it was coded, its clean and easy to read but a lot of it is in need of serious fixing and while some of you are probably going to say "so why not fix it?" no - because a lot of the best scriptors out there have already done that with countless scripts. why add to the pile of things already done? I prefer to say "use these if you want, there additional resources."

Bottom line is:

I am truly sorry I have wasted developers time with my tools and my scripts and I know I am the laughing stock of the moderators of this section of the forum and the scriptors and developers that come here. I just wanted to add in my two scents and my ideas and extend RGSS, 2 and 3 with some useful tools. How ever it looks like that isn't the case and I am truly and deeply sorry for any one I offended or wasted the time of.

None the less:

Version 0.2.2 is released. It offers new features and new coding standards.

Whats new?

Coding Standards

I have been attacked and threatened in other forums and communities because my standards are camelCase and not snake_case. Threatened such that moderators have issued "warns" against me. So I have decided to switch to snake_case. All the code is lower case except for that of class and module names and I have switched over to snake_case where required.

exists?(object) added to the vector class

Does the item your searching for exist? if so return it.

Sort Module

Some people may want to sort the data being pushed into their arrays. These sort methods are array based and take in only arrays. You can read the API in script or on the Blog to better understand how these sorts are used. Quick sort and Merge sort have been brought in, bits from Java assignments, blogs and what have you have been used to create these sorting methods.

I plan to add in the Bubble Sort at a later date.


Recursive Module

-- Not being supported past 0.2.2 and will be deprecated in 0.2.3 and removed in 0.2.4

This was never intended to make it into the RGSS Dev tools how ever some one some where might ind it useful. It contains a sum_of and a Fibonaccie Numbers method. these are just something I read in a book and online and was playing with recursive functions in ruby. I don't see developers needing the use of, or wanting recursive functions so this module won't be supported past this release.


Data Types

This is what i really wanted to focus on in this release. As I was researching how data types are used in ruby I decided to implement a version that I was reading about. For further Information Its best if you read the Documentation in the script its self or the API listed. essentially things like Queue and other sorts of data types can now be implemented. the API has a example as does the Source (under Test Suites) and in the Rpg Maker VX project.

Abstract methods

CODE
abstractmethod     :method_name


has been introduced because of the data types script which introduces data types to the RGSS series. The abstract method implementation essentially states that any method made a abstract method must be complimented in the class that is derived from the class that holds the abstract method. Ruby will throw a not implemented error.

Note on Data Types Impl Script - Do not separate it up. If you want to use the abstract method implementation then please place that class above any class you plan to use that abstract method in.


Whats happening with vector class?

As stated before some people don't like this class, see no use for it or even despise me on a level unknown to me for eve creating it. It was my first script ever created in this set of scripts and I am happy to retire it if the community thinks it should be deleted. a pole for the thread has been created. If the com unity wishes it gone, it will be deprecated in version 0.2.3 and removed in version 0.2.4


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Dec 18 2011, 04:37 PM
Post #14


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




QUOTE
Apart from that, I say the concept certainly has merit;

I don't think you're reading what I am saying. The concept of these tools has the potential of becoming more integrated than that of the SDK.

QUOTE
I know the differences between a an array and a vector. there is no question in that, I prefer a vector over an array personally.

If you know these differences, and know enough ruby to be creating a core library, then you should know that the ruby array lacks little to nothing in comparison to a vector. If you want my two cents worth, drop the vector, and build a matrix module instead; these are far different from an array and their functionality is not native to RGSS/2/3. I think any scripter here would agree to matrices over vectors.

QUOTE
I am truly sorry I have wasted developers time with my tools and my scripts and I know I am the laughing stock of the moderators of this section of the forum and the scriptors and developers that come here.

We're just trying to help. Anyone'd get the same constructive criticism if they submitted a script where - say they only used global variables, put all their code in 1 def and used goto's or whatnot.

QUOTE
As stated before some people don't like this class, see no use for it or even despise me on a level unknown to me for eve creating it.

Umm.. despise? there's only been two of us who've mentioned it's not of much use, and we've explained why even. I've mentioned a viable alternative, and I hope you at least check into it. That being said, I'll take the first step and vote against the vector class.

btw, at least 40% of the code for the vector class was from my help, so don't think of it as a contempt for you creating it.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Kread-EX
post Dec 18 2011, 11:14 PM
Post #15


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Adrien, I really believe your knowledge of Ruby in general and RGSS in particular is too lacking for such an endeavor. Your replies to Nightshade and certain things I've read over at rpgmakervxace.net clearly highlights this fact.

Rather than waving your pride, martyr complex and Java knowledge (in no particular order) around each time you receive criticism, you might want to check out Ruby docs in order to understand what the library does (instead of just copying it).

You will probably answer this with excuses, fake self-deprecation, and fake apologetic behavior, but really, think about it.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 18 2011, 11:34 PM
Post #16


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




My tools are here for people to use, use them or not its up to you.

As for your constructive criticism and your feed back from both Global Mods, I accept it and I take it (read it again because its not something you've ever heard me say...)

as for my "fake" appoligitetic-ness, let me state one more time I really am Sorry to both of you for wasting your time....and that wasn't fake Now if either of you has something your like to see this project take on in terms of VX or VX ace I am all for it as the core foundation is built and the features are added. Keep in mind these are meant to be developer tools and not "plug and play" scripts for players. Kreads Window suggestion has been taken into account. and will be looked at. That is if he can elaborate or if what night5h4d3 has said is correct.


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Zeriab
post Dec 19 2011, 08:25 AM
Post #17


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




Hi Adrien.
I have taken a look at your code and I want you to take a look at your fibonacci number implementation.
There are some fun coding puzzles related to that. :3
Firstly I suggest that you turn your methods into module functions (keyword: "module_function")
I suggest that because they are self-contained methods where doing RGSSRecursive.fib(10) is nice while including the methods into classes does not make much sense. You can do it by putting the keyword like this:
CODE
module RGSSRecursive
  module_function
  def sum_of(value)
(...)


Now I have a question for you: What is the maximum fibonacci number you can calculate that way?
To help you I made a little script which you can use to calculate a fibonacci number within a given time limit: (Assumes you are using the module_function)
CODE
# Settings
fibn  = 30    # The fibonacci number to retrieve
time  = 5     # The timeout in seconds

# Create thread
t = Thread.new do
  $status = :running
  p RGSSRecursive.fib(fibn)
  $status = :done
end

# Sleep for upto the specified timeout in incremental steps of 100 ms
count = 0
step  = 0.1  
while count < time && t.alive? do
  sleep(step)
  count += step
end

# Throw an error if the thread is still running.
# Note: Getting the number printed out and getting an exception is possible
if $status != :done
  throw Exception.new('Timeout occurred')
end

exit


Should you try to run that you'll encounter a problem with your current implementation. What is it that's wrong?
Try you hand at debugging the code yourself. Please do post what you think is the problem. (I find that actually having to write out my thoughts help. I guess that is also applicable for you)
Let me know if you have any trouble fixing the code. Also please do let me know what the maximum number you can calculate in 5 seconds is (+ what the number is)

*hugs*
- Zeriab


__________________________
Go to the top of the page
 
+Quote Post
   
Adrien.
post Dec 21 2011, 09:26 AM
Post #18


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




QUOTE (Zeriab @ Dec 19 2011, 09:25 AM) *
Hi Adrien.
I have taken a look at your code and I want you to take a look at your fibonacci number implementation.
There are some fun coding puzzles related to that. :3
Firstly I suggest that you turn your methods into module functions (keyword: "module_function")
I suggest that because they are self-contained methods where doing RGSSRecursive.fib(10) is nice while including the methods into classes does not make much sense. You can do it by putting the keyword like this:
CODE
module RGSSRecursive
  module_function
  def sum_of(value)
(...)


Now I have a question for you: What is the maximum fibonacci number you can calculate that way?
To help you I made a little script which you can use to calculate a fibonacci number within a given time limit: (Assumes you are using the module_function)
CODE
# Settings
fibn  = 30    # The fibonacci number to retrieve
time  = 5     # The timeout in seconds

# Create thread
t = Thread.new do
  $status = :running
  p RGSSRecursive.fib(fibn)
  $status = :done
end

# Sleep for upto the specified timeout in incremental steps of 100 ms
count = 0
step  = 0.1  
while count < time && t.alive? do
  sleep(step)
  count += step
end

# Throw an error if the thread is still running.
# Note: Getting the number printed out and getting an exception is possible
if $status != :done
  throw Exception.new('Timeout occurred')
end

exit


Should you try to run that you'll encounter a problem with your current implementation. What is it that's wrong?
Try you hand at debugging the code yourself. Please do post what you think is the problem. (I find that actually having to write out my thoughts help. I guess that is also applicable for you)
Let me know if you have any trouble fixing the code. Also please do let me know what the maximum number you can calculate in 5 seconds is (+ what the number is)

*hugs*
- Zeriab


I didn't actually care enough to make the recursive functions worth using, so they are being deprecated but thanks none the less. They were never suppose to make it in and I regret that they did


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th May 2013 - 01:44 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker