Second Lesson, Break it down.

Started by Ryex, April 18, 2011, 09:44:50 pm

Previous topic - Next topic

Ryex

April 18, 2011, 09:44:50 pm Last Edit: April 19, 2011, 06:39:37 am by Ryex
Second Lesson, Break it down.




"We can dance if we want to, We can leave your friends behind"

*Looks up*

Wha!? No I wasn't dancing the safety dance. That would just be stupid!




Ok here's the second lesson, this and the next few lesions will focus on how to take a system you want to script and break it down into smaller and smaller pieces that until you have something that you can actually script.

These lesions are intended to teach Programming not just Ruby, in fact when we do get down to the ruby side of things I'll only brush briefly on the concepts you need. As such it is a VERY good idea to start reading a simple ruby tutorial in order to learn the syntax.

Programming is a skill, one that allows a human to instruct computers to do tasks. Ruby is a language, a tool by which a person can program. But the fact of the matter is that when learning how to program it is best to realize that, just because one knows the syntax and grammar of a language DOSE NOT mean they can program in it.

As I said these next few lessons will focus on breaking down the system we created so that it can be scripted.  That means be will be working with layers of abstraction

Read this to learn more.
Abstraction - http://en.wikipedia.org/wiki/Abstraction_(computer_science)

Now that you know what I mean by abstraction I'll explain the process.

If you think of the entire system as a whole then you're thinking of the highest level of abstraction that the system has.
Going one 1 layer in abstraction down you'll find that the system is made of three or four smaller pieces. These pieces take in data, compare it to data the pieces keep internally and spit out some new data.

Going down 1 level further you'll find that those three or four smaller pieces are in turn made of other pieces that once again take in data, do something with it, and then return new data. You can keep going like this until you find that you have reached the lowest level of abstraction in our system. This level is made of only the base statements that make up Ruby: assignments, operators, method calls to the standard library, ect.

In truth you could keep going lower from those base statements into the C language, which ruby is built on, and from there even lower into byte code. But that would be pointless. The reason Ruby is so nice to learn with is because all that complicated stuff, like memory management and manipulation, has been abstracted away so that we don't have to deal with it.

So, we are going to break down the system into smaller pieces, going 1 level of abstraction deeper each time.

You're assignment is to write down a model of the system and submit it by posting it inside a spoiler, that way other student don't have to see your work if they don't want to. I encourage you to not look at other's work you don't learn anything that way, at least not with this type of thing. Your trying to grasp a complex concept here, not memorize your multiplication tables :P.

I'll give you a little help to get you started.

Start by writing down everything the system dose, than break those actions out, start by grouping them together if they are all related think of these groups of actions as an object, a little machine that dose all these actions. then break them apart further. Stop when you think the lowest objects in your modal could be scripted in 3-20 lines of code (you don't have to know how, just as long as you think the action is simple enough to be expressed in terms of the simple statements that are Ruby).

Here's a video I mad that might explain the concept better. http://www.youtube.com/watch?v=s8HNrlvRCD8

Each of you submit your own modal. IN SIDE A SPOLIER PLEASE (use this bbcode [spoiler][/spoiler] which results in this )
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Jragyn

Well... Its not coded, but I catagorized the thought, and scribbled out the basic idea...
I am sure there is stuff missing, but its a start, and others can see to have a frame to build off of perhaps? :
Spoiler: ShowHide
[A Skill Progression System]

The system as a whole will advance skills via experience into new skills.


@Each skill will have its own variable, "xp". (not to be confused with .exp)
@Each skill will have a tag, "used", set as true/false dependant on use to determine atrophy.

$A skill really only needs to be checked in battle, as thats where most skills are used.

[CONFIGURATION AREA]
Skill Learning Configuration by user:
skill.id => [[pre-req.skill > usage req.],[pre-req.skill > usage req.]]
(Multiple skill requirements is optional)
(if not listed, then no 'evolution' is possible)

Skill Atrophy Configuration by user:
skill.id => [battles not used before atrophy begins, xp degraded per battle after]
(If not listed, then skill does not degrade)

Scene_Skill Configuration by user:
SHOW_XPTONEXT = true/false
SHOW_XP_BAR = true/false (requires blizzart bars?)
TOGGLE_BUTTON = Input::(button?)

Battle_End Configuration by user:
LEARNED_NEW_MSG = "[chara_name] learned [new_skill]."
EVOLVED_NEW_MSG = "[chara_name]'s skill evolved into [new_skill]."
DEGRADED_MSG = "[chara_name]'s [skill_name] has rusted due to lack of use."
[/CONFIGURATION AREA]

[BATTLE EDIT]
> Can the skill 'evolve'?
>>> If yes, then gain usage XP per use, and tag as "used" to prevent atrophy, Else: Do nothing.
[/BATTLE EDIT]

[BATTLE_END EDIT]
>>> Can the skill 'evolve'?
>>>>> If yes: Has the skill met the prerequisite(s) for 'evolving'? Else, do nothing.
>>>>>>> If yes: 'evolve'. Else, keep gaining experience on usage.
>>>>> Does the skill(s) get replaced or is a new skill learned?
>>>>>>> If replaced, then remove skills and add new skill, Else: add new skill.

>>> If yes: Can the skill degrade?
>>>>> If yes: was the skill tagged as "used"? Else, do nothing.
>>>>> If no: Has the skill been used in user-defined battles?, Else, do nothing.
>>>>>>> If no: reduce usage experience by user-inputted amount. Else, do nothing.
[/BATTLE_END EDIT]

If there is branching, then xp-to-next for skills is kind of difficult to track.

[SCENE_SKILL EDITS]
> Can the skill 'evolve'?
>>> If yes: Is the skill part of a branch or straight line?
>>>>> If branch: then do nothing.
>>>>> If straight: on configurable button-toggle, open mini-window to list skill to 'evolve' into.
?>>>> If straight: Put XP-to-next-(bar?) in skill.name. (User's choice)
[/SCENE_SKILL EDITS]


A bright light can either illuminate or blind, but how will you know which until you open your eyes?

Ryex

April 19, 2011, 02:10:47 am #2 Last Edit: April 19, 2011, 05:25:05 am by Ryex
no, no, no, no. you getting a head of yourself. you NOT supposed to be writing code. your NOT even supposed to be writing pseudo code like that.

your creating a modal, like a flow chart, of how the big idea should break down into smaller parts. you can create this modal however you want. an image of a actual flowchart, or a stack of indented text I don't really care. but DON'T write code. you'll just end up messing your self up latter.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Jragyn

>_<

I see.
So thats... too much detail?
You want a flowchart variation of it?
Guess its time to break out Paint.NET. XD

A bright light can either illuminate or blind, but how will you know which until you open your eyes?

Ryex

April 19, 2011, 03:52:34 am #4 Last Edit: April 19, 2011, 05:25:50 am by Ryex
not just make a flowchart version of what you have. your starting in the wrong place. the point is to write the modal without even touching code. Stop thinking about what needs to be edited in the RMXP scripts for it to work. Think about the system as if your making it from scratch.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

GrieverSoft

I think we might all be too newb to realize the difference.  Because when I try and imagine the smaller parts of the four basic functions, code comes to mind...
I like pie.  The pie is also evil.

Ryex

April 19, 2011, 05:03:39 am #6 Last Edit: April 19, 2011, 05:11:12 am by Ryex
Think of it as a large machine that dose the task. then think of all the smaller tasks that need to be done to accomplish that task. think not how the parts work, but what the parts are. Start with the top level and go as far as you can. if you can only get two or three levels down thats fine. post it and I'll point you in the right direction to go further. this IS the HARDEST part of learning how to script and not just edit.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Exactly. Learning how to structure things from scratch is a vital part in learning how to program.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

http://www.youtube.com/watch?v=s8HNrlvRCD8

I made a quick video to hopefuly help people understand what I'm talking about when I say "break it down". now it's 4 am I'm going to get what sleep I can now.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Jragyn

Though sloppy, I think I kinda get what you're saying.
I'll post up a model later today when I get to tearing apart the system for a second time.

Hopefully this will help me in my endeavors of learning C# as well >_<
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

AngryPacman

I'm gonna give this a shot by writing down what the system would need without touching acutal code. This is just a bunch of things that would have to be made with code, but I haven't written it in code. Am I doin' it right?
Spoiler: ShowHide
  • Write a method to record the amount of times a skill is used.

  • Write another method to define how the 1st method could be expressed through text.

  • Write a method to actually express the 1st method in text.

  • Write a method to upgrade skills when a defined amount of uses have happened.

  • Write a method to get rid of the old skill once it is upgraded.

Yes?
G_G's a silly boy.

Dweller

A first try of the second lesson assigment

Spoiler: ShowHide


(I uploaded a .png because I write it on paint.net. If it's not the right format I will change it).
Dwellercoc
Spoiler: ShowHide

brewmeister

perhaps a non-programming example would help...

Level 1: Brush Teeth

Level 2:
  Get Toothbrush
  Get Toothpaste
  Combine Toothbrush & Toothpaste
  Replace Toothpaste
  Use Toothbrush on Teeth
  Replace Toothbrush
  Rinse


Level 3:
  Combine T&T
    Store toothbrush in right hand
    Store toothpaste in left hand
    Remove cap from toothpaste
    Aim toothpaste at brush
    While toothbrush is not full of toothpaste*
      Squeeze
    Stop Squeezing


* it's sometimes ok to use 'programming' terminology/concepts/logic, but in a very generic sense.

It's sometimes hard to conceptualize a modification this way, since you have already decided the mode of implementation (the language), and you're looking at the current implementation rather than just it's 'requirements'.

Ryex

@AngryPacman Your making the same mistake that  jragyn00 was. you trying to conceptualize it using ruby. thats NOT the point. get as far a way from ruby as humanly possible when making this system modal. don't think with Ruby methods at all.

@Dweller you've got the right Idea but your starting about two levels down. use the the idea "upgrade skills with experience gained from use" as the top level and then split that into two or three larger tasks Like I did in the video. then you can divide those big general tasks up into the more specifies tasks you've put in your modal.

Brewmister has provided a good example of Idea with the task "Brush Teeth" thank you for that. you don't have to get nearly as specific in the process as hes did just yes. thats is going to be for lesson three.

If I were to redo his modal it would look something like this.

Level 1:
Brush Teeth
    Level 2:
    prepare toothbrush
        level 3:
        get toothbrush
        add toothpaste
    use brush on teeth
        level 3:
        place on teeth
        brushing motion
    finish
        level 3:
        rinse brush
        rinse mouth
        replace brush
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Sacred Nym

Spoiler: ShowHide
-Skill Experience System
   -Skill Families (eg. Fire, Fira, and Firaga)
      -Skill EXP Requirements
   -Skill Experience Tracking
      -EXP Gain/Loss values
      -Experience Gain
         -Did (actor) use (skill)
            -Gain Skill EXP after battle
            -Enough EXP for new skill?
            -Learn new skill, forget old
      -Experience Loss
         -Did (actor) NOT use (skill)
            -Count subsequent battles were (skill) is not used
            -Is there too much neglect?
            -Lose Skill EXP after battle
            -Forget neglected skill, relearn old


Something like this, right? (only read first post)
Quote昨日の自分に「さようなら」
Say "Goodbye" to who you were yesterday.

Ryex

Good job, you've got the idea Nym.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

cyclope

Spoiler: ShowHide

Skill Level System

  1. XP

      2. Gain XP

         3. Gain via script call
         3. Gain after used in battle

      2. Loose XP

         3. Loose via script call
         3. Loose after battle not used

      2. Grace period

        3. Dont loose XP during a time after learning a new skill

   1. Leveling

      2. Level when reaching a certain amount of XP
      2. Learn/Forget Skills

         3. When gaining XP amount for certain skill learn, and if nesesary forget old ones
         3. When loosing XP amount for certain skill learn, and if nesesary learn old ones

      2. Set level via script call

Things I Hate

1. People who point at their wrist asking for the time... I know where my watch is pal, where the hell is yours? Do I point at my crotch when I ask where the toilet is?

2. People who are willing to get off their a** to search the entire room for the TV remote because they refuse to walk to the TV and change the channel manually.

3. When people say "Oh you just want to have your cake and eat it too". Damn Right! What good is cake if you can't eat it?

4. When people say "it's always the last place you look". Of course it is. Why the hell would you keep looking after you've found it? Do people do this? Who and where are they?

5. When people say while watching a film, "did ya see that?" No Loser, I paid $12 to come to the cinema and stare at the damn floor!

6. People who ask "Can I ask you a question?"... Didn't give me a choice there, did ya sunshine?

Ryex

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

AngryPacman

Think I've gotted it now.
Spoiler: ShowHide
Level 1 >> XP SYSTEM
  Level 2 >> LEVEL EXP
    Level 3 >> GAIN FOR BEATING MONSTERS
    Level 3 >> GAIN FOR WINNING BATTLES
  Level 2 >> SKILL EXP
    Level 3 >> GAIN FOR USING SKILL
      Level 4 >> GAIN MORE FOR KILLING MONSTERS
      Level 4 >> GAIN LESS FOR HIGHER SKILLS
    Level 3 >> UPGRADE WHEN ENOUGH EXP
      Level 4 >> UPGRADE MORE WITH MORE EXP
      Level 4 >> MORE EXP REQUIRED FOR HIGHER LEVELS
      Level 4 >> FORGET OLD SKILL WHEN UPGRADE
    Level 3 >> REACH HIGHEST LEVEL
      Level 4 >> STOP EARNING SKILL EXP
    Level 3 >> CHANGE THROUGH SCRIPT CALL
      Level 4 >> GAIN THROUGH SCRIPT CALL
      Level 4 >> LOSE THROUGH SCRIPT CALL
      Level 4 >> CHANGE LEVEL THROUGH SCRIPT CALL
        Level 5 >> RAISE LEVEL THROUGH SCRIPT CALL
        Level 5 >> LOWER LEVEL THROUGH SCRIPT CALL
G_G's a silly boy.

Ryex

close

Your missing the skill branch of the system. it needs some way to define skill learning ect.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />