### #Shooter - A challenge, and a request for help

Friendly conversations, and everything that doesn't fit into the other forums.
• 1
• 2

#### #Shooter - A challenge, and a request for help

LukasPJ
Posts: 311
Joined: Tue Feb 03, 2015 7:25 pm

Hey guys!

Here's a minor challenge and request for you! My teammate (Simon Jensen) and I are working on my master thesis, which consists of the following components:
• We will make a game.
• People will write AI's for the game.
• We will write a reinforcement learnt AI, which trains on the previously mentioned AI's and attempts to beat them.

We are almost done with the game, and we are gonna arrange a hackathon, where people can develop AI's which will compete. However, we could always use more ai's, and we would like to work out some of the quirks before the hackathon, so I'm hoping some of you will try and implement an AI for the game!

The AI's are implemented in C#, you will implement a function which you can name anything you want, for example it could be named "MyThinkMethod". This method takes a FeatureVector and returns a PlayerAction. Whatever you do inside this function is up to you, as long as you don't access any other information from Torque3D than what is given in the FeatureVector, and don't try to manipulate the state of Torque3D. We didn't have time to patch up all the security holes there are.

Here's a simple example of an AI that simply moves forward:
using Torque3D;using Torque3D.Engine.Util.Enums;namespace GameAI{   public class AIClass   {      [ConsoleFunction]      public static PlayerAction MyThinkMethod(FeatureVector vector)      {         return PlayerAction.MoveForward;      }   }}

And here is an example which avoids obstacles:
using Torque3D;using Torque3D.Engine.Util.Enums;namespace GameAI{   public class AIClass   {      [ConsoleFunction]      public static PlayerAction MyThinkMethod(FeatureVector vector)      {         if (vector.DistanceToObstacle < 1.5f)            return PlayerAction.TurnRight;         return PlayerAction.MoveForward;      }   }}

Getting started is simple! Just download the game (Winx64 compiled on Windows 10) here. Open the VS solution in the aiProject folder. It should be able to compile right away, so see if the solution compiles.

The solution is a simple C# solution, with a single class, which references the Torque3D.dll and outputs to the aiLibs folder. All dll's in the aiLibs folder will be probed for static functions with the [ConsoleFunction] attribute, so you can have multiple AI's in different dll's. You will see I left a simple one for you to try and beat
Then simply run the Game.exe file. When the main menu loads, select "SinglePlayer" and "StartLevel" and then you should see the following screen:

Now you can write in the name of the function that the AI should use (there is a bad one for default). For example you could write "MyThinkMethod" or "LukasThink" like so:

Now, you should see the game running which looks like this. The Player 1 is the blue one, Player 2 is green.

Please tell me if anything is unclear and thank you so much if you take a look at this. Feel free to report bugs, errors, stuff that is not properly explained etc. And if you make a cool AI, please post it here so we, and everyone else, can download it and compete against it!

Happy coding!

Edit:
You control the camera with WASD + E for up and C for down.

Edit:
Game mechanics!
This is fairly important, I guess.. The game mechanics are as follows:

T3D has the standard 32ms tickrate. Each tick allows both players to take 1 action (i.e. one call to their think function). The players can take the following actions:

• None - Do nothing
• MoveLeft - Strafe left
• MoveRight - Strafe right
• MoveForward - Move forward
• MoveBackward - Move backward
• TurnRight - Turn right at a rate of 2 degrees per tick
• TurnLeft - Turn left at a rate of 2 degrees per tick
• Shoot - Shoot once, with a probability of missing. If the shoot delay is greater than 0, this action will fail.
• Prepare - Save one action for next round

Now, we can take a bunch of actions, but what information are we basing it on? The idea is that you have limited information about the game world. When an enemy is within your FOV, you can't tell for sure where it is. So you will have to rely on the Damage Probability.
When a player is in your FOV, there is a certain probability that you will hit the player, and thus a probability that you miss. The closer the enemy is to the center of your FOV, the higher the probability. We use a Normal distributed PDF, so the probability quickly drops.

This is the full list of information you get in the so-called "FeatureVector":

• Change in rotation
• Change in movement
• Velocity
• The probability that a shot at the current tick will result in damaging the other player
• The change in "Damage Probability"
• Current health
• Current health of the enemy
• Distance to obstacles directly in front of you
• Ticks since the game started
• Ticks since an enemy was last observed (i.e. since damage probability > 0)
• Ticks since damage was last taken
• Delay in ticks before you can shoot again

#### Re: #Shooter - A challenge, and a request for help

Duion
Posts: 651
Joined: Sun Feb 08, 2015 1:51 am

Are you using BadBehavior ? I use those behavior trees and found them really easy to use and practical. Just an idea.

#### Re: #Shooter - A challenge, and a request for help

JeffR
Steering Committee
Posts: 646
Joined: Tue Feb 03, 2015 9:49 pm

This looks pretty sweet. I'll have to dick around with this this weekend

#### Re: #Shooter - A challenge, and a request for help

LukasPJ
Posts: 311
Joined: Tue Feb 03, 2015 7:25 pm

Duion wrote:Are you using BadBehavior ? I use those behavior trees and found them really easy to use and practical. Just an idea.

Nope, I dunno if BadBehavior was an option, but there's not really any AI stuff in there. I custom-wrote a Player class for the purpose and made the "ThinkMethod" functionality.

#### Re: #Shooter - A challenge, and a request for help

LukasPJ
Posts: 311
Joined: Tue Feb 03, 2015 7:25 pm

New update!

Important changes:
• Renamed "killProb" to "damageProb" where applicable.
• Fixed places where "prob" was spelled "prop".
• Added the health of the enemy to the feature vector
• Every round now has a timer, if timeout both players loses

There were also minor UI changes
Available here: http://www.filedropper.com/sharpshooter-deploy_1

#### Re: #Shooter - A challenge, and a request for help

JeffR
Steering Committee
Posts: 646
Joined: Tue Feb 03, 2015 9:49 pm

As per my comment in irc, ran into some trouble running it. Here's the command prompt output:

Microsoft Windows [Version 6.1.7601]

D:\gamedev\T3DMIT\SharpShooter-Deploy>game.exe

y 'file:///D:\gamedev\T3DMIT\SharpShooter-Deploy\aiLibs\LukasAI.dll' or one of i
ts dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515
) ---> System.NotSupportedException: An attempt was made to load an assembly fro
m a network location which would have caused the assembly to be sandboxed in pre
vious versions of the .NET Framework. This release of the .NET Framework does no
t enable CAS policy by default, so this load may be dangerous. If this load is n
--- End of inner exception stack trace ---
eBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&
stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntro
spection, Boolean suppressSecurityChecks)
Base, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& s
tackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntros
pection, Boolean suppressSecurityChecks)
semblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMar
k& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIn
trospection, Boolean suppressSecurityChecks)
idence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm,
Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackM
ark)
at Torque3D.Initializer.InitializeTypeDictionaries(String path) in C:\Special
e\Game\Torque3D\My Projects\Empty\buildFiles\c#\Torque3D\Torque3D\Initializer.cs
:line 19
at Game.Program.Main(String[] args)

#### Re: #Shooter - A challenge, and a request for help

LukasPJ
Posts: 311
Joined: Tue Feb 03, 2015 7:25 pm

JeffR wrote:As per my comment in irc, ran into some trouble running it. Here's the command prompt output:

Microsoft Windows [Version 6.1.7601]

D:\gamedev\T3DMIT\SharpShooter-Deploy>game.exe

y 'file:///D:\gamedev\T3DMIT\SharpShooter-Deploy\aiLibs\LukasAI.dll' or one of i
ts dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515
) ---> System.NotSupportedException: An attempt was made to load an assembly fro
m a network location which would have caused the assembly to be sandboxed in pre
vious versions of the .NET Framework. This release of the .NET Framework does no
t enable CAS policy by default, so this load may be dangerous. If this load is n
--- End of inner exception stack trace ---
eBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&
stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntro
spection, Boolean suppressSecurityChecks)
Base, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& s
tackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntros
pection, Boolean suppressSecurityChecks)
semblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMar
k& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIn
trospection, Boolean suppressSecurityChecks)
idence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm,
Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackM
ark)
at Torque3D.Initializer.InitializeTypeDictionaries(String path) in C:\Special
e\Game\Torque3D\My Projects\Empty\buildFiles\c#\Torque3D\Torque3D\Initializer.cs
:line 19
at Game.Program.Main(String[] args)

Huh, that is a weird issue. Try deleting the LukasAI.dll file, apparently it is out-of-date or something similar.

#### Re: #Shooter - A challenge, and a request for help

Johxz
Posts: 391
Joined: Sat Feb 07, 2015 11:37 pm
@
LukasPJ

#### Re: #Shooter - A challenge, and a request for help

LukasPJ
Posts: 311
Joined: Tue Feb 03, 2015 7:25 pm

Gimme a day, I just had the Hackathon, and I found a bunch of issues, which I will solve.
This is the presentation we used today:
http://lukasj.org/sharpshooter/#/

http://lukasj.org/sharpshooter/#/14

But atm you have to delete, the dll's inside the "AiLibs" folders before it works. I'm working on updating the deployment zip so it works out of the box I'm also creating a subreddit for the game, as we intend to keep supporting the game during our thesis

It incurs to me that I should probably have posted the livestream of the tournament here..

#### Re: #Shooter - A challenge, and a request for help

JeffR
Steering Committee
Posts: 646
Joined: Tue Feb 03, 2015 9:49 pm

I got myself sick for most of the weekend and first half of this week, so I didn't get to do much with this like I wanted to, but it's cool that it sounds like the tourney went well.

Did the stream get archived anywhere?
• 1
• 2

#### Who is online

Users browsing this forum: No registered users and 2 guests