Some help with my Java program

Discussion in 'Programming' started by Justin393, Jun 21, 2015.

  1. Hey guys, so I've been working on a program in Java to make a proof of concept that another game's matchmaking system can be fixed. Currently, their system relies too much on one stat from a player and results in unfair matches. I have mostly eliminated that flaw, but I still have some undesired outcomes. Here is a list of my errors that I can't seem to resolve.

    1. If you're level 100 you get this error when it attempts to find you a match:
    if you're level 1 it will match you with a completely random opponent. So it seems that every level but 1
    Exception in thread "main" java.lang.NullPointerException

    1. at jjbat_000.matchmaking.Main.findMatch(Main.java:547)

      at jjbat_000.matchmaking.Main.main(Main.java:183)

      here are the following lines:
      547: int oppLevel = c.getLevel();

      183: findMatch(ch);

      That error only occurs when my level is 100, it works on every other level
    2. It only compares level, It's supposed to compare the level first, then check rank and critical, but it only works on level. (I'll post a few sample outputs from the program so you can see my meaning.

    Here are a few sample outputs from the program running.

    #1

    Code (Text):
    This is a proof of concept to prove that the matchmaking system can be improved upon
    Here we will input some basic information to find a fair match. Input the stats that you would like.
    Please input the level you would like.. (1 - 100)
    32
    Please input the rank you would like.. (1 - 3000)
    500
    Here are your stats..
    Level = 32
    Rank = 500
    Please input how many opponents you would like to be randomly generated
    2000
    Generating 2000 opponents...
    There are 210 opponents in your queue!
    Took 8 ms to generate the opponents!
    Attempting to find a close match...
    You have been matched! Here are the stats of your opponent...
    Level - 35
    Rank - 16
    Critical - 80
    Took 122000 nano seconds to find a match!
    Thanks for using the new matchmaking system!
    #2

    Code (Text):
    This is a proof of concept to prove that the matchmaking system can be improved upon
    Here we will input some basic information to find a fair match. Input the stats that you would like.
    Please input the level you would like.. (1 - 100)
    48
    Please input the rank you would like.. (1 - 3000)
    600
    Here are your stats..
    Level = 48
    Rank = 600
    Please input how many opponents you would like to be randomly generated
    30
    Generating 30 opponents...
    There are 6 opponents in your queue!
    Took 1 ms to generate the opponents!
    Attempting to find a close match...
    You have been matched! Here are the stats of your opponent...
    Level - 41
    Rank - 4400
    Critical - 100
    Took 118000 nano seconds to find a match!
    #3

    Code (Text):
    This is a proof of concept to prove that the matchmaking system can be improved upon
    Here we will input some basic information to find a fair match. Input the stats that you would like.
    Please input the level you would like.. (1 - 100)
    87
    Please input the rank you would like.. (1 - 3000)
    798
    Please input the critical you would like.. (0 - 600)
    287
    Here are your stats..
    Level = 87
    Rank = 798
    Critical = 287
    Please input how many opponents you would like to be randomly generated
    400
    Generating 400 opponents...
    There are 41 opponents in your queue!
    Took 1 ms to generate the opponents!
    Attempting to find a close match...
    You have been matched! Here are the stats of your opponent...
    Level - 84
    Rank - 1736
    Critical - 185
    Took 118000 nano seconds to find a match!
    So basically, I have them input the stats they want, (If the level is over 50 they can input critical, yes I know test 1 and 2 the opponent has critical, I just haven't patched that yet, basic character creation flaw)
    After they input their stats, the system will sort them by their level (In Character.java) into a List. Then when they generate the opponents, the opponents are generated with completely random stats, and sorted the same way. Then the system pulls a random one from the user's queue, checks the level, if it's close it's SUPPOSED to then check rank and critical and if they're close match them, but right now it only seems to check level, as you can see by the trial runs. (I want level to be within 10 and everything else within about 100) and if an opponent fails the checks they get put into a random queue. Then if the computer can't match you I want it to pick a random opponent from the noMatch queue and face them, but for some reason that won't work. Here's the error from that trial:
    Exception in thread "main" java.lang.NullPointerException

    at jjbat_000.matchmaking.Main.findMatch(Main.java:233)
    233: int oppLevel = c.getLevel();

    at jjbat_000.matchmaking.Main.main(Main.java:183)
    183: findMatch(ch);
     
  2. Can you post some code? It's hard to find your issue without seeing the line that is throwing the exception.
     
  3. Oh wow.. I could've swore I put the code on here..
     
  4. Just put some up and I'll take a look. Can youmake sure it includes the line that threw the null pointer?
     
  5. Yep, lemme grab it now
     
  6. Line 546 is returning a null character class. See if you can figure it out from there. I need to view this on my computer with a usable VM to dig deeper. In other words, tomorrow if I get time I'll tear it apart if you can't find the issue.