SoC2014 Zubin AI

From The Battle for Wesnoth Wiki
Revision as of 15:13, 21 March 2014 by Zubinkapadia (talk | contribs) (Questionnaire)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This page is related to Summer of Code 2014
See the list of Summer of Code 2014 Ideas



This is a Summer of Code 2014 student page


ATTENTION

This page will be continuously modified and updated.

Description

Zubin Kapaida: Improve AI by implementing global attack/retreat decision

I believe that the key to making a good AI bot is to keep your ideas clear and simple. One must evaluate the gravity of the situation using the given parameters and accordingly act offensively or defensively.

Sometimes it is more beneficial to risk one unit’s death or even sacrifice a few and perform the attack, the tricky part is to figure out when. In this game “Battle of Wesnoth” several factors affect the decision making like terrain, time of day (i.e. day / night), special abilities, enemy units’ status etc.

Positioning is a crucial part, ideally we should try to position every unit such that it has backup from other units and is away from critical danger, also positioning in terrain that would support maximum defense if ideal. Next we must try to exploit the enemies weakness, e.g. if the enemies unit has no defense in range, then we should attack that unit with heavy range units. Also while attacking we must try to surround the enemy from multiple directions and then synchronize the attack.

For implementation I propose use different parameters like aggression, depth etc. Here aggression parameter would specify how much the AI values its own units as opposed to that of the enemies. Depth parameter indicates the number of units that will attack a single opponent unit. protect_leader (radius) parameter, it is used to target any enemy unit which comes within the specified radius around the leader, and many others will be needed.

The value of aggression will determine whether to play offensively or to retreat. Next I propose the use of decision tree to determine the value of aggression. The decision tree will be a binary tree and in each node we check some condition like terrain, time of day etc. which affects our strategy. So we start from the root node and after validating all the conditions we end up on a leaf node. The value of aggression will be determined on the basis of the leaf node we end up on.

As mentioned earlier positioning is very important. Positioning of units is different for aggressive and defensive approaches. To plan out the positioning we will use threat map. A threat map is a 2D array which describes the level of danger on every position. While building a threat map, the positioning of the enemy units, type of units and other factors are taken into account.

IRC

ZubinKapadia

Questionnaire

1) Basics

1.1) Write a small introduction to yourself.

I am Zubin Kapaida, third year student of Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT)

1.2) State your preferred email address.

kapadiazubin07@gmail.com

1.3) If you have chosen a nick for IRC and Wesnoth forums, what is it?

ZubinKapadia

1.4) Why do you want to participate in summer of code?

To improve programming skills and to be a part of an open source project.

1.5) What are you studying, subject, level and school?

I am studying Engineering in Computer Science at undergraduate from Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT)

1.6) What country are you from, at what time are you most likely to be able to join IRC?

I am from India and I will be available on IRC every day from 10:00 am to 2:00 am IST

1.7) Do you have other commitments for the summer period ? Do you plan to take any vacations ? If yes, when.

No


2) Experience

2.1) What programs/software have you worked on before?

I have developed games in Flash using Actionscript, Unity3d game engine using javascript, panda3d game engine using python and corona SDK using lua.

2.2) Have you developed software in a team environment before? (As opposed to hacking on something on your own)

Yes

2.3) Have you participated to the Google Summer of Code before? As a mentor or a student? In what project? Were you successful? If not, why?

No, I haven’t participated

2.4) Are you already involved with any open source development projects? If yes, please describe the project and the scope of your involvement.

No I am not

2.5) Gaming experience - Are you a gamer?

Yes I am a gaming fanatic. I play counter-strike competitively on an inter-college level.

2.5.1) What type of gamer are you?

Hardcore Gamer.

2.5.2) What type of games?

On a competitive level I play FPS games. Casually I play every type of game: RPG’s, sand boxes, arcade, racing, strategic etc.

2.5.3) What type of opponents do you prefer?

Human opponents, higher their skills, better the gaming experience becomes.

2.5.4) Are you more interested in story or gameplay?

I consider both these components equally important for a single player game, but considering ‘Mafia’ the game, I would give story an edge over gameplay. Whereas in a multiplayer game, its gameplay without any doubts.

2.5.5) Have you played Wesnoth? If so, tell us roughly for how long and whether you lean towards single player or multiplayer.

Yes, although only for a few days in order to know the specifics of the game and to apply for this project. And initially as a newbie I would prefer single player.

2.6) If you have contributed any patches to Wesnoth, please list them below. You can also list patches that have been submitted but not committed yet and patches that have not been specifically written for GSoC. If you have gained commit access to our repository (during the evaluation period or earlier) please state so.


3) Communication skills

3.1) Though most of our developers are not native English speakers, English is the project's working language. Describe your fluency level in written English.

I am fluent in speaking as well as reading and writing English.

3.2) What spoken languages are you fluent in?

English, Hindi, Gujarati

3.3) Are you good at interacting with other players? Our developer community is friendly, but the player community can be a bit rough.

If you are implying about in game interaction, then yes I have had my share of experience playing with aggressive players and I have handled it well. And if you are implying about interaction in a team, even then I have worked in teams and haven’t faced any troubles.

3.4) Do you give constructive advice?

Yes, I always tend to help others.

3.5) Do you receive advice well?

If it’s a restrictive and demeaning advice then I ignore them, whereas if it’s constructive and motivating I receive it positively.

3.6) Are you good at sorting useful criticisms from useless ones?

I guess I am.

3.7) How autonomous are you when developing ? Would you rather discuss intensively changes and not start coding until you know what you want to do or would you rather code a proof of concept to "see how it turn out", taking the risk of having it thrown away if it doesn't match what the project want

I prefer discussing intensively for major functions, whereas I prefer the later while tweaking small functions.


4) Project

4.1) Did you select a project from our list? If that is the case, what project did you select? What do you want to especially concentrate on?

Yes, I’ve selected ‘Improve AI by implementing global attack/retreat decision’. I would concentrate on effectively figuring out the situations in which the AI should change its strategy, using decision trees.

4.2) If you have invented your own project, please describe the project and the scope.

4.3) Why did you choose this project?

I have selected this project because I am highly interested in Artificial Intelligence and game development, and I think it will be a great experience working with this project.

4.4) Include an estimated timeline for your work on the project. Don't forget to mention special things like "I booked holidays between A and B" and "I got an exam at ABC and won't be doing much then".

Pre coding phase

March 22- May 18 (4 weeks)

  • Reading the codebase of Wesnoth and understanding the flow of application code thoroughly.
  • Discussion with mentor and the community regarding the project to take valuable feedback.
  • Thoroughly plan out the decision tree and threat map structures.
  • Design algorithm into detail
  • Learn useful interfaces


Coding phase

May 19 - June 9 (3 weeks)

  • Implementing prototypes
  • Testing prototypes
  • Refining prototypes


June 10 – June 27 (2 weeks)

  • Working on implementation of the main code for the AI
  • Implementing threat maps.
  • Mid-term evaluation


June 28 - august 5 (6 weeks)

  • Working on implementation of the main code for the AI
  • Implementing decision trees.
  • Implementing Micromanagement for units.


Pencil down PHASE


August 6 – August 18 (2 Weeks)

  • Cleaning the code
  • Fixing the bugs
  • Documentation


4.5) Include as much technical detail about your implementation as you can

For implementation we must use different parameters like aggression, depth etc. Here aggression parameter would specify how much the AI values its own units as opposed to that of the enemies. Depth parameter indicates the number of units that will attack a single opponent unit.protect_leader (radius) parameter, it is used to target any enemy unit which comes within the specified radius around the leader, and many more will be needed.

The value of aggression will determine whether to play offensively or to retreat. Next I propose the use of decision tree to determine the value of aggression. The decision tree will be a binary tree and in each node we check some condition like terrain, time of day etc. which affects our strategy. So we start from the root node and after validating all the conditions we end up on a leaf node. The value of aggression will be determined on the basis of the leaf node we end up on.

Also positioning your units is very important. Positioning of units is different for aggressive and defensive approaches. To plan out the positioning we will use threat map. A threat map is a 2D array which describes the level of danger on every position. While building a threat map, the positioning of the enemy units, type of units and other factors are taken into account.

4.6) What do you expect to gain from this project?

  • Gain experience in game development.
  • Achieve a better understanding of Artificial Intelligence.
  • Gain experience of working with an open source community.

4.7) What would make you stay in the Wesnoth community after the conclusion of SOC?

I would love to stay in the Wesnoth community even after the conclusion of SOC.


5) Practical considerations

5.1) Are you familiar with any of the following tools or languages?

  • Git (used for all commits) - Yes
  • C++ (language used for all the normal source code) - Yes
  • STL, Boost, Sdl (C++ libraries used by Wesnoth) - No
  • Python (optional, mainly used for tools) - Yes, I have also developed a game in Panda3D

using python.

  • build environments (eg cmake/scons) - Yes
  • WML (the wesnoth specific scenario language) - No
  • Lua (used in combination with WML to create scenarios) - Yes, I have developed an android

game in Corona SDK using lua

5.2) Which tools do you normally use for development? Why do you use them?

Eclipse, Idle for python and flash develop.

5.3) What programming languages are you fluent in?

C, C++ and python

5.4) Would you mind talking with your mentor on telephone / internet phone?

No, not at all.

This page was last edited on 21 March 2014, at 15:13.