11-04-2011, 02:09 PM | #11 |
Join Date: Jul 2007
Location: Ann Arbor, MI
|
Re: GURPS RCC (Ranged Combat Calculator)
Right, and we aren't expecting you to be a genius over night. Just trying to help you down the right path early on. It's good that you've started something that lets you get results early. It took me a long time and a lot of independent struggle to learn how to organize my software and my data in a way that made sustainable development possible.
__________________
Online Campaign Planning |
11-04-2011, 03:17 PM | #12 | |
GURPS FAQ Keeper
Join Date: Mar 2006
Location: Kyïv, Ukraine
|
Re: GURPS RCC (Ranged Combat Calculator)
Quote:
(2) Are VB and VB.NET the same thing? After being explained that Java and Javascript, C, C++ and C# are rather different, I no longer take it for granted. |
|
11-04-2011, 03:57 PM | #13 |
Night Watchman
Join Date: Oct 2010
Location: Cambridge, UK
|
Re: GURPS RCC (Ranged Combat Calculator)
|
11-04-2011, 05:18 PM | #14 |
Join Date: Jul 2007
Location: Ann Arbor, MI
|
Re: GURPS RCC (Ranged Combat Calculator)
He's using VB.NET. VB.NET and C# aren't the same language, but they compile down to the same p-code that runs on the same virtual machine. Any language that can compile down to the .NET runtime can write an assembly that is compatible with any other .NET language.
That's actually nothing new though. Shared libraries (DLLs on windows) offer the same types of services, provided they are properly constructed. Microsoft set out a standard for doing it (stdcall calling convention), and every major windows development tool can either create those DLLs or consume them.
__________________
Online Campaign Planning |
11-04-2011, 11:13 PM | #15 |
Join Date: Jun 2011
Location: Richmond, VA
|
Re: GURPS RCC (Ranged Combat Calculator)
Ok everyone, I am using Visual Basic 2010 express to build this app and others that I am working on.
And like Clay said I am no genius...however I am highly trainable. Concepts like assemblies, classes, and modules are still a bit tough for me. In fact I am wrestling with this problem here. I want the user to be able to enter into a textbox "3d+1" for lets say damage then hit a button to roll the damage with the results displayed in another text box. I'd like to be able to do that without a massive case select sub. I think what I need to do is somehow take the entry, have it read by a subroutine wich would interpret 3d+1 as produce a random number 1-6 three times total the sum of those numbers and add 1. Input and or sample VB code is greatly appreciated |
11-05-2011, 02:45 AM | #16 |
Join Date: Jun 2011
Location: Richmond, VA
|
Re: GURPS RCC (Ranged Combat Calculator)
Still hammering away at this problem. I need to figure out how to parse a text entry like 3d+1 so that I may be able to incorporate weapon damage into then new version of the RCC.
Once I have an understanding of that then I shall rule the universe |
11-05-2011, 02:56 AM | #17 | |
GURPS FAQ Keeper
Join Date: Mar 2006
Location: Kyïv, Ukraine
|
Re: GURPS RCC (Ranged Combat Calculator)
Quote:
http://msdn.microsoft.com/en-us/library/kwb0bwyd.aspx then http://msdn.microsoft.com/en-us/library/aka44szs.aspx and finally http://msdn.microsoft.com/en-us/libr...t.toint32.aspx to convert to an integer. |
|
11-05-2011, 03:54 AM | #18 | |
Join Date: Jul 2007
Location: Ann Arbor, MI
|
Re: GURPS RCC (Ranged Combat Calculator)
Quote:
He has another, more famous book, The C++ Programming Language, that you'll find in any book store with a programming section. It's expensive and easily worth the money. While you've started in a different language, learning basic principles early makes you life easier later. You can download Visual C++ Express and get the same excellent programming tools, with a compiler for a different language. There are also some other good tools, such as Code::Blocks with mingw (a free C++ compiler suite), and if you're willing to undergo a bit of hoop jumping eclipse with the C++ tools can be very nice. More generally to solve your die rolling problem, you need to write a parser that understands die expressions. GURPS has very simple die expressions, so this shouldn't be too hard. There are two parts to the expression, a mandatory die part, which is terminated by a 'd', and an optional modifier, indicated by a '+' or '-' following the 'd'. These should be considered operators. You can write a function that handles each operator. Each operator handling function might look like this: function op_d(int val, int sum) returns int begin int i int accumulator for i = 1 to val accumulator = accumulator + (rand() mod 6) next i return accumulator + sum end function op_minus(int val, int sum) returns int begin return sum - val end function op_plus(int val, int sum) returns int begin return sum + val end That's a pseudo-code, not something that will run. I haven't written any basic in over a decade, and I'm more than a little rusty. And to be fair, when I was writing more basic code, we had to use line numbers (yes, I'm that old). You also need to break your string into tokens. A token is a symbol that you either store as a value or treat as an operator. In your example, these would be the tokens: '3', 'd', '+', '1' The general method for separating tokens is to search through a string for operators. Each operator is a token and anything between the operators is a value. Whitespace is discarded. Non-operators at the start and end of the string are considered values. All of your operators are pretty simple, so you can write a pretty simple parser. If you have a value variable and an operator variable, you loop through the list of tokens until you have both a value and an operator. When both are populated, you call the appropriate operator function with the value and your accumulated sum. Upon return you clear the operator and value, then continue going through the loop. That is a little more complex that you strictly need to parse a GURPS die expression, but it's a good basis for a more extensible dice expression parser. It would be quite easy to expand that to use a roll and keep expression, or the more complex polyhedral expressions that Cortex system games use (d6 + d4 + chicken_entrails)
__________________
Online Campaign Planning |
|
11-05-2011, 04:13 AM | #19 |
Join Date: Jun 2011
Location: Richmond, VA
|
Re: GURPS RCC (Ranged Combat Calculator)
That explains the concept of what I need to do. Which is what I figured. my problem right now is not having the knowledge to put it into code. However I am working on it.
I am having trouble parsing the string into parts to put into formula for calculation. |
11-05-2011, 04:18 AM | #20 |
Join Date: Jun 2011
Location: Richmond, VA
|
Re: GURPS RCC (Ranged Combat Calculator)
Bottomline is I don't kow how to write a parser in VB yet.
|
Tags |
gurps 4e, ranged, ranged combat |
|
|