Recently in javur Category

Java Top N List

| | Comments (0) | TrackBacks (0)

So I've been working in the Java mine (of my own volition) and now I will grace you all with my thoughts on Java, several years after I first played[1] with it. At times this list may seem a little harsh, but in reality I'm really liking the experience.

[1] And I do seriously mean "played", about as far as I got was "Hello World" and "ooh look at all of those objects!"

  1. Semicolons. I've just come off of a python/ruby kick. Having to type in semicolons again is weird.

  2. Typing. Also I've been coming off of a Haskell kick. Although Java's type system is not nearly as strict as Haskell's it's nice for the compiler to catch some little errors. Actually Haskell's type system is like BDSM, real strict, real painful, but also really nice in a way.

  3. Arrays vs. Collections. In all of the languages that I like to work in arrays are out and indexed lists are in. Java shows off it's machine language roots (and its similarity to C) by advertising and making arrays what people use. Compounding this is that where Collections are concerned (and pretty much any container type thing that takes the global base Object class type) the collections are more like LISP lists. A programmer can put in whatever the hell he wants into them, defeating some of the niceness of having type checking in the first place. Make up your mind Java. Are you dynamically or statically typed?

  4. Version Numbers. The discrepancy JDK version numbers and Sun Marketing people's version numbers are just stupid. But really most version numbers are completely stupid anyway.

  5. Debugger. jdb is crap. And I'm not going to install Eclipse. Time to try out the new java enabled version of gdb.

  6. Interpreter/Shell/REPL thing. As said before my language progressing looks something like (but probably not quite) perl -> C -> PHP -> Bash -> Python -> Scheme -> Common Lisp -> Haskell -> Ruby -> Java. The path is very roundabout, but most of these languages have a Read, Evaluate, Print, Loop thing that allows a developer to run little snippets of code and get back results. This really is a language feature folks! Although I don't know how well Java would cope with it since it is built on verbosity.

  7. Enumerations. Mapping symbols to integers in code is so 1969. I only think Haskell, Lisp, and (maybe) Ruby do this nicely.

  8. Classes vs. Packages vs. Modules. Everything is packaged in a class even if it doesn't make an object. So maybe they should've been called MODULES. Also, long.package.names.are.really.annoying. Especially when they're mapped to directories and my command line wraps around the screen.

  9. Development tools. I was going to say something about this but I forget. Maybe it was something about the Java communities habit of rewriting things (like building Ant instead of using make.)

  10. Interfaces vs. mixins and multiple inheritance. Maybe my number one complaint. I've heard that multiple inheritance was cut out because it would be too complicated for the programmer. From reading how someone is suppose to write java code for stuff like mixins (pretty much a lot of boiler plate crap) I think it may be worth the complication.

  11. Modifying existing classes. A lot of the OO languages let the programmer muck with the guts of existing classes. Java does not. This seems to be another case of "other programmers are our enemies."

  12. Public, private, and protected. "Other programmers are our enemies" again. Python does the old school Internet way of trusting the user of a class or library. The Java way probably helps compilation in some way (also numbers 10 and 11 also probably do as well.)

  13. Core types vs. Objects. int is a core type in the language while Integer is a class type that wraps all of the OO goodness around the int core type. Because of this I've messed with way too much code that has to cast between these types of types. Yucky.


Some Results

| | Comments (0) | TrackBacks (0)

The card game is progressing nicely. I now have some basic game looping and logic working (it's not perfect or 100% corrrect to spec yet.) Currently it's setup with two very simple AIs that play each other. Depending on the cards the AIs can play until they exhaust the deck, which indicates a couple problems: 1) if the deck is exhausted we should reshuffle the discards into a new deck, and 2) either the AI needs to be less careful about hoarding phys points, or the card distribution needs to be tweaked to have less (or less powerful) defense cards. Anyway some unit tests would be good for this thing someday. Current source code is available from darcs at http://dasbistro.com/~sam/card-game. There is no ANT or Make or anything for it. Right now I just use javac's capability of tracking down deps on it's own. Anyway here's a short game log.

Player 1 dealt [Card Drain (Psi) 0 -2 OPPONENT]
Player 2 dealt [Card Shield (Phy) 1 0 SELF]
Player 1 dealt [Card Drain (Phy) -2 0 OPPONENT]
Player 2 dealt [Card Magic Missile (Phy) -4 0 OPPONENT]
Player 1 dealt [Card Heal (Phy) 3 0 SELF]
Player 2 dealt [Card Drain (Psi) 0 -2 OPPONENT]
Player 1 dealt [Card Magic Missile (Phy) -4 0 OPPONENT]
Player 2 dealt [Card Shield (Phy) 1 0 SELF]
Player 1 dealt [Card Drain (Phy) -2 0 OPPONENT]
Player 2 dealt [Card Shield (Psi) 0 1 SELF]
Player 1 dealt [Card Magic Missile (Phy) -4 0 OPPONENT]
Player 2 dealt [Card Heal (Phy) 3 0 SELF]
Player 1:
  Phys: 10
  Psi: 10
  Hand:
    [Card Drain (Psi) 0 -2 OPPONENT]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
  Active: null
  Passive: [Card Heal (Phy) 3 0 SELF]
Player 2:
  Phys: 10
  Psi: 10
  Hand:
    [Card Shield (Phy) 1 0 SELF]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
    [Card Drain (Psi) 0 -2 OPPONENT]
    [Card Shield (Phy) 1 0 SELF]
    [Card Heal (Phy) 3 0 SELF]
  Active: null
  Passive: [Card Shield (Psi) 0 1 SELF]


Round 0
Player 1:
  Phys: 10
  Psi: 10
  Hand:
    [Card Drain (Psi) 0 -2 OPPONENT]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
  Active: null
  Passive: [Card Heal (Phy) 3 0 SELF]
Player 2:
  Phys: 10
  Psi: 10
  Hand:
    [Card Shield (Phy) 1 0 SELF]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
    [Card Drain (Psi) 0 -2 OPPONENT]
    [Card Shield (Phy) 1 0 SELF]
    [Card Heal (Phy) 3 0 SELF]
  Active: null
  Passive: [Card Shield (Psi) 0 1 SELF]
[Card Drain (Psi) 0 -2 OPPONENT] played against 2
Player 1 dealt [Card Drain (Psi) 0 -2 OPPONENT]
[Card Magic Missile (Phy) -4 0 OPPONENT] played against 1
Player 2 dealt [Card Drain (Phy) -2 0 OPPONENT]


Round 2
Player 1:
  Phys: 9
  Psi: 10
  Hand:
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
    [Card Drain (Psi) 0 -2 OPPONENT]
  Active: [Card Drain (Psi) 0 -2 OPPONENT]
  Passive: [Card Heal (Phy) 3 0 SELF]
Player 2:
  Phys: 10
  Psi: 9
  Hand:
    [Card Shield (Phy) 1 0 SELF]
    [Card Drain (Psi) 0 -2 OPPONENT]
    [Card Shield (Phy) 1 0 SELF]
    [Card Heal (Phy) 3 0 SELF]
    [Card Drain (Phy) -2 0 OPPONENT]
  Active: [Card Magic Missile (Phy) -4 0 OPPONENT]
  Passive: [Card Shield (Psi) 0 1 SELF]
[Card Magic Missile (Phy) -4 0 OPPONENT] played against 2
Player 1 dealt [Card Heal (Phy) 3 0 SELF]
[Card Drain (Psi) 0 -2 OPPONENT] played against 1
Player 2 dealt [Card Shield (Psi) 0 1 SELF]


Round 4
Player 1:
  Phys: 12
  Psi: 8
  Hand:
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
    [Card Drain (Psi) 0 -2 OPPONENT]
    [Card Heal (Phy) 3 0 SELF]
  Active: [Card Magic Missile (Phy) -4 0 OPPONENT]
  Passive: [Card Heal (Phy) 3 0 SELF]
Player 2:
  Phys: 6
  Psi: 10
  Hand:
    [Card Shield (Phy) 1 0 SELF]
    [Card Shield (Phy) 1 0 SELF]
    [Card Heal (Phy) 3 0 SELF]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Shield (Psi) 0 1 SELF]
  Active: [Card Drain (Psi) 0 -2 OPPONENT]
  Passive: [Card Shield (Psi) 0 1 SELF]
[Card Magic Missile (Phy) -4 0 OPPONENT] played against 2
Player 1 dealt [Card Shield (Psi) 0 1 SELF]
[Card Drain (Phy) -2 0 OPPONENT] played against 1
Player 2 dealt [Card Magic Missile (Phy) -4 0 OPPONENT]


Round 6
Player 1:
  Phys: 13
  Psi: 8
  Hand:
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Drain (Phy) -2 0 OPPONENT]
    [Card Drain (Psi) 0 -2 OPPONENT]
    [Card Heal (Phy) 3 0 SELF]
    [Card Shield (Psi) 0 1 SELF]
  Active: [Card Magic Missile (Phy) -4 0 OPPONENT]
  Passive: [Card Heal (Phy) 3 0 SELF]
Player 2:
  Phys: 2
  Psi: 11
  Hand:
    [Card Shield (Phy) 1 0 SELF]
    [Card Shield (Phy) 1 0 SELF]
    [Card Heal (Phy) 3 0 SELF]
    [Card Shield (Psi) 0 1 SELF]
    [Card Magic Missile (Phy) -4 0 OPPONENT]
  Active: [Card Drain (Phy) -2 0 OPPONENT]
  Passive: [Card Shield (Psi) 0 1 SELF]
[Card Drain (Phy) -2 0 OPPONENT] played against 2
Player 1 dealt [Card Drain (Phy) -2 0 OPPONENT]
The Winner: Player 1

Ha Ha Me + Java

| | Comments (0) | TrackBacks (0)

So in that last post "joopla" was a completely apt typo.


Java Card Game: Part the First

| | Comments (0) | TrackBacks (0)

I am teaching myself a marketable skill. The last marketable skill I learned was Ruby (or Python if you look at what people really want on the job boards) and since most people want Java knowledge with Ruby on Rails that's what I'm now learning. Java.

It's not so much as learning as re-exploring an old cave that you ventured into once when you were a snotty nosed teenager. For a language like Java, where I've seen syntax flown around for years, it's good (for me) to jump in with an idea for something to implement. Either taking a problem from the ACM or the PP list. For Java since I wanted to get a grip on J2EE and all of the joopla that surrounds it, mostly focusing on the web aspects (since that is what most folks want.) Something on the web and useful (to me or maybe others) is what I was thinking. Now what could I do with something that isn't mind-numbingly boring like some sort of of silly business database application, that used things like sessions and databases?

Ok, games can use these things. And they are most definately not boring (most of the time.) My first idea was to take the Sim City clone that has been living in my head for about five years and making it a DHTML web game. I currently have about 2-3 half baked transit simulators implemented in several languages and pages of notes. The real problem with doing this idea was that it is a pretty huge amount of thinking and implementing that I haven't done yet. So that one really is just out (and someday maybe it will be started... I've been messing with Ruby on Rails so maybe I'll do it there.)

Somehow I came onto the idea of a cardgame (it's written on this notepad here with "Java ideas: ... CARDGAME!") It came to me pretty quickly I guess, and I'm not really sure from where. Shannon plays a bit of Magic: The Gathering online so that may have had something to do with it. As I haven't played any incarnation of the multitude of trading card games, the rules for this game are taken from games I know (Lunch Money, City of Heroes, and Munchkin all come to mind when I look at the design), and keeping the rules simple since I have to make a computer do them.

So, the rules and concepts:

  • There are two wizards who are fighting each other (this will possibly be expanded to being there are many wizards figting each other, teaming up, etc.) Each wizard has a certain number of Physical points (or hit points), and Psi points (or magic points.)
  • Each player gets dealt 5 cards to begin.
  • Cards are either offensive or defensive.
  • Each card affects either the player or their opponent's psi and phys attributes.
  • Once a players phys attribute reaches zero game is over and the wizard is dead. When a players psi attribute reaches zero they cannot use magic.
  • Each player has a passive card slot that can hold either an offensive or defensive card which will affect each round of play. The passive slot card can be changed on the players turn and counts as a full round. Placing the card in the slot also causes the new card in the slot to be effected.
  • Each turn the player plays a card and draws a new card.

There are a few wrinkles in this right now. The costs of cards needs to be worked out a little bit, and the initial points allocated to the players. I'll probably have a couple crude AIs play each other to figure this out. Currently I have a barebones Game, Player, and Card classes to play with. Soon a bit of console testing, and then (mood music) crazy web crap.


ha ha javur

| | Comments (0) | TrackBacks (0)

I am totally the best programmer in the world.

import java.io.*;

class Hello {
     public static void main (String args[]) throws IOException
     {
         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
         String name = "";

         System.out.println("What's your name?");
         name = reader.readLine();

         System.out.println("Hello " + name + "!");
     }
}

About this Archive

This page is a archive of recent entries in the javur category.

infotainment is the previous category.

life is the next category.

Find recent content on the main index or look in the archives to find all content.

April 2009

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

November 2005: Monthly Archives

Pages

Powered by Movable Type 4.25