Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

How many of you people are good at math algorithms or programming?

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
This topic is archived.
Home » Discuss » The DU Lounge Donate to DU
 
Massacure Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Feb-21-05 10:56 PM
Original message
How many of you people are good at math algorithms or programming?
I was thinking of trying to make a online game. I think I have some things planned out well, but there is an algorithm I've been thinking about but has had me stumped.

Let's say we have:

Team 1:
2 guys with an AK-47.
1 guy with a RPG
1 tank

Team 2:

4 guys with an AK-47
2 tanks.

AK-47 damage = 50. Human modifier is 1, Tank modifier is 0.1
RPG damage = 250. Human modifier is 1, tank modifier is 1.
Tank damage = 500. Human modifier is .2, tank modifier is 1

How do I break it down so that the AK guys fire at humans first and the RPG and tank fire at tanks first?

If you know php, that is a plus, other wise you can just use pseudocode or a basic algorithm.
Printer Friendly | Permalink |  | Top
Skink Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Feb-21-05 11:02 PM
Response to Original message
1. OK I'm really bad at math.
Sorry.
Printer Friendly | Permalink |  | Top
 
Massacure Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Feb-21-05 11:04 PM
Response to Reply #1
2. Well keeping this kicked helps.
;)

I don't know where else it would fit that is slower though.
Printer Friendly | Permalink |  | Top
 
Philosophy Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Feb-21-05 11:15 PM
Response to Original message
3. Priority list
I think I see what you're getting at with your modifiers - a priority list. Each weapon should have a list of targets associated with it in order of priority. The weapon chooses the target with the highest priority that is in its range. You could still add a little randomness in with your modifiers if you use them probabilistically.
Printer Friendly | Permalink |  | Top
 
sans qualia Donating Member (675 posts) Send PM | Profile | Ignore Mon Feb-21-05 11:22 PM
Response to Original message
4. I don't know if this will be helpful...
Edited on Mon Feb-21-05 11:47 PM by sans qualia
(I don't know anything about php, so this is written in
something approximating Java...)

void setTarget(){
 if (Guy.weapon == "AK-47")
  if (Guy.seesGuy() != -1) 
   Guy.target = Guy.allSeen[Guy.seesGuy()];
  else
   Guy.target = Guy.allSeen[0];
 else
  if (Guy.seesTank != -1)
   Guy.target = Guy.allSeen[Guy.seesTank()];
  else
   Guy.target = Guy.allSeen[0];
}

int seesGuy(){
 for(x=0; x < Guy.allSeen.length(); x++)
  if (Guy.allSeen[x].type() == "guy")
   return x;
 return -1;
}

... where setTarget() and seesGuy() are methods in the Guy
class, and allSeen in an array of type, um, "targetable
thing" that contains all of the opposing things the guy
can see.

edit: I tried to indent for readability, but apparently the
forum software doesn't like extra spaces... sorry.

another edit: it also doesn't like square brackets... grr...
[i]grudgingly[/i] replace with <>'s

yet another edit: just noticed the plain text checkbox... I am
an idiot...
Printer Friendly | Permalink |  | Top
 
Skink Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Feb-22-05 12:19 AM
Response to Reply #4
5. Yikes all around...
:crazy:
Printer Friendly | Permalink |  | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Thu May 02nd 2024, 03:58 AM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » The DU Lounge Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC