4k General

OK, I’m starting to feel confident this will be complete in time for the deadline. Otherwise I guess I can save it for java4k 2013…? Started working on december 19th, based on some template posted here last year. Currently at slightly over 4k, but I have lots of things that can be removed, and made no real attempt to keep things very small. Just need to make the AI a bit more clever and have some better scenarios (probably fewer scenarios though; there are 14 now, but that is probably a waste compared to having maybe 5 good ones instead?).

Oh, I should probably come up with a name for it before submitting. At first I was planning to do something more like a Panzer General clone, so I thought of something like Panzers 4k or 4k General, but now it has diverged quite far from that anyway.

http://dl.dropbox.com/u/11540578/java4k_G_120101.png

AI and scenario data/generator is using up way too much space to have nice graphics (at least at my 4k beginner skill level), but in a way that is just staying true to the genre. :slight_smile: Maybe I can make the map look slightly better if I have a few bytes to spare.

Features:

  • 4 unit types (infantry, tanks, artillery, engineers)
  • limited field of vision (there are more enemies in game seen above, but most are too far away)
  • 4 types of terrain (clear, woods, city, water)
  • engineers can enter a water hex and act as a bridge for other units, for “river crossing”
  • engineers are also good for attacking cities, that other units are not so good at
  • a unit that is attacked is weakened (marked with a gray border) and much easier to attack later in the same turn, so you want to concentrate several units on the same enemy in the same turn (and preferably strike with artillery first)
  • a campaign of several scenarios; complete a scenario by taking all cities before a certain number of turns to advance to the next scenario (fail and you get to replay the scenario)
  • different units have different movement rates and combat power in different terrain
  • some sort of AI… it’s not very clever of course
  • combat results in possible loss of attacking and/or attacked unit

Essentially what I think you expect from a turn-based wargame?

Currently all units except for artillery can move then attack, like in Panzer General, but I will probably have to remove that to save a few bytes (especially by making the game easier for the AI).

I would be interested to hear if you think this is a too easy project? It’s my first attempt at a 4k game. I know there are some obvious features (eg supply, air-support) that I would like to add if I could, but that there will be no room for me to make a proper GUI for. Supply would be very confusing for the player if there is no good way to display what units are “in supply” and why.

Also, what other similar games have there been? Couldn’t find any on the current java4k site.

[quote=“pelle,post:3,topic:37903”]
It’s an achievement to create a working 4k game which is more sophisticated than Pong. This sounds more advanced than some games I’ve seen in previous years’ competitions, so don’t worry.

Your game is very promising, and will certainly make an original 4K entry. And good for every wargamer, with all these announced features. I don’t remember any such turn-based wargame in previous 4K contests, although some turn-based strategy games have already been submitted.

To answer some of your questions :

  • it doesn’t seem at all an easy project ;
  • about the scenarios, favor better and fewer ones ;
  • about the name, 4K General is a cool one. Some other suggestions : 4K Storm Rising, Memoir '4K, T4ktical Assault…

Receive my encouragement to complete your game.

Thank to both of you!

I’m leaning towards 4k General at the moment, even if it might create some wrong expectations.

If you ask me, I’ll say that your problem maybe fit it on 4K. The AI and graphics seem take lot space. I’m new to 4K too so let’s rock! ;D

Added AI, removed some minor things (like the ability to move+attack), for a total size of 4156 bytes.

Trying to add some terrain textures, but it seems like it uses too much space (total of 4262 now) AND is too slow (I could easily fix one problem, but not both). Annoying.

Removed some debug code (kept the number of enemy units down to make AI debugging easier). Now I’m at 4112 bytes. Close. :slight_smile:

4092 bytes. :slight_smile: Now I only need to work a bit on the scenarios. The graphics will have to remain awful.

So… finally I sat down to do some more coding on this game. I thought an easy way to save some bytes, to leave room for improvements, would be to throw out my silly wasteful way of saving bitmap images as a long string with one character (“x” or “o”) per pixel, and instead use a byte array. That didn’t work out so well. JAR size increased to 4197 bytes. I know some FAQ already warned that this wouldn’t work, but I guess I couldn’t believe it until I saw it. :frowning:

Guess I’ll have to git stash this implementation and forget it for now.

OK, so I have to figure out some other trick to make room for a little more content. I want the move-attack-rule back, and I know how to make the AI handle it too, but I need a few more bytes. Some other day. At least now I tried this thing (only 30 minutes lost anyway).

A small victory: I changed the way the woods terrain is generated, making it look better and also saved 12 bytes. :slight_smile:

Added a twist (not that great) to level 4. Now at 4095 bytes.

Will try to stay away from making more changes now, only focus on scenario design.

I played a little war game before similar to what this one looks like and it was quite fun. Keep it up!

Ooops. I had some debug code in my jar (it was supposed to only be in the debug build). After fixing my jar is only 3776 bytes. Wow.

Suddenly I must think about adding features again.

3994 bytes. I would have uploaded it tonight if I had 1 found the upload button and 2 had the time to fix some balance problems.

EDIT: Oh, ok, I noticed the upload button. Still want to do some minor tweaks, and I’m too tired to write a readable description of the game now anyway.

http://dl.dropbox.com/u/11540578/java4k-120223.png

Game submitted! ;D 8) (Of course not accepted by admins yet, but soon I hope.)

Campaign ended up being 10 scenarios. There is room for more, but I think 10 is enough. If anything there would be more interesting things to use the last 57 bytes for.

The AI is extremely defensive and rarely counterattack. One thing it definitely should do is attack with artillery more often (no risk of losses to the attacker), but if I fix that all scenarios will be much more difficult and you will need many more units to win (which will slow the game down and be boring). We’ll have to pretend that the enemy is running very low on ammunition or something. ::slight_smile:

Instructions:

Click unit to select, then click a hex to attack or move to. Repeat
for as many units as you want to move or attack with. Proceed to the
next turn by clicking the button in the upper right corner.

An unit that has already been attacked in the current turn is easier
to attack (less risk for your unit, greater chance of eliminating it).

Artillery can attack enemy units up to 3 hexes away. Other units can
only attack adjacent hexes.

Units in woods or cities are more difficult to attack (except for
artillery attacking woods).

Terrain also affects movement speed.

Enemy units far away are not seen.

Engineers can move into river hexes to let other units cross (the only
way to cross rivers). They are also better than other units at
attacking cities.

You win by occupying all cities on the map. This means you need to
leave a unit behind to guard each city you take, it is not enough
to simply pass through them to win, you must have a unit there.

After 15 turns a scenario ends in failure and is restarted.

There are 10 scenarios. Good luck!

Yes, the tiles/squares are called hexes in the instructions, for historical reasons, although I didn’t have enough space to add the code to actually render them as hexagons. :slight_smile:

Tested all ten levels and never failed so I guess they are too easy.

Some notes:

  1. Every time I click on the map the whole screen blinks so I guess you missed double buffering.
  2. When engineers stand next to the water there is no indication that they can move to it.
  3. The enemy never, ever attacked, making it extremely easy to win.
  4. Add an indication as to whether a unit moved or not, this will also help with the visualization around the next point:
  5. Sometimes when I clicked next turn it didn’t register.
  6. Maybe make it possible to move and attack if you have at least one spare square as that will make it more tactical where to move your units
  7. When winning it isn’t saying anything until you hit next turn (and that might make it 16/15 turns with just a small text showing you that you won).

Oh, and here is a link for the lazy among us :slight_smile:
http://www.java4k.com/index.php?action=games&method=view&gid=400

Mike