Skip to main content

· 3 min read

During our development of Settlers of Catan, we met a subfunction level problem of synchronizing a dice and read the dice result based on the face exposing up.

For example, given two dices in the following positions. You need to detect the facial values of the dices.

The number is printed in console.

· 2 min read

The Settlers of Catan, sometimes shortened to just Catan, is a multiplayer board game designed by Klaus Teuber and first published in 1995 in Germany by Franckh-Kosmos Verlag (Kosmos) as Die Siedler von Catan. Players assume the roles of settlers, each attempting to build and develop holdings while trading and acquiring resources. Players are rewarded points as their settlements grow; the first to reach a set number of points, typically 10, is the winner. The game and its many expansions are also published by Mayfair Games, Filosofia, Capcom, 999 Games, Κάισσα, and Devir. -- Wikipedia

Unity Client-Server Architecture

Our Catan Gaming System(CGS) will be based on Server-Client architecture. CGS is based on Unity engine, and since Unity’s networking is integrated into the engine and the editor, it is redundant to treat Server and Client as different executables like how a traditional Server-Client architecture would. In our design, we are treating the entire CGS as one executable, and within the executable there are Server and Client components. An overview structure of our executable is shown here:

· 4 min read

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. (Definition on its homepage http://www.slimframework.com/)

Here you can have a taste of it :)

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");

return $response;
});
$app->run();

I just got introduced to Slim Framework recently, and speaking frankly it is not a good experience working with it and the poor community is nothing like npmjs, which is a place where I hang around most of the time. All the tutorials online are mostly theory-based and really not organized, some of them don't even run properly.

· 10 min read

Shell Scriping:

  • The different variants of exec do slightly different things. Some take a variable number of string arguments. Others take a list of strings. Still others let you specify the environment that the process runs with. This particular variant expects a program name and an array (also called a vector, hence the ‘v’) of string arguments (the first one has to be the program name). The ‘p’ means that instead of providing the full file path of the program to run, we’re going to give its name, and let the operating system search for the program in the path.
  • Once fork() returns, we actually have two processes running concurrently. The child process will take the first if condition (where pid == 0).
  • We use waitpid() to wait for the process’s state to change. Unfortunately, waitpid() has a lot of options (like exec()). Processes can change state in lots of ways, and not all of them mean that the process has ended. A process can either exit (normally, or with an error code), or it can be killed by a signal. So, we use the macros provided with waitpid() to wait until either the processes are exited or killed. Then, the function finally returns a 1, as a signal to the calling function that we should prompt for input again.
  • build-in commands are like CD and Exit. If you want to change directory, you need to use the function chdir(), the thing is, the current directory is a property of a process. So if you wrote a program called cd that changed directory, it would just change its own current directory, and then terminate. Its parent process's current directory would be unchanged. Same thing with exit.
  • A forward declaration is when you declare (but don’t define) something, so that you can use its name before you define it.

Problem Set:

First Set

  1. Q: How is a system call different from a function call?
    • A System Call provides abstractions to user program and managing computer’s hardware resources; its functionality is generally defined by POSIX for UNIX/ or Windows Standards.
    • A system call involves trapping into Kernel, which executes an interuption to Kernel. A Function Call generally refers to a call to a piece of code in the user space, thought, there might be system calls involved in a function call in specific cases such as fopen().
    • System call involves a mode switch from user to kernel.
    • Functionality: system calls are set by OS developer, function call can be arbitarily written by the programmer

· 7 min read
  • This note-blog basically covers readings of chapter 2
  • waitpid(pid_t pid, int *status, int options)

Processes-2.1

  • Pseudoparallelism: only one process is running at a certain instance, in a course of 1 second, cpu works on several of them, giving the illusion of parallelism.
  • Multiprocessor Systems : two or more CPUs sharing the same physical memory. Keeping track of multiple/parallel activities is hard for people to do. => OS designers evolved a conceptual model (sequential processes)

· 2 min read
  • Describes the different ways user / stakeholders interact with the system
  • Analysis technique to describe in a formal way how a computer system should work. It lists a sequence of actions that yields a result that is of value to an actor.
  • For each of ellipse we have, there is an use-case template associated with it. image

· 7 min read

When I joined Business Process and Information Technology Department of Baidu.inc, I was assigned to a team which was responsible for a development of the Internet giant's ERP system. During my service at the company, I was amazed by the amount of efficiency improvement owning to process management software. Meanwhile, there exists such a similarity between Redux, which is a functional programming based framework suggested by Facebook, and ERP process management.

Redux and Functional Programming

What is Redux?

Redux is a Javascript library that is based on concept of Flux, which provides a great framework to maintain state management (it plays a crucial role combining with React.js which renders JSX based on state-change). Following diagram illustrates a simple paradigm. image

· 2 min read

I have almost done my summer internship at Baidu.inc. As a Chinese person, it has been a dream to work for Baidu, since it is not only the Chinese Google, it is also the Chinese Reddit (Baidu Tieba) and Quara (Baidu Zhidao), and Baidu has Andrew Ng who is a rockstar in Artificial Intelligence working as a Chief Scientist. I did get a few decent offers from tech firms in Canada, but eventually I decided to work in Beijing just to experience the Internet world and see how it is going in China.

Memories

Me and My Tech Lead

My tech lead is an admirable person in terms of personalities and technologies. He used to work for Atlanssian™, the producer of Jira and SourceTree. He has great sense of Agile Development.

Robin Li

CEO of Baidu speaks at summer party

· 10 min read

The AI agent has two main methods of coming up with a good move. When processing time and RAM space is sufficient, it utilizes a Alpha Beta Pruning Search Tree algorithm to search the seed amount that it will have after few rounds of moves for all current legal moves; while running time and RAM space is limited or board states are numerous to be processed, it will filter and compare the pre-defined heuristics, evaluate the board state at a level and sum up all heuristic factors to find the best move. A search tree algorithm is more accurate than Heuristic method because it inspects all cases in the following “n” rounds instead of narrowing itself down to one certain state. Since the given constrains give enough space and running time for the AI agent to go for at least a depth of 6 rounds for alpha pruning search, and this Has game has a maximum of 32 pits for one side to be counted for each turn, it will use Alpha Beta Pruning mainly. image