Typical AI run

Introduction

In this article, we develop a simple AI for the game 2048 using the Expectimax algorithm and “weight matrices”, which will be described below, to determine the best possible move at each turn.

The implementation of the AI described in this article can be found here. The source files for the implementation can be found here.

Recursivity of score function

We define some symbols and functions in order to construct a function to compute the score of any one game state (i.e. grid).

• Game state: A \$latex 4 times 4\$ square matrix \$latex mathbf{A}\$ where \$latex mathbf{A}_{ij}\$ is equal to the value of the cell in the game grid at row \$latex i\$ and column \$latex j\$.
• \$latex text{score}(mathbf{A})\$ : The numerical score of the game state \$latex mathbf{A}\$.
• \$latex D_mathbf{A}\$ : The set of possible move directions (up, down, left, right) for \$latex mathbf{A}\$.
• \$latex…

View original post 825 more words

25 Stunning Skylines Around the World

New York City – Photograph by DIGITALFREAKART

Following up from the Sifter’s first skyline post, here are 25 more stunning skylines around the world. These are by no means the ‘best’ skylines, just a collection of incredible photographs taken by some amazing photographers around the world. Almost all photographs are from the wonderful community over at deviantART. If you haven’t been, I recommend you check out their site, many of the artists sell their artwork and prints as well.

I tried not to duplicate too many of the cities covered in the first skyline post, so places like Chicago, Hong Kong and Shanghai were omitted. If you any suggestions for cities in the next series of skylines, please share in the comments below!

2. Melbourne, Australia

Photograph by XREBELXDIAMONDSX

3. Paris, France

Photograph by LAURENTIS

4. Damascus, Syria

Photograph by PRESPECT

5. Dubai, United Arab Emirates

Photograph by

View original post 153 more words

Introduction

In this post, I want to share my experiences in using Devise as an authentication solution for my company’s Web app.

While building Motonow, the team had to make a couple of though decisions and choosing the right authentication solution was one of them. To be honest, most of the projects I’ve joined had already overcome this phase so I’ve never participated in such conversations until Motonow.

After doing some prototypes, we’ve decided to use Devise because:

1. It has most of the features we want to implement already in place;
2. It’s really straightforward to start with;
3. It’s well documented;
4. It’s widely adopted in the Rails community;

Everything was going well until the domain model started to grow in the sense that Devise’s basic configuration was not enough for us. At that point, we needed to extend Devise, more specifically the RegistrationsController.

Domain Model

At the beginning we only had a User model so integrating with devise was pretty easy…

View original post 522 more words

Process Explorer Tips and Tricks

I would like to take a minute and share my thoughts on Process Explorer:

-= Process Explorer =-

• Super Task Manager – on Steroids 🙂
• Lists many details about processes and threads otherwise hard or impossible to obtain.

-=- Process Explorer Basics -=-

• It uses a number of undocumented functions
• When you launch it for the first time under an Administrative context it loads a device driver to help it obtain some info.
• It helps to get the stacks of Kernel mode threads for debugging purposes.
– Get full path names of EXE’s and Dll’s for handles that are not within the current session.
– Runs on all versions of windows since Win95
– Related Commands
– Handle: command-line handle viewer
– Listdlls: command-line DLL viewer
-Process Explorer shows a parent-child relationship between processes organizing them in a Process Tree-View.

Example! services.exe is the services control manager application – is…

View original post 1,812 more words

Dynamic roles and permissions using cancan

Most of us already use cancan for authorization, where we define the Role Based Access (RBAC) to various models in the Ability class. However, any changes to these abilities, requires code changes to the Ability class and restarting the application for the changes to take effect.

What if we could assign these permissions dynamically? That would be great, wouldn’t it. This is how we manage roles and permissions dynamically. Some initial thoughts were picked up from here

This approach is based primarily on authorization for the controller actions.

Let’s consider an example. We will add the models as they are required. Right now the basic application has models User, Role and Permission. The relationship is as shown

`Role #the model to save the role :name # the role name :has_many :users :has_and_belongs_to_many :permissions User :name # user name :email # user email :password # user password :belongs_to :role Permission #…`

View original post 583 more words

Google Integration Using Devise and Omniauth In Rails App.

In this blog i’ll show how to integrate Google authentication using devise.To install devise you can refer to my blog here.

Step:1
Add the gems in your gem file

``gem ‘devise’gem 'omniauth'gem 'omniauth-google-oauth2' ``

Run the “bundle install” command to install the gem.

Step:2
You need two more columns to store provider type and userid given from google

``rails g migration AddProviderToUsers provider:string uid:string``

Runt rake db:migrate to insert the columns in users table.

Step:3
Go the user model “user.rb” and add the following line

``devise : omniauthable``

Step:4
First of all you need to create an app in google to get “Client key” and “Client Secret key”

``https://code.google.com/apis/console/``

Create an app and get the Client id and secret key.

Step:5
Now you need to declare the provider name and client id and key.Go to the file config/initializers/devise.rb and the following line

``require 'omniauth-google-oauth2' config.omniauth :google_oauth2, "APP_ID", "APP_SECRET"…``

View original post 195 more words