This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

Yoinkinator
Yoinkinator presents ...

2010/2/1

BattleBasicAI

This is basically my first attempt at programming basic AI.

A very basic simulation, not a game, but fun to watch! Consequently, there are no controls.

Essentially, it's Red vs. Blue and both units fire bullets at each other from a given range, and if a unit is hit 3 times by an enemy bullet, it dies. The dead units appear with "X"s and the winning faction spins (those that aren't dead).

The movements seem random, but there is a basic pattern to which the units move. When a unit is more than a given distance away from a target, it finds the closest enemy and moves in it's direction. Once the unit gets within that distance, it begins firing and moving in a specific orientation (random between -90 degrees and +90 degrees) around its target. If it's target is destroyed, it finds new targets and continues this procedure until all targets are terminated, by which time it spins in triumph!

UPDATE (2/1): Units and bullets now loop when they reach the end of the world! Respawning system now implemented! Bug fixed! Casualty Counters!

UPDATE (2/2): Casualty Counter now determines winner. Round system now functioning (Rounds: 500 total casualties).

UPDATE (2/3): Counters and Round Archive reprogrammed: much smoother. Dead units now clear.

SOON: Sudden Death (Eliminate Ties). 'Learning' systems, should be interesting :).

Special Thanks: Builderboy2005 for the help :)

Hope you enjoy!

7055 views / 12 in the last 7 days

6 votes | 0 in the last 7 days

Tags: simulation demo strategy artificial battle basic ai random intelligence 2d

open in greenfoot
Your browser is ignoring the <APPLET> tag.
A new version of this scenario was uploaded on Wed Feb 03 01:59:18 UTC 2010
A new version of this scenario was uploaded on Wed Feb 03 05:29:20 UTC 2010
YoinkinatorYoinkinator

2010/2/3

Thanks!
Ls_silenceLs_silence

2010/2/3

blarg
A new version of this scenario was uploaded on Thu Feb 04 06:04:48 UTC 2010
YoinkinatorYoinkinator

2010/2/4

Is anyone else continually getting Red as the victor for each round?
tombud999tombud999

2010/2/4

Yes, the red always win.
Well it looks to me that it is because the red is able to win even if it has less casualties :/ Also maybe add a speed slider so we can do fast simulations?
YoinkinatorYoinkinator

2010/2/5

Well, the side with the least casualties is supposed to win... I don't know why Red is winning most of the time :/ I'll try to create an overall 'commander' for each side or something and even this out.
Oh whoops, i was thinking kills not casualties x.x

See all comments

Want to leave a comment? You must first log in.

Who likes this?

qnanqing plcs limefortheworld SamSkinner Builderboy2005 tombud999