Coder Social home page Coder Social logo

halite's Introduction

Halite C# bot and tools used to train this bot

Actual content of the submitted zip file is in https://github.com/cbovar/Halite/tree/master/Submission. Halite server only compiles two files (HaliteHelper.cs and MyBot.cs) so I had to fit all the code in those files which is not a common practice in C#.


Networks were trained using ~300 games from erdman v17 for a few hours using CPU. Three different networks were trained and used in the same bot:

  • 'Early network': early part of the game
  • 'Strong network': to play strong pieces (> 200)
  • 'Normal network': the rest

The idea is to try to copy the strategy of another player.


Steps to train an Halite bot using ConvNetSharp

This will train a single network, you can use TripleFluentNetTraining instead of FluentNetTraining to train a bot similar to cbovar V45

principle

  1. Get games historical data
  • Download games historical using HltDownloader. Downloaded games will stored in 'games/{UserId}/' folder. (e.g. games/2609/ for erdman)
  1. Train a network
  • Update downloaded games location here
  • Update the name of the player to copy here
  • Update network structure here. By default it is:
var convInputWith = 11; // Will extract 11x11 area

var net = FluentNet.Create(convInputWith, convInputWith, 3)
                    .Conv(3, 3, 16).Stride(2)
                    .Tanh()
                    .Conv(2, 2, 16)
                    .Tanh()
                    .FullyConn(100)
                    .Relu()
                    .FullyConn(5)
                    .Softmax(5).Build(); // 5 classes (1 for each direction)
  • Update trainer algorithm here. By default it is:
 var trainer = new AdamTrainer(singleNet) { BatchSize = 1024, LearningRate = 0.1, Beta1 = 0.9, Beta2 = 0.99, Eps = 1e-8 };
  • Run Training project. Downloaded games will be loaded and training will start. Four files will be created:
    • Loss_single.csv
    • Test_Accuracy_single.csv
    • Train_Accuracy_single.csv
    • net.dat (trained network)

training

Run locally your trained bots

You can use ComparerRunner to make your bots fight each others. By default, version V28 and V45 will fight each others. You can add your newly trained bot by modifying the following list:

            // List of bots
            var bots = new List<Func<IPlayer>>
            {
                {() => new ThreeNetBot{Prefix="../../../networks/V45/", Name = "V45"} },
                {() => new SingleNetBot{Prefix="../../../networks/V28/", Name = "V28"} },
            };

In order to easily debug bots, Halite.cpp has been ported to C#. Halite.cs

halite's People

Contributors

cbovar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jung-kuei

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.