Tuesday, December 30, 2008

Memory Leaks

Any time I add a substantial chunk of code or do drastic changes, I check my running logs. Fishguts is compiled with memory leak logging tools so each time I run it, it generates a log and tells me where it was allocated from…

So yeah.. I spent today removing all mem leaks from the astar code which turned out I was fighting myself, and it was a simple one liner.. but hey, at least there is no leaks again! Tho there is an odd tangeng in the pathing…

Lets do a nice example.

    ABC
    ...
    ...
    ...
    DEF

ABC are enemies, DEF ande my guys.

You would think, on first pass,they cheapest cost would be A->D, B->E, C->F.. but what happens is…

Move1

    .BC
    A..  
    ...
    ...
    DEF

Move 2

    .BC
    ...
    A..
    ...
    DEF

Move 3

    .BC
    ...   
    ...   
    .A. 
    DEF

Umm… what? yeah.. not sure either… Mostly it appears everyone goes to attack the guy in the middle… I need to do some more testing.

edit:: Hmm that gave myself a clue, and checking my code, I was comparing versus the cost of the number of moves instead of the actual COST of the movement (diagonals cost more), etc.. oops.. fixed now.

 

Posted by Stu on 12/30/2008 at 08:18 PM Permalink to this post.
Filed Under : ComputersDevelopmentFishguts
Tags:

(0) Comments
Share/Bookmark

Monday, December 29, 2008

A Star Pathfinding

Christmas was busy, and in terms of code, not a lot got done. I did put a prelim A* routine into play this morning. I’ve been watching it generate cellular automata based dungeons and put random start/end points in and draw the best A* path between them. It ran for a few hours and no bugs appeared. Its kinda fascinating to watch it meander its way from point A to B.

I guess the plan now is to generate a list of all enemies on the map, and for each one, generate an A* path and see what has the lowest cost. That should not be very CPU heavy as the combat map is always a fixed size, its small and there are very few obstacles to actually detour around.

Mm and I can throw away the entire path but for the first step, as that is all the enemy needs to take…

Posted by Stu on 12/29/2008 at 01:29 PM Permalink to this post.
Filed Under : ComputersDevelopmentFishguts
Tags:

(0) Comments
Share/Bookmark

Thursday, December 18, 2008

Choosing who to attack

Basic AI can be as easy or as hard as you want to make it.

Here is a nice example I’m trying to work through.

If Monster B (MB) is next to Monster A (MA) and MA has a melee weapon, well you have them fight. easy.
What happens when you want MA to move toward some enemy to fight.

First you need to determine whom you want to attack. Deciding that is a PITA.

Right now I build a list of everyone alive whom is not affiliated to the same alliance groups as myself (Everyone can have two alliances), this should basically be everyone I want to kill, and no friendlies.

Then with that list you could pick the closest one to head toward…

But what if, due east 4 spaces is a Big Black Dragon whom is the closest, but due west 5 spaces are two wimpy kobolds… A human player would go for the kobolds..

Hmm.. but the computer is not me. So now I need an extra field to give each monster a relative threat level.

OK so now we know that the kobolods pose less of a threat than the Black Dragon… Lets replace the kobolds with a Dracolich which is a bigger threat than the Black Dragon.. Only behind the Black Dragon is a line of 10 more Black Dragons..

So even tho the Black Dragon is a lesser threat and close, than the Dracolich… Only the 10 more behind it make it a bigger threat… and because you know you have that Long Sword vs Dracolich +42…

Hmmm, so now we need to take into account something like a rough proximity count to the target, and am I holding any special weapons that might juuust help me out?

Should the computer know that all 11 Black Dragons are injured and have only 1 hp each, are all poisoned so will probably die before the start of the next round?

How much information should the computer snoop on? Too little and the compuer will make stupid choices. Too much and it will be extremly hard to beat (plus it can move on the diagonal and you cant).

Its never as easy as picking the nearest neighbor.

Then you have to factor in A* path finding, that monster might be the closest, or best choice but the A* path finding takes me right past that nasty pack of beholders…

Posted by Stu on 12/18/2008 at 10:50 AM Permalink to this post.
Filed Under : ComputersDevelopmentFishguts
Tags:

(2) Comments
Share/Bookmark

Monday, December 15, 2008

Things I had’t paid attention to before

I learnt something on the weekend, something I had not bothered to really think about.

My Wapienica straight razor is a 4/8
My Carl Rader Solingen straight razor is 5/8
and my Thomas Turner Royal Navy straight razor is 6/8

Hmm, also consequently the wapi is the most delicate, and the Thomas Turner is positively wedge-like, its probably 1/4 or less hollow ground I think.

Posted by Stu on 12/15/2008 at 01:05 PM Permalink to this post.
Filed Under : LifePersonal
Tags:

(0) Comments
Share/Bookmark

Human AI

Got some basic human AI going. This is for the generic humanoid/human thinking level enemies. It is only 80% implemented right now but the logic flow will be something like the following;

It basically goes like this right now;

- If there is an enemy next to me, switch to melee weapon and attack
- If no enemies around me, switch to ranged weapon and attack
- If I cant attack, move closer

I still have to wrangle spells in there.

I also don’t want everyone to fire off spells in the first couple of rounds and be left with nothing if combat goes on for more than a couple of rounds. I had thought that the lower the hit points the higher rated using spells should be. I also still need to factor skill into play. So someone with higher melee skill should think of using that first, rather than an abysmal magic rating, and thus a wizard should concentrate on spells before rushing headlong into battle with just a dagger and no melee skill…

The human level AI will probably be the most complex. Higher up intelligence AI is just tweaked human ai, and you can think of tweaks like, automatically picking the PC’s with the lowest hit points or other sneaky things. Dumb AI will just be of the rush-and-attack kind of thing with no sense of self preservation.

Posted by Stu on 12/15/2008 at 09:21 AM Permalink to this post.
Filed Under : ComputersDevelopmentFishguts
Tags:

(0) Comments
Share/Bookmark

Wednesday, December 10, 2008

Other Projects

Random stuff that has been neglected for too long.

Bunyon
Cleaned up the head of the Bunyon interpreter last night, branched it for playing with the TRS80 format. The plan is to convert the TI99 bytecode into an more managable form of bytecode and strings internally. With the new internal representation I can load the TRS80 ScottFree format and convert that from its ASCII line oriented text into new one.

The hope is that there will be litle to no code change required regarding trs80 game code and ti99 game code for playing, but of course there are always edge cases, and probably the couple of opcodes that the TI99 does not use, the TRS80 probably will use…

I also need to test the remaining four Scott Adams games I have and create .apl code and transcriptions.

This will hopefully go hand in hand with the ScottCom compiler.

ScottCom
Speaking of the ScottCom compiler, the plan for that is to export the internal representation (which is TI99 bytecode) into TRS80 line oriented format.

The big problem here is with TRY blocks. I dont know how or even if, the TRS80 format uses or implements try blocks.

SmallC Cleanup
My little SmallC project is going ok, the first big hurdle is the need to add prototypes. I branched the AVR codebase and stripped all the junk out, the nice thing about this base is it handles structs and unions and ANSI-C functions, just not prototypes.

It would be really nice if it converted it into an AST but maybe I’ll consider that later. I need to also incorporate some of the ideas from the original SmallC 2.x tree (this has a different license than the original 1.x branch the AVR tree comes from), which turns it into pcode in memory rather than direct asm textual statements.

Codpiece
This is my little database system, kind of like an access database without the forms front end. It was inspired by the original PC-File+ database system (who remember the first shareware app?), and is more of an interesting excercise than anything serious (are not all my projects?).

Cracks and Cervices
Ahh my other big project (next to fishguts), this needs some loving, but until Fishguts gets to a more complete state I dont intend to focus on it much. I really need to cut a release of its current code base but I think it needs a few more extras added to it (you know, those things on the roadmap that I decided it should have, but never finished in my projected time allotment).

Posted by Stu on 12/10/2008 at 01:52 PM Permalink to this post.
Filed Under : ComputersDevelopmentBunyon / ScottComCracks and Crevices
Tags:

(0) Comments
Share/Bookmark
Page 1 of 2 pages  1 2 >