Steve Jackson Games - Site Navigation
Home General Info Follow Us Search Illuminator Store Forums What's New Other Games Ogre GURPS Munchkin Our Games: Home

Go Back   Steve Jackson Games Forums > Roleplaying > GURPS

Reply
 
Thread Tools Display Modes
Old 11-04-2011, 02:09 PM   #11
ClayDowling
 
ClayDowling's Avatar
 
Join Date: Jul 2007
Location: Ann Arbor, MI
Default Re: GURPS RCC (Ranged Combat Calculator)

Quote:
Originally Posted by ssveter View Post
I am just learning VB. To say the least my skills are limited. What you see in the RCC is only what I have learned to do in about three weeks of self taught tinkering.
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
ClayDowling is offline   Reply With Quote
Old 11-04-2011, 03:17 PM   #12
vicky_molokh
GURPS FAQ Keeper
 
vicky_molokh's Avatar
 
Join Date: Mar 2006
Location: Kyïv, Ukraine
Default Re: GURPS RCC (Ranged Combat Calculator)

Quote:
Originally Posted by ClayDowling View Post
C# and VB.NET runtimes are compatible. If you just make your core features available as assemblies, you won't have any problem.
(1) I didn't know that.
(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.
__________________
Vicky 'Molokh', GURPS FAQ and uFAQ Keeper
vicky_molokh is offline   Reply With Quote
Old 11-04-2011, 03:57 PM   #13
johndallman
Night Watchman
 
Join Date: Oct 2010
Location: Cambridge, UK
Default Re: GURPS RCC (Ranged Combat Calculator)

Quote:
Originally Posted by vicky_molokh View Post
(2) Are VB and VB.NET the same thing?
No... traditional VB (as used for GCA) is significantly different to VB.NET, but since the last release of trad VB was in 1998, some people people who've taken up BASIC recently are likely using VB.NET and calling it VB.
johndallman is offline   Reply With Quote
Old 11-04-2011, 05:18 PM   #14
ClayDowling
 
ClayDowling's Avatar
 
Join Date: Jul 2007
Location: Ann Arbor, MI
Default 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
ClayDowling is offline   Reply With Quote
Old 11-04-2011, 11:13 PM   #15
ssveter
 
ssveter's Avatar
 
Join Date: Jun 2011
Location: Richmond, VA
Default 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
ssveter is offline   Reply With Quote
Old 11-05-2011, 02:45 AM   #16
ssveter
 
ssveter's Avatar
 
Join Date: Jun 2011
Location: Richmond, VA
Default 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
ssveter is offline   Reply With Quote
Old 11-05-2011, 02:56 AM   #17
vicky_molokh
GURPS FAQ Keeper
 
vicky_molokh's Avatar
 
Join Date: Mar 2006
Location: Kyïv, Ukraine
Default Re: GURPS RCC (Ranged Combat Calculator)

Quote:
Originally Posted by ssveter View Post
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
In C#, there's a bunch of string operators that can do exactly that. Surely there are some equivalents in VB.NET.

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.
__________________
Vicky 'Molokh', GURPS FAQ and uFAQ Keeper
vicky_molokh is offline   Reply With Quote
Old 11-05-2011, 03:54 AM   #18
ClayDowling
 
ClayDowling's Avatar
 
Join Date: Jul 2007
Location: Ann Arbor, MI
Default Re: GURPS RCC (Ranged Combat Calculator)

Quote:
Originally Posted by ssveter View Post
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
This is where you want the Stroustrup book. This is a problem he talks about early on, because it's a common problem. One of the earliest projects is a calculator, which deals with the input parsing problem quite thoroughly.

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
ClayDowling is offline   Reply With Quote
Old 11-05-2011, 04:13 AM   #19
ssveter
 
ssveter's Avatar
 
Join Date: Jun 2011
Location: Richmond, VA
Default 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.
ssveter is offline   Reply With Quote
Old 11-05-2011, 04:18 AM   #20
ssveter
 
ssveter's Avatar
 
Join Date: Jun 2011
Location: Richmond, VA
Default Re: GURPS RCC (Ranged Combat Calculator)

Bottomline is I don't kow how to write a parser in VB yet.
ssveter is offline   Reply With Quote
Reply

Tags
gurps 4e, ranged, ranged combat


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Fnords are Off
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 10:57 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.