Would you be willing to commit 3 app pages to this game?
Yes
 94%  [ 16 ]
No
 5%  [ 1 ]
Total Votes : 17

The AI you describe sounds like something trivial for you to implement yourself, if you put your mind to it. A trivial pathfinding algorithm just tries to increment or decrement the AI player's X and Y position to get closer to the actual player; if you want to make it more complex, you can add the ability to try to move around walls.
Well, Kerm, my issue is I've never coded any type of AI before. So, for a game I'd rather not have that be my first attempt. That being said, I'm willing to give it a go, if someone could pseudo code the general concept.

As for smooth scrolling, I can do the frame-by-frame, but implementing the smooth scrolling system is beyond my capabilities. I'd also be willing to try and work with pseudo code for that too.

Update

Have a new sprites list. It is enclosed.


Code:
Textures

$00   Desert Sand
$02   Tree
$04   Grass
$06   Water full tile
$08   Water top-left edge
$0A   Water top-right edge
$0C   Water bottom-left edge
$0E   Water bottom-right edge
$10   Lava
$12   Sheet of Ice
$14   Block of Ice
$16   Hedge
$18   Fence
$1A   Solid Block
$1C   Trick Block
$1E   Bottomless Pit
$20   Ground
$22   Cactus
$24   Death Mountain sign
$26   Lake Hylia sign
$28   Kakariko village sign
$2A   Graveyard sign
$2C   Desert sign
$2E   Lost Woods sign
$30   Quest 1 sign
$32   Quest 2 sign
$34   Quest 3 sign
$36   Deku tree sign
$38   Castle Wall
$3A   Castle Tower
$3C   Dark Barrier

Buildings

$3E   left edge w/ roof
$40   right edge w/ roof
$42   left edge w/o roof
$44   right edge w/o roof
$46   roof extension
$48   building extension w/o roof
$4A   building extension w/ roof
$4C   door: temple of time
$4E   door: link's house
$50   door: sage's house
$52   door: Ganon's house
$54   door: Zelda's house
$56   door: deku tree
$58   door: forest temple
$5A   door: ice temple
$5C   door: water temple
$5E   door: spirit temple
$60   door: shadow temple
$62   door: fire temple
$64   door: Ganon's castle
$66   exit to prior map

In Dungeon

$68   stairs up
$6A   stairs down
$6C   boss door
$6E   locked door
$70   key
$72   boss key
$74   warp to boss
$76   spikes
$78   webbed hole (in deku tree)
$7A   hole to deku tree below ground

Other

$7C   Quest 1 Entrance
$7E   Quest 2 Entrance
$80   Quest 3 Entrance

Items

$82   Heart Refill
$84   Heart Container
$86   Magic Refill
$88   Din's Fire
$8A   Faore's Wind
$8C   Nayru's Love
$8E   Wooden stick
$90   Wooden Shield
$92   Kokiri Sword
$94   Hylian Shield
$96   Master Sword
$98   Mirror Shield
$9A   Fire Tunic
$9C   Zora Slippers
$9E   Empty Bottle
$A0   Fairy
$A2   Light Magic
$A4   Lens of Truth
$A6   Hookshot
$A8   Longshot
$AA   Quiver (20 max)
$AC   Quiver (50 max)
$AE   Bow
$B0   Bundle of 5 arrows

Characters

$B2   You (Link)
$B4   Sage
$B6   Zelda
$B8   Death Mountain Guard                                         
$BA   Deku Tree
$BC   Old Man

Enemy Classes

$BE   Soldiers   ATK 1 / DEF 1
$C0   Trolls      ATK 3 / DEF 2
$C2   Spirits      ATK 3 / DEF 5
$C4   Shades   ATK 1 / DEF 3
$C6   Zombies   ATK 2 / DEF 2
$C8   Keese      ATK 2 / DEF 1
$CA   Fire Keese   ATK 1 / DEF 2
$CC   Ice Keese   ATK 1 / DEF 2
$CE   Goblins   ATK 4 / DEF 4
$D0   Sorcerers   ATK 5 / DEF 5

Boss Enemies

$D2   Deku Tree (troll class)      ATK 5 / DEF 7
$D4   Forest Temple (troll class)      ATK 9 / DEF 3
$D6   Ice Temple (sorcerer class)      ATK 7 / DEF 5
$D8   Water Temple (sorcerer class)   ATK 9 / DEF 7
$DA   Spirit Temple (spirit class)      ATK 11 / DEF 9
$DC   Shadow Temple (shade class)   ATK 4 / DEF 10
$DE   Fire Temple   (goblin class)      ATK 13 / DEF 12
$E0   Ganondorf (sorcerer class)      ATK 15 / DEF 15


**For enemies that damage you once, the ATK factor is dealt immediately. For enemies that damage you by burning, freezing, or poisoning, the damage is dealt once per every couple cycles until the damage counter expires.

**The DEF value of an enemy determines how much damage it can take before it dies. The damage you deal is determined by the base attack of your player (increases as you clear dungeons), with the weapon type as an attack multiplier.

**enemy class attacks
Soldiers have swords and swing at you.
Trolls have clubs and try to club you.
Spirits try to collide with you.
Shades shoot a poisonous spray at you.
Zombies try to collide with you.
Keese try to fly into you.
Fire Keese try to fly into you and set you on fire.
Ice Keese try to fly into you and freeze you.
Goblins have axes and swing at you.
Sorcerers fire spells at you. Spell classes include: fire, freeze, and stun. Stun deals damage once. Freeze and fire deal freeze and burn damage.


I added the Deku Tree dungeon for all of those who have played Ocarina of Time. Thus, I also added the STICK and the WOODEN SHIELD as items. Both have a set number of hit points, before they break. The other two shields have no set hit points.

Oh, and I'll be needing routines for 90, 180 and 270 degree sprite rotation.
Bump. Here are some screenshots, but they are of my computer screen, viewing the maps in creation.
PS: Sorry about the logo in the second, Kerm. lol I didn't know how to select part of a screen when I took that.


ACagliano wrote:
Well, Kerm, my issue is I've never coded any type of AI before. So, for a game I'd rather not have that be my first attempt. That being said, I'm willing to give it a go, if someone could pseudo code the general concept.

Here's a little AI that's more fail-safe and smart:

Code:

1. Keep track of your previous movement direction. (undefined and disregarded if you just spawned)
2. Find the difference in x and y.
3. Select one of four movement directions based on these rules:
a. Initially select the direction that will shorten the longer difference, with preference to x.
b. If that direction is blocked by a wall, select the other direction that will shorten the distance between you.
c. If both of those directions are blocked, select your previous direction.
d. And if that direction is blocked, select the direction opposite your previous direction.
4. Move in that direction.

Here's some examples of this at work:

Code:

A = player
M = monster
# = obstacle
. = empty spot (not traversed)
<>^v = left, right, up, down (your movement path)

M>>>A

M>v..
..>v.
...>A

M#.
v#.
v#A
>>^

>>A..
^###.
^#M#.
^#v#.
^<<..

#########
#M#>..#.#
#v#^#.#.#
#v#^#.#A#
#>>^#...#
#########
(but then Presto! The middle wall moves!)
#########
#.#M#.#.#
#.#v#.#.#
#.#v#.#A#
#..>>>..#
#########
(but then Presto! All three walls move!)
#########
#....>>v#
#.#.#^#v#
#.#.#^#A#
#.#.#M#.#
#########
Alright. One epic fail AI attempt coming right up. lol. jk.

I'll give it a whirl.

ACagliano wrote:
Alright. One epic fail AI attempt coming right up. 0x5. jk.

I'll give it a whirl.
How is the AI going? I hope you're starting small and building it up piece-by-piece. Remember, when all of us coded our first AI, we had never done so before, and most of us never read through any guides to learn how to do it! Smile
KermMartian wrote:
ACagliano wrote:
Alright. One epic fail AI attempt coming right up. 0x5. jk.

I'll give it a whirl.
How is the AI going? I hope you're starting small and building it up piece-by-piece. Remember, when all of us coded our first AI, we had never done so before, and most of us never read through any guides to learn how to do it! Smile


I haven't actually started it yet. I'm still mapping on Pixelscape, which I've just discovered another bug, so I need to wait for a fix on that. In the meantime, I have some more screenshots for you...

Water Temple and part of Lake Hylia



Part of the Death Mountain area, showcasing the cliffs



Part of Kakariko Village

I'd suggest working on the cliffs -- the perspective at the 45 and 135 degree edges is rather wacky. It's hard to distinguish between the path and the (what I think is) grass in the village. The houses also look rather... skinny. I'd venture to say for at least that larger building in the village, you want to show a better sense of dimension, as it looks awkwardly thin -- you could fix this by showing more of the roof's top. The ladder in the second screen-portion is rather out of proportion of the rest of the environment, and seems out of place as a result. There is a LOT of banding in the water tiles, making them very harsh on the eyes (this effect grows harsher at higher pixel sizes.) Also, the village looks incredibly sparse -- no trees, signs, bushes, other minuscule landmarks? Adding some flair to the map's design results in a much more appealing sight for the player.
Ashbad wrote:
I'd suggest working on the cliffs -- the perspective at the 45 and 135 degree edges is rather wacky. It's hard to distinguish between the path and the (what I think is) grass in the village. The houses also look rather... skinny. I'd venture to say for at least that larger building in the village, you want to show a better sense of dimension, as it looks awkwardly thin -- you could fix this by showing more of the roof's top. The ladder in the second screen-portion is rather out of proportion of the rest of the environment, and seems out of place as a result. There is a LOT of banding in the water tiles, making them very harsh on the eyes (this effect grows harsher at higher pixel sizes.) Also, the village looks incredibly sparse -- no trees, signs, bushes, other minuscule landmarks? Adding some flair to the map's design results in a much more appealing sight for the player.


The cliffs: Yes, I know. I'm not an excellent spriter, so I kind of don't know how to fix them.
The ladder: I kind of like it that way Sad
The buildings: I could, but that would involve more sprites. Sad
The village: Yes, I will work more on the flair once a bug with Pixelscape is resolved.
The houses are all full-on isometric, so shouldn't the cliffs be head-on isometric as well, and not have those funky flare-outs at the edges? How about at least some pseudocode for your AI?
KermMartian wrote:
The houses are all full-on isometric, so shouldn't the cliffs be head-on isometric as well, and not have those funky flare-outs at the edges?


Well, they're not quite Isometric; they're more of a 45 degree (or more) overhead perspective. Combined with the funky cliff perspective, it is collectively commonly called "LTTP Perspective" among many in the game art industry, because the most notable game that used this was Zelda: A Link to the Past. A few examples. Doesn't quite make sense relative to natural forms of perspective, but this one is often employed to allow for a better view of everything on the map, and so that cliffs and high-rises can be equally observable at any angle.

As for some extreme nitpicking, this is the most common form of isometric perspective, being edge-major with roughly a 30 degree overhead slant.

/off topic Cool
You should read up on path-finding algorithms. There are some pretty easy ones you could use Smile
AI Psuedocode...

where P = prior direction,
X = enemy x
Y = enemy y
A = player X
B = player Y


Code:
$for each enemy {
If (X<A) and [(X+1) /= blocked]
::X + 1 -> X
else
If (X>A) and [(X-1) /= blocked]
::X - 1 -> X
else
If (Y<B) and [(Y+1) /= blocked]
::Y + 1 -> Y
else
If (Y>B) and [(Y-1) /= blocked]
::Y - 1 -> Y
else
If (P) /= blocked
::move in P direction
else
move in whatever direction has yet to be attempted.
Oops... I realize that I need to correct my AI code a little bit, because it will be confused in this case, since its previous direction is blocked and it has two other directions it can take:

Code:

.....#.
M>>>>#A
.....#.

Basically, the principle of the code is that moving in the previous direction is the last resort, and it should not do so unless all other directions are blocked. Therefore, in this code, if the previous direction is blocked but two directions are available, it should randomly select one of them, or perhaps move in the positive direction.

And while we're on the subject of AI, I also wanted to share a Machine Learning idea that I had for an adventure game like this:
1. For every enemy type, there is a Spawn Score, kept in a large integer space. When the player begins a new game, all of the Spawn Scores are set to an equal, high value.
2. When the player takes damage, all onscreen enemies add 1 to their type's Spawn Score per point of damage dealt. The enemy who dealt the damage adds additional points to theirs.
3. When an enemy takes damage, all onscreen enemies subtract 1 to their type's Spawn Score per point of damage. The enemy who took the damage decreases additional points.
4. When an enemy is spawned from a particular spawn point (which can spawn at least two different types of enemies), use the Spawn Scores to construct a pie chart of sorts to randomly determine which enemy spawns there. This means that an enemy with a Spawn Score of 100 is ten times less likely to spawn than an enemy with a Spawn Score of 1000.

As an example (taken from LOZ Wind Waker):
- When you enter the Earth Temple, Redeads and Stalfoses both have Spawn Scores of 100. Both also spawn from coffins.
- You enter a room with six coffins, which all reveal their contents, which turn out to be four Redeads and two Stalfoses.
- All four Redeads stun you with their scream attacks, giving a Stalfos time to whack you upside the head and deal 4 HP (4 heart quarters) of damage. All six enemies gain 4 points, and the Stalfos that hit you gets an additional 4 points (1 bonus for each HP). The spawn scores are now 116 for Redeads, 112 for Stalfoses.
- After you recover, you succesfully kill all four Redeads (4 HP each, which is worth 1 point here). On each death, all enemies lose 1 point, and the Redead you killed loses 1 additional point. Following the cascade down, the Redeads lose a total of 14 points, and the Stalfoses lose 8 points. The Spawn Scores are now 102 for Redeads, 104 for Stalfoses.
- A Stalfos hits you again, for 4 more HP. The Stalfoses gain a total of 12 points, putting the Spawn Score at 116. The Redeads don't gain any points, since they're dead now.
- You kill both Stalfoses (8 HP, worth 2 points). Doing the cascade again, the Stalfoses lose a total of 10 points, putting the Spawn Score at 106.
- Now, the next time you encounter a coffin, a Stalfos is somewhat more likely to spawn than a Redead, since it has a slightly higher Spawn Score.

The final effect is that, after playing the game for a while, the player will be faced with the enemies they find most difficult. Enemies that can do the most damage to the player and avoid getting hurt are the enemies that are most favored, though respect is paid to enemies that can drive you into other enemies or hazards. Additional considerations include:
- Change the values accordingly, especially if 1 HP for an enemy is not the same as 1 HP on the player.
- If you have more memory, simply keep running tallies of all of these values and calculate the Spawn Scores dynamically. This allows you to easily change the relationships between these tallies.
- Add and subtract points (or keep tallies) for other events, such as stolen coins or items.
- Use a similar technique for enemy AI strategies. Enemies draw from a subset of all the available strategies (the ones that they can execute). In more powerful programming environments, include multiple categories of strategies (walking, attacking, etc.)
- Allow players to view and export the Spawn Scores, reporting them to an online database. That way, you can see which enemies are easier and which are more difficult.
That is very interesting. Basically Darwin's evolution (sort-of) for seeing which enemy should be spawning.

In terms of stronger enemies, wouldn't time also change the spawn points so stronger ones spawn as time progresses?
AHelper wrote:
In terms of stronger enemies, wouldn't time also change the spawn points so stronger ones spawn as time progresses?

What do you mean by this, exactly?
- Do you mean that, for instance Stalfos will generate at a particular spawn point as opposed to a Keese? In that case, the system takes care of that automatically. Since the Keese is a much weaker enemy than the Stalfos, a little time will quickly put greater preference to the Stalfos over the Keese. Pretty much the only time such fundamentally weak enemies will be allowed to spawn is when they have spawn points all to themselves.
- Or, do you mean that enemy stats will go up as time progresses? In that case, the system will still work, since all stats (including yours) are going up relative to one another, so the changes to the scores will still be proportional. This is, of course, assuming that each enemy with the different stats subscribes to the same Spawn Score (e.g. a 20 HP Redead uses the same Spawn Score as a 4 HP Redead).
- Or do you mean that souped-up versions of enemies with new abilities, such as Fire Keese over normal Keese, will spawn at these spawn points over time. That's a little more tricky, and is probably more of a matter of choice for the implementer. You could either decide to combine fundamental types (i.e. you use the same technique to defeat any Keese, no matter how it's souped up), make the souped-up versions of the enemies separate (i.e. they creamed the Keese, so let's see how they do against a FIRE Keese!), or maybe even add enhancements as a secondary category similar to the AI strategy thing mentioned above (e.g. have Fire, Ice, and Lightning enhancements on all enemies).
God, there is no way in heck I'll be able to code that...
ACagliano wrote:
God, there is no way in heck I'll be able to code that...

Probably not to that complex of a degree. But you do have ten different types of enemies, so you could probably do just the essential parts of the system:
- Each enemy type has a 16-bit Spawn Score. At the beginning, set them all to an equal, high amount (such as 32768).
- For each point of damage an enemy deals, add 1 to its type's Spawn Score. Cap it at 65535.
- For each point of damage dealt to an enemy, subtract 1 from its type's Spawn Score. Cap it at 1 (so it still shows up sometimes).
- Scores determine which enemy types spawn by using a pie chart mechanism, among the subset of enemies allowed for that room.
And here's some psuedocode for the pie chart mechanism:

Code:
// All Spawn Scores are 16-bit integers
Find sum of all Spawn Scores of all allowed enemy types and store in 24-bit integer "sum".
Generate a 24-bit random integer (add two 16-bit ints) and mod it by sum. Store this in variable "choose".
For each enemy type allowed in the room:
 Subtract the Spawn Score from choose.
 If the result dips below zero, spawn that enemy type and end the loop.
Ok... I have picked up progress on this, starting with a complete recode of everything. I dumped the sprite/map set as well and plan to redo them. Also, I devised two separate algorithms for AI, one for enemies that try to run into you and one for enemies that shoot at you from far away. In addition, I have designed the main menu, file save, and map save routines. I will also be doing the event triggers and event scripts. Events are divided into two classes, pre-move events and post-move events. Pre-move events are generally what should stop you from moving onto a tile. Post-move events are like entering a building, stepping on lava, or collecting an item.

AI for Collision

1. Keep track of your previous movement direction. (undefined and disregarded if you just spawned)
2. Find the difference in x and y.
3. Select one of four movement directions based on these rules:
a. Initially select the direction that will shorten the longer difference, with preference to x.
b. If that direction is blocked by a wall, select the other direction that will shorten the distance between you.
c. If both of those directions are blocked, select your previous direction.
d. And if that direction is blocked, select the direction opposite your previous direction.
4. Move in that direction.

**there are some caveats with perhaps not a complete collision, since the tiles are 8x8 and AI/player movement is pixel based...

For AI where the enemy can fire at you

1. Move toward player y (more distance) (we are aiming to move in line with player, but not actually towards player)
; if enemy y = player y, we should try to shoot (but not all the time). If we are not shooting, goto 4.
; if movement blocked, goto 2

2. Move toward player x (again, moving in line with player, but not towards player).
; if enemy x = player x, we should try to shoot (but not all the time). If we are not shooting, goto 4
; if movement blocked, goto 3

3. Do nothing.

4. Move away from player on y (try to keep distance).
; if movement blocked, goto 5

5. Move away from player on x.
; if movement blocked, do nothing

-----------------------------------

Another thing I need help with. When the player moves, or the AI moves or a bullet sprite advances, I will need to replace the correct sprite underneath the sprite that has just moved. How do I do this?

-----------------------------------

Obviously, while I have made significant progress, a lot still needs to be done. So, if there are any developers out there who can code in Z80 and are willing to spare a bit of their time, I would not turn down some assistance with some of this programming. Assistance will be fully credited.

Particular areas of the coding that I need help with are this:

1. AI, initialization
2. AI, position update
3. AI, graphics rendering (including replacing what was under the enemy sprite)
**I am having issues with this because the tile set is 8x8 and the movement actually occurs 1 pixel at a time.
4. Bullet code, for enemies and for players.
5. Bullet sprite rendering
6. Rendering of the sprites in greyscale.

So, basically AI and graphics. Everything else is either already done or in progress. Also, for collision, I found this routine online, at the same link Kerm has sent me before:


Code:
check:
; a = x
; b = y
; returns c flag set if good
; returns c flag reset if no good (nc)
;  destorys af (quite obvious if one knows any z80 at all)
cp x1
jr c,nogood
cp x2+1
jr nc,nogood
ld a,b
cp y1
jr c,nogood
cp y2+1
jr nc,nogood
;if it gets here, it's in the box!   Yay!  Hooray!  Peoples rejoice!
; as a side effect of the last operation, the carry flag is already set.
ret
nogood:
or a;to reset the carry flag
ret


It checks whether a coordinate is inside a box. I could use a modification of this for collision detect.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement