Wyrmkeep Entertainment Board
November 23, 2017, 06:01:29 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Patreon for Inherit the Earth:Sand and Shadows launched!
 
Our sites: Wyrmkeep Entertainment Home   Inherit the Earth Comic   Mole's Quest   The Labyrinth of Time
   Home   Help Search Members Login Register  
Pages: [1] 2 3 ... 5
  Print  
Author Topic: Game Concept: Technical  (Read 91654 times)
Kay
Full Member
***
Offline Offline

Posts: 67



View Profile
« on: September 02, 2004, 06:38:43 PM »

Re: a dialogue/scripting system: I suggest looking at Morrowind's editor. From that and from my own work, what's needed are data structures that look like this:

class Line: ## A line of dialogue
    text="What gets said, with code insertions like 'I have {value:self,HP} hit points.'"
    requirement_1_variable = None ## A variable that gets checked to determine whether this line can be used.
    requirement_1_value = None ## What must its value be?
    requirement_2_variable = None ## etc.
    requirement_2_value = None ## etc.
    code_to_execute = None ## Special code that gets executed if this line is chosen, eg. "Give Player 100 coins" or "Run script #42."

class Topic: ## A dialogue topic the player can ask about
    lines = [] ## Attach Lines to this.
    name = "The name of this topic."
    special = None ## Requirement for being able to ask about this?


Then when the player wants to ask about a topic, you use a function that basically says,

For each Line in Topic (starting with the first):
    check each requirement for this Line.
    if all requirements met:
        select this line and display; run its code. Quit.
    else:
        do nothing
If we get here, no line was selected.
Display default line.


That gives you the equivalent of Morrowind's dialogue system. Coding individual topics and lines by hand is a royal pain, so an editor program is necessary. If you want a more advanced dialogue system, you start getting into neural networks... possible, but tricky. I would assume Morrowind-like AI first.

Re: AI, we'd need to decide what the NPCs are capable of. Random walking within a restricted area, the above dialogue system, and basic "attitude" towards the player (based on group membership, species, etc.) are all fairly easy to program. Would they need to do more? For party members or potential friends of the hero, I'd want more AI, but we could get away with the dialogue system plus Final Fantasy-style scripted conversations to bring them to life.

Re: Graphics Engine, this is the hard part. Displaying square graphic tiles is fairly easy. Adding multiple graphics layers (for transparency, clouds, etc.) isn't terrible. Scrolling smoothly and animating sprites is tough. Using isometric (diagonal) tiles adds another level of complexity, since you're basically drawing rectangular graphics but only displaying a diamond-shaped chunk of them, and deciding how multiple faces of a 3D block should be painted. Especially if you can rotate.

Re: Developer Tools, what's needed are:
-World Editor (draws the areas where the player can walk around; places scripted events, items, etc.)
-Tile Editor/Converter: Creates graphics or (if necessary) converts them to the right format
-Dialogue Editor: Creates conversation topics and lines.
-Script Editor: Creates planned events.
-Game Engine, Debugger Version: Lets the player walk around in the game world as if playing the game, with the ability to cheat, turn code features on/off, etc.

Other things:
-Is it possible that Bethesda/ZeniMax (Morrowind's creators) have patented some part of their AI, ie. the concept of a topic-based conversation system?
-I will mention this discussion on TSA-Talk, a relevant mailing list.
Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #1 on: September 03, 2004, 12:26:59 PM »

Quote
Re: Graphics Engine, this is the hard part. Displaying square graphic tiles is fairly easy. Adding multiple graphics layers (for transparency, clouds, etc.) isn't terrible. Scrolling smoothly and animating sprites is tough. Using isometric (diagonal) tiles adds another level of complexity, since you're basically drawing rectangular graphics but only displaying a diamond-shaped chunk of them, and deciding how multiple faces of a 3D block should be painted. Especially if you can rotate.

For this, I beg to differ - using a 3d Scene Graph almost immediately eliminates all of these problems. Its entirely possibly to make a 2d game using a 3d engine, and is often desirable, since you can use many neat 3d special effects on the 2-d elements that you get "for free" when you would normally have to code these by hand... Gish - http://www.chroniclogic.com/gish/ - is a perfect example of this. You wouldn't know it was a 3d game unless you were fishing around in the advanced settings. They get advanced per-pixel lighting, beautiful special effects, the whole she-bang, for free.
The effect is stunning; a beautiful mix of 2d elements and wonderful "3d"-esque effects. Also, the lper-pixel ighting effect is really neat for night-time scenes. Wink

This is not to say it would be a cakewalk, but using a 3d Scene Graph eliminates most of the mundane work and lets you work with the actual logic of the implementation.

Quote
Re: AI, we'd need to decide what the NPCs are capable of. Random walking within a restricted area, the above dialogue system, and basic "attitude" towards the player (based on group membership, species, etc.) are all fairly easy to program. Would they need to do more?

What kind of world would you want them to be in? The type of gameplay dictates what the player would expect from the AI - a hack 'n' slash would not have the AI depth of a dynamic RPG, for instance.

Morrowind-style AI is ridiculiously easy to copy, though, given that they only do a few things, if any at all (have you ever asked Ahansi the thief about "her profession?" Her tone of voice changes completely and assumes the pre-defined gender-neutral tone that the scripters wrote up for all thief classes, ackward at the very least).

On a completely unrelated note:
I love Ultima 7's model of AI. You could literally stand still in one place and watch the AI wander around by itself. Guards patrolled the streets. At dawn, shopkeepers would wake up, leave, and LOCK THE DOORS behind them - it is truly a great experience, sneaking into someone's house at night through the window, waiting until morning (when they lock-up and leave) then ransacking them blind, opening the door and hauling ass when you're done. Wink Its a pretty simple model of AI, but compared to Morrowind's... I'm really not sure why Morrowind's AI wasn't more indepth: they had an attitude towards the player (good or bad), and walked random patterns at all times of the day and night. The only "special" actions were scripted ones, which I thought was kind of odd, but whatever.

Quote
-Is it possible that Bethesda/ZeniMax (Morrowind's creators) have patented some part of their AI, ie. the concept of a topic-based conversation system?

If you write over a 1,000 lines of code for anything its been estimated that there is at least an 80% chance you're breaking someone's patent - sometimes its just best not to think about it.

Of course, if that's true, then I must be some kind of legendary underground hacker-hero of the wild west. ^.^

More realistically, a patent for conversation-driven AI c(SH)ould never be granted to Bethesda Softworks - if anyone has the patent, its gotta be Origin, as the first few Ultima games contained all of the stuff Morrowind's conversation scripting does.
Logged
Kay
Full Member
***
Offline Offline

Posts: 67



View Profile
« Reply #2 on: September 10, 2004, 06:48:07 PM »

Quote
This is not to say it would be a cakewalk, but using a 3d Scene Graph eliminates most of the mundane work and lets you work with the actual logic of the implementation.

So where would we get a graphics/animation coder?

Quote
What kind of world would you want them to be in? The type of gameplay dictates what the player would expect from the AI - a hack 'n' slash would not have the AI depth of a dynamic RPG, for instance.

My "favorite" Morrowind moment: being chased by a dozen or so wolves, bears, berzerkers, and ice witches, all of whom attack on sight, fight to the death, always follow my path even if I'm running in circles; none of whom cooperate or get demoralized by seeing me slaughter their friends with a sword crackling with icy doom.

The moral: make the battle system stylized, more like Final Fantasy's, and have the AI focus on when to fight and when to surrender.

Re: dialogue, the problem of characters switching speech styles is partially treatable. Create a "Speech Filter" so that before a character speaks, all instances of words in [list 1] are replaced by the same entries in [list 2]. For instance:

Bostonian: "r" --> "ah", "R" --> "Ah"
Result: "Park your car at Harvard" --> "Paahk youah caah at Haahvaahd."

Kid: "want to" --> "wanna", "going to" --> "gonna", "got to" --> "gotta"
Result: "I want to fly high; I've got to fly higher" --> "I wanna fly high; I've gotta fly higher."

Then tag each NPC as to what filters they use. These have flaws, eg.:
Filter: "very" --> "really"
Result: "Every" --> "ereally"

...but they can help keep characters from switching accents suddenly. For cat-people you can just change "r" to "rr"; for a Japanese person you could do a few substitutions like "hai" for "yes" just to add flavor.

Re: AI, like I said, I would put Morrowind-level AI on the "must have" list, with a few characters (like potential friends) having better AI, and put advanced stuff on the "do once there's a working demo" list. The "shopkeeper schedules" thing you mentioned exists for Morrowind, but I lack the "Tribunal" expansion it requires.

If I had a good basic graphics engine in a language I knew (like Python), I could show off decent AI. I could also, with a little work, show off what I mean in Python based on what I've already done, but the graphics "engine" there is unusuable for a real game.

Where could we find people willing to experiment with these ideas?
Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #3 on: September 12, 2004, 08:25:58 AM »

Quote
So where would we get a graphics/animation coder?

Why reinvent the wheel? There are tons of open source 3d scenegraphs that do the job admirably; there's probably at least one very advanced engine for each major language. Its just a matter of implementation after that.

Quote
My "favorite" Morrowind moment: being chased by a dozen or so wolves, bears, berzerkers, and ice witches, all of whom attack on sight, fight to the death, always follow my path even if I'm running in circles; none of whom cooperate or get demoralized by seeing me slaughter their friends with a sword crackling with icy doom.

The wolves should be killing the bears, the bears should be killing the wolves, the ice witch should be casting buff spells on the berzerkers, and the berzerkers should be killing everyone - including the witch!

Quote
The moral: make the battle system stylized, more like Final Fantasy's, and have the AI focus on when to fight and when to surrender.

Turn-based, real-time, quasi-real-time (those whacky power-up bars!)?

Quote
I could also, with a little work, show off what I mean in Python based on what I've already done, but the graphics "engine" there is unusuable for a real game.


Also, google for "Python Scene Graph" and you'll find a ton of 3d engines to use. Its pretty easy to use them 2d styles: programmatically draw a polygon for each sprite, then use the bitmap image as a texture on the polygon.... bam. Instant 2d love-making, you know? You'd move them around on the same Z-axis and it'd be just like a 2d engine.

Quote
Where could we find people willing to experiment with these ideas?


! You seem pretty willing to experiment on the issue yourself.

There's a difference between experiencing and trying to deliever a polished product, though - they take two seperate, distinct development arcs, and very little intersects. What you use in one you  probably won't be able to use in another. So you'll have to decide no what direction you want to go with this kind of prospect.

Don't look at me unless you fancy getting comfortable with the .NET library and a Python-clone for the platform like Boo or IronPython: I've sworn off all other development platforms but Java and .NET - I gain way too much and I slow too far down when I start using low-level langauges. I used to be technologically agonistic... but ****** that. I get too much stuff using .NET or Java.
Logged
Kay
Full Member
***
Offline Offline

Posts: 67



View Profile
« Reply #4 on: September 12, 2004, 07:30:53 PM »

How does one get Java and .NET? I've worked with JavaScript a bit; is there a free (and usable, and legal) version of these available?

The biggest problem I encountered while fooling with AI (I haven't touched it in a while) is the "world," which isn't even part of the AI itself. It's the virtual environment containing rooms, items, and things that an AI can sense. The "world" is a pain because it takes up more than its share of programming time and limits what an AI can do. Right now I got away from my ugly-graphics version by switching to a MUCK-like text interface, but that means it's not possible to move around within a "room." It's like something Douglas Adams said about the Hitchhikers' Guide Mk. II: ideally an AI would have no filters limiting how it can perceive the world.

Bleh, but most of what the new version does is move around and look at new objects. All the graphical version did was move, find food, converse Morrowind-style, and learn a bit.

What kind of actions would you expect from a major character -- with a good AI -- in an ItE sequel sort of game? What could it do to make you like it, and make you think of it as more than a scripted character?

Come to think of it, I wonder whether VERGE would be usable for a project like this. It's C-based, contains basic graphics functions and a scrolling tiled graphics engine (2d), and is ugly.
Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #5 on: September 13, 2004, 08:01:16 AM »

Quote
How does one get Java and .NET? I've worked with JavaScript a bit; is there a free (and usable, and legal) version of these available?

Both are free and crossplatform.

Java
Java SDK - Java JDK 1.5 - http://java.sun.com/j2se/1.5.0/download.jsp A release canditate for version 1.5, the final version due out at the end of this month. Contains too many improvements over Java Development Kit (JDK) 1.4.2 to even bother with 1.4.x now. Smiley

Best free Java IDE available: Eclipse. www.eclipse.org

.NET

You can go here: http://lab.msdn.microsoft.com/express/ to grab the .NET SDK and a free IDE for the language of your choice. If you're interested in notepad-style development, you can search around www.msdn.com for the .NET 2.0 SDK, download, and install...

...both are free.

Quote
The biggest problem I encountered while fooling with AI (I haven't touched it in a while) is the "world," which isn't even part of the AI itself. It's the virtual environment containing rooms, items, and things that an AI can sense. The "world" is a pain because it takes up more than its share of programming time and limits what an AI can do.

It could act more like an "agent." To get around AI interaction with the world, things would have to be described in units that the AI could understand. It must be able to look at a "node" (let's say a sword in this case), know that this node is used for "damage," know that this node can be "wielded," know that this node can be "stored," know that this node could... etc, for every action. The agent, then, stumbling across this node, will decide (using weighted values) wheither the weapon is better than anything it has, wheither it can carry this weapon around, and if it can carry this weapon around, does it have enough weapons that it should discard the lowest power weapon?

You could apply similar logic to interaction with other world components - agent wants to go to point C from point A, but at point B there is a locked door. The agent cannot pathfind its way to point C from point A. However, upon inspecting the node at point B, it passes it through a function that determines a few essential values: is there something it wants behind the door, will opening the door allow it to continue with its path finding, can it open the door...?

To keep the code simple, you can break node logic up into an abstract basis of "verbs" and "nouns" and shit, so you won't have to keep programming new logic for each kind of node you add to the game. All nodes would pass through the same function, and the appropraite action would be called at the very end (agent might decide to invoke the "wield" verb, the game takes it from there).

This requires weighted values and for verbs to be defined - the Agent must know what the "wield" weights its "attack" or "defense" values much heavier than the "eat" verb, which weights its "health" value down to, like, 0. Or maybe -1 (application crash!). The better part of this is that agents that do not have a particular definition for how a "wield" verb will affect them would probably ignore the item and keep moving; great for feral agents.

There need to be a handful of basic hardcoded values, though, such as traversing distances would be done the same in all agent models, for instance.

Quote
What kind of actions would you expect from a major character -- with a good AI -- in an ItE sequel sort of game?

I'd expect it to have its own "agenda" - something it wants to accomplish, something that makes it real and different from the unwashed masses that simply wander around mindlessly all through the day and night. If it knows that I've found out about its treacherous plans, I want it to try and hide somewhere - not just stand in the middle of the town square and wait until I initiate conversation. I want it to flag me down if it has something important to say... or just follow me around creepily. >Smiley

I want it to do things without waiting for me to walk up and mash the 'A' button on the controller.
Logged
Kay
Full Member
***
Offline Offline

Posts: 67



View Profile
« Reply #6 on: September 22, 2004, 11:50:44 AM »

.NET doesn't look like what I had in mind at all; it seems to be more for making online databases and E-commerce sites. Will investigate Java next. What I'd like is to build a program with a clean Windows interface and Net access. As it is, I either have to build my own window-and-button system or learn Java!
Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #7 on: September 23, 2004, 09:46:00 AM »

Quote
.NET doesn't look like what I had in mind at all; it seems to be more for making online databases and E-commerce sites. Will investigate Java next. What I'd like is to build a program with a clean Windows interface and Net access. As it is, I either have to build my own window-and-button system or learn Java!
Not really.

People are making Realtime 3d engines and high quality commercial games with it. Grab the demo of Arena Wars, by the way, if you dig strategy games - its one of the craziest RTS' I've ever played. Capture the flag... with tanks. Man, Germans are ******ing insane.

The .NET framework is the next generation in windows development, after all, so it encompasses everything from client-side programming to server side programming.

Is this simple enough for you?

Code:
using System; //base libraries.
using System.Windows.Forms; //Windowing library.

namespace MySampleProject
{

class MyWindow : System.Windows.Forms.Form //Inherit a generic Windows, uh, window.
{

  public MyWindow() //Constructor; called when class is created.
  {
   Button MyButton = new Button(); //Create new button.
   this.Controls.Add(MyButton); //Add new button to this form.
   /* Anything else.
    ....
   */
  }
}
}

Launching:

Code:
using System;
using System.Windows.Forms;

namespace MySampleProject
{
class Launcher
{
  public static void main(string[] args)
  {
   Application.Run(new MyWindow());
  }
}
}

Those are two seperate flies, by the way, for consistency's sake.
Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #8 on: September 23, 2004, 09:49:36 AM »

Oh. Uh, not to sound like a cheap shill for .NET, though - the only reason I know so much is because of a hobby project (a game) I'm working on every once in awhile.

Edit: Freaking forum broke my bracket spacing. Bah.
« Last Edit: September 23, 2004, 09:59:10 AM by Threed » Logged
Kay
Full Member
***
Offline Offline

Posts: 67



View Profile
« Reply #9 on: September 24, 2004, 09:35:16 PM »

I'm installing the Visual C# IDE for .NET now. It looked like the best option of the ones MS offered, and possibly easier to use than IronPython. Why can't I get anyone to give me a legal, high-powered, easy-to-use development tool for free? =) Python is powerful and not too hard to use, but you really have to build a lot of stuff from scratch even using Pygame.

I'm concerned about MS's license agreement though -- automatic expiration in 2005 March? "Recipient may not... distribute" anything "created using the Software"?

Will edit this after I give Visual C# a try...

OK. I'm now fooling with basic applications, closer to "Hello World" than AI or ItE. Will keep at it.
« Last Edit: September 25, 2004, 04:55:43 PM by Kay » Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #10 on: September 25, 2004, 09:11:09 AM »

What you are downloading is Visual Studio 2005, C# Express Beta 1, an Integrated Development Enviroment for the .NET Framework.

Beta 1, AKA, "We're not sure its ready for production use yet, so until we say you're not allowed to distribute stuff you make with it, don't, O-K?"

Beta 1 is time-bombed to explode a year after its release, but Beta 2 should come long before that... and, with Beta 2, you'll be able to freely distribute applications created with it.

The "do not distribute thing" is mostly hope on Microsoft's part, though, since there's really no way to tell if you wrote the program using the command line or you wrote it using another IDE like SharpDevelop.

Microsoft has gotten into the habit of public betas before polished final releases.

It usually goes, 'Beta 1, Beta 2, RC1, RC2, Final Software Release.'

Quote
Why can't I get anyone to give me a legal, high-powered, easy-to-use development tool for free? =)

~.~ hehe. Yeah.

The development framework - ".NET Framework SDK" - and the runtime are available for free, to everyone. What you're downloading is an IDE - an advanced editor that invokes the SDK whenever it wants to create a new application. You could just as easily use Notepad to develop .NET/C# applications, but that's not as much fun as looking at the IDE's pretty graphics.

The IDE could die on you a month from now - radioactive cancer or something - and you could keep programming using another .NET IDE or just NotePad or jEdit.
« Last Edit: September 25, 2004, 09:11:36 AM by Threed » Logged
Kay
Full Member
***
Offline Offline

Posts: 67



View Profile
« Reply #11 on: October 04, 2004, 08:53:57 PM »

Thought I'd give a progress report. I was hoping to create a simple C#/.NET demo of the dialogue system by now, but with other things going on (fiction writing and law school!) I've been busy. So far, C# is great for creating buttons and Windows controls, but a pain for even an experienced amateur trying to figure out how to make basic things like arrays and objects work. Can't do anything without making the line/topic structures compile and managing to access and manipulate instances of them.

This has screenshots of past versions.

I was thinking that instead of the ugly graphics I was doing, and instead of the MUCK-like text interface, it'd be nice to make a Windows tree-view of game locations (like City A\Wharf District\Alley) and organize the AI along those lines without worrying about the exact placement of obstacles within a location. That would make pathfinding simpler, and if it were ever built into a real game, AI for walking around a room could be handled separately from AI for deciding what city to go to. (This is based on Threed's "agent" comment, but without the assumption that any AI picking up a sword automatically knows how it's used.)

Will keep at it.
Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #12 on: October 05, 2004, 11:40:39 AM »

Quote
I was thinking that instead of the ugly graphics I was doing, and instead of the MUCK-like text interface, it'd be nice to make a Windows tree-view of game locations (like City A\Wharf District\Alley) and organize the AI along those lines without worrying about the exact placement of obstacles within a location. That would make pathfinding simpler, and if it were ever built into a real game, AI for walking around a room could be handled separately from AI for deciding what city to go to. (This is based on Threed's "agent" comment, but without the assumption that any AI picking up a sword automatically knows how it's used.)

Will keep at it.

What happens, using this model of pathfinding, when there is a location that is in the "root" node (A City), but can only be accessed by two distinctly seperate children nodes that aren't in the same tree?

AKA,

"Gulliver" can only be accessed via "A City\TownPlaza\BackAlley" and "A City\Hidden Attic\Roof\FireEscape\Backalley"? It should not be able to pathfind its way to Back Alley by going directly through "A City."

For a MUCK-like style, have you considered a matrix layout? A 3 dimensional L x W x H layout of the city (!) where the blocks are interconnected and thus that determines where the AI can and can't GO?

[3, 2, 1] might not be linked to [3, 2, 2], and so to go upstairs, the AI might have to go to [3, 3, 1] ... etc, etc, etc.

This can be a 2d matrix, I'll admit, but then the layout's going to look pretty funny from a visual perspective and you'll have to do weird things to link one node in the matrix to another.

And of course, each matrix node can hold information about the room (other nodes inside of it that might be of interest ... ..)!


Quote
This is based on Threed's "agent" comment, but without the assumption that any AI picking up a sword automatically knows how it's used.

I think - as a matter of preference, of course - that all Agents should explicity know what actions are available for any given object they encounter, then make a reference check against a matrix of information about that object, AKA, 'What do I know about the functions of this object?' and 'I tried to use this particular node's function before and I failed miserably - should I try again?' The crux of the issue, in my eyes, is that most functions will be used regardless - a pipe wrench is used for unclogging drains, which an AI might not have discovered, but it does know that a pipe wrench is a very blunt object and that there is a six foot ogre coming at it, and so, off it goes - pipe wrench meets ogre's forehead with a responding thud!

That implies that there are basic things an AI already knows, though: how to defend itself, how to forage, how to...




(Something something something, arrays, something, objects, something)
Incoming code block! Its C#, but I'm sure you can figure out how to translate it to Python easily - its very legiable:

First: topic node structure thing. Wink
Code:
struct Topic
{
public string Subject;
/The following are two arrays: one contains possible questions, and another contains possible answers.
The first array is one dimensional; that is, there is only one style of question to ask.
The other arary is two dimensional; that is, for each kind of response, there are really several different kinds of responses!
Thus,  Questions[0] (first element in the Questions array) corresponds to Answers[0][N] the first element in the answers array, with N being one of the 2nd dimension elements - typically, "depth."
 */
public string[] Questions; //Things user can ask.
public string[][] Answers; //Two dimensoinal array.

}

Second: random code snippet, initalizing the array and them picking a random response:
Code:

Topic topic; //new topic.
//Initalize new questions array with preformatted responses - in a real scenario, this should be done dynamically, and frankly, using an ArrayList, or else you'll have to be dynamically resizing Questions[] until the cows come home.
topic.Questions = { "What is your name?", "Why should I make sweet love to you?", "Yo!" };
//Initalize Answers - see above comment.
topic.Answers = { { "My name is Sir Frederick the Great", "My name is... your daddy, that's what!" }, { "Because I am hung like a horse - literally", "Because... uh... shoot. I love the color of your eyes, you know?", "What?! WHAT!! YOU PERVERT! GET OUT! GET OUT!" }, { "Sup?", "Diggity!", "Er, goddamn thug wannabes..." } };

//Code that reads user response here and stores it in an integer named bob, bob being the, uh, integer that determines what the query was.
//In a real scenario, you'd iterate through a list of keywords and try to make a 75% match between what the user asked and what the AI knows.
//But this isn't real, is it?

int bob = 1; //He's trying to make love to me!
Random rand = new Random(); //A new random number generator.
Answers[Question Asked][Responses available]
Console.WriteLine(topic.Answers[bob][rand.Next(0, 2)]);

Its really quite trivial to manipulate arrays in a basic way - they're the equivilent of  a mathematical matrix, except that they can be strings, characters, integers, or custom datatypes (you can make an array of Topics[] if you wanted!).

I'm pretty sure Python has the concept of arrays - they're very powerful constructs for some things, and I don't think that Guido von Russam would've left'em outta the langauge for too long.
Logged
Kay
Full Member
***
Offline Offline

Posts: 67



View Profile
« Reply #13 on: October 06, 2004, 10:05:25 PM »

For the sake of my blood pressure, I'll bug you about code again. I've got the basic dialogue system working in Python already, but I can't translate it into C#. For instance:

Code:
  class DlgLine
    {
        public string text;
        public LineReq req1;

        public DlgLine()
        {
            this.text = "Test text";
            this.req1 = new LineReq();
        }
    }
...defines a simple version of the dialogue line, where a LineReq is another class. Then:
Code:
          ArrayList squirrel = new ArrayList();
            squirrel.Add("A");
            squirrel.Add("B");
            squirrel.Add("C");
            return squirrel[0].ToString();
...returns "A", with no problem. But:

Code:
          ArrayList squirrel2 = new ArrayList();
            squirrel2.Add(new DlgLine());
            squirrel2.Add(new DlgLine());
            return squirrel2[0].text;
...gives an error: 'object' does not contain a definition for 'text'. Changing that last line to "return squirrel2[0].GetType().ToString();" returns "DialogueDemo.DlgLine", so the program acknowledges that entry 0 of squirrel2 is a dialogue line, but vigorously denies that it has a property called 'text'. (I also note that the 'Item' property of ArrayList, while mentioned in the docs, doesn't seem to exist.) What's going on?!

The topic structure DlgTopic has a variable called "lines" which is an ArrayList into which I put DlgLines. I make an instance of DlgTopic called "topic". All I'm trying to do is call "topic.DisplayLine(0);" for an existing instance of the topic structure and have that function return this.lines[0].text; I haven't even gotten to line-selecting code here.

And if I distribute a working demo, do I distribute the 'solution' file that the IDE builds? I see no information here on making an actual EXE.

Thanks a lot for any help here.
Logged
Threed
Jr. Member
**
Offline Offline

Posts: 42



View Profile
« Reply #14 on: October 07, 2004, 08:23:42 AM »

Alright, if you're using .NET 2.0, there are two types of lists:

ArrayList returns an object that must be cast to the proper format - it is slow, but not terribly slow, and mostly used for heterogenuous arrays, where you might have a string, then an integer, than an... you get the jist.

The other list, List<>, is in System.Collections.Generic; it works just like the ArrayList, except that it is a homogenuous data-type - there can be only one!

Using a List<> works like this:

List<int> bill = new List<int>(); //This list only holds integers, and there's no reason to cast them to integers, because they are!
int ted = bill[index];

You'd use, List<DialogType> dialog = new List<DialogType>();
and then, DialogType diggy = List<DialogType>[Index[;

If you want to keep using ArrayLists, you'd use this:

ArrayList ted = new ArrayList(); //HOmogenous array - add whatever.

And then, to retrieve,

return (ted[INDEXOFMYLEWT] as string).text;

Or,

string text = (ted[INDEXOFMYLEWT] as string);

Or,

string text = (string)ted[INDEXOFMYLEWT];

Yo.

On the Item property

The 'Item' property means that you can access a data structure like you would an array.

Its the []s in ArrayList[INDEX];

It means that you can grab a particular ITEM from the array doing this: [].
ArrayList[INDEX] returns an ITEM, usually an object that needs to be cast to the proper datatype (int, string, MyFavoriteDataType), etc.

On distribution

Nope, compile the application, and surf to ProjectDirectory/bin/(Release or Debug, depends on how youbuilt the application)/ProjectName.exe

Distribute, but know that, like Python, peeps will need the runtime installed.

Most peeps already have the runtime (thanks microsoft!), but inevitably, there will be someone who does not. They can go here:

http://www.microsoft.com/downloads/details...&displaylang=en

Its all point 'n' click, just like everything else microsoft.
Errata

You can AIM NuklearToast if you need more help in a hurry and I'm online. Wink
Logged
Pages: [1] 2 3 ... 5
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!