Jeżeli coś wymaga specjalistycznego know-how, trudno to skopiować, a
wówczas konkurencja na rynku jest niewielka i można dobrze na tym
zarabiać. Naprawdę nie dziwi dlaczego Chiny stają się potężną gospodarką, bo nie każdy może sobie pozwolić na produkcję samolotów czy superkomputerów. Polska nadal nie ma zaawansowanego towaru lub usługi, dla której nie ma konkurencji. Ileż można chwalić się świetną kiełbasą, jabłkami czy innymi mało przetworzonymi produktami. Specjalistyczne know-how można przełożyć także na mniejszy kaliber. Zakładając firmę opartą na prostym modelu łatwym do skopiowania możemy tylko zacząć odliczać godziny kiedy pojawi się silny rywal, a może wystarczy spojrzeć za rogiem, bo pewnie tam nasza konkurencja już jest. Nie pozostaje zatem nic innego jak zacząć wgryzać się w zaawansowane technologie i posiąść właściwe know, a potem wymyślić how.
Saturday, 1 February 2014
Tuesday, 28 January 2014
How did you implement a shooting algorithm for the game of Battleship?
Let me describe it a little bit. I took a course on Java programming at my university. I had to implement the game of Battleship in the framework of my project.
The application was divided into 3 parts: model, controller and view (traditional MVC). You could play the game in console using only the model part. The model package (module) contained the main class Model. The Model class contained two attributes of type Player (two players: fist and second) and shotPlayer attribute that denoted the player who could shoot (of type PlayerState). When a shot arrived, the PlayerState object routed the shot to the player that was shot. For example, if first player shot, the PlayerState object routed the shot to the second player.
The PlayerModel class contained the "opponentHit(Point point)" method. Point had two attributes: (x,y) coordinates of the shot. In the method, the shot was sent to the player's board called Sea. The Sea board consisted of fields. Each field had a state:
/** Field is not used. */
UNUSED,
/** Field has been hit and it was a miss. */
MISS,
/** There is a mast and the field has not been hit yet. */
SHIP,
/** There was a mast, but the field has been hit. */
HIT,
/** There was a mast and the ship (which contained the mast) was sunk. */
DESTROYED
Each stated of the field decided on the transition to the next state and the new state was returned. I used the state design pattern here. The coordinates of the point determined the field of the Sea. If the previous state of the field was UNUSED then there was a miss. If the previous state of the field was SHIP then there was a hit. Otherwise, the shot should be repeated.
The code can be found here: https://github.com/adam-dziedzic/battleShips
The application was divided into 3 parts: model, controller and view (traditional MVC). You could play the game in console using only the model part. The model package (module) contained the main class Model. The Model class contained two attributes of type Player (two players: fist and second) and shotPlayer attribute that denoted the player who could shoot (of type PlayerState). When a shot arrived, the PlayerState object routed the shot to the player that was shot. For example, if first player shot, the PlayerState object routed the shot to the second player.
The PlayerModel class contained the "opponentHit(Point point)" method. Point had two attributes: (x,y) coordinates of the shot. In the method, the shot was sent to the player's board called Sea. The Sea board consisted of fields. Each field had a state:
/** Field is not used. */
UNUSED,
/** Field has been hit and it was a miss. */
MISS,
/** There is a mast and the field has not been hit yet. */
SHIP,
/** There was a mast, but the field has been hit. */
HIT,
/** There was a mast and the ship (which contained the mast) was sunk. */
DESTROYED
Each stated of the field decided on the transition to the next state and the new state was returned. I used the state design pattern here. The coordinates of the point determined the field of the Sea. If the previous state of the field was UNUSED then there was a miss. If the previous state of the field was SHIP then there was a hit. Otherwise, the shot should be repeated.
The code can be found here: https://github.com/adam-dziedzic/battleShips
Sunday, 29 December 2013
CLASSPATH
This: http://kevinboone.net/classpath.html is really great explanation of the classpath in Java. Worth reading!
Wednesday, 13 November 2013
Essay - how should we behave?
There is no general and final rule
that could establish the way of our behaviour. There were different
philosophical as well as religious concepts that strived to give us a
recipe for life, but without success. Moreover, there is always a
clash between conservative and liberal approaches to life.
Technology seems to be the one of the sources of
frictions between older people and teenagers. The elder are reserved
towards new electronic devices, whereas young generation absorbs them
rapidly and uses them everywhere, especially in public places. In my view, young people should neither
play songs noisily from their smartphones in public places nor
telephone to somebody and talk loudly. It can be really annoying. On
the other hand, sitting there and waiting for somebody or going by
bus and doing nothing can be boring. Then, the person can read
something on a tablet, listen to music using earphones, play a game
or textchat with somebody. It is at least difficult to get to know
somebody in a bus, so why not to catch up with your friends on
Facebook. The best way to solve the problem is to have both sides the
elder and younger to sit there and talk about technology. Maybe, this
time young people could teach something their parents and
grandparents.
We should remember about
individualism. We should not be concerned about other people's
judgement about us. Only then can we be creative and enthusiastic.
Each of us has his or her big value as an individual. We ought to be
aware of that since this forms a fundamental role in our personal and
professional life. I fully agree with this. However, we do not have
to become rebels. The case is to find our own paths in our lives and
follow them even against the odds. Everybody will die someday, so we
have nothing to loose. It is easy to copy others. Although it is
much harder to be innovative, it gives more fun and
satisfaction.
All in all, our behaviour is a result of many factors. Each of us had better find their own path, but at the same time be tolerant and be aware of different opinions. We should inhibit the bubbles created around us by the other people from inflating. We must stay hungry, full of energy and open-minded.
All in all, our behaviour is a result of many factors. Each of us had better find their own path, but at the same time be tolerant and be aware of different opinions. We should inhibit the bubbles created around us by the other people from inflating. We must stay hungry, full of energy and open-minded.
Friday, 8 November 2013
Who is an outcast?
I'm attending an online course on Algorithms, Part II by Robert Sedgewick and Kevin Wayne. I implemented a tool that uses WordNet data to determine an outcast in a group of words. What was interesting about that? There was a file outcast2.txt which contained only two words: von_Neuman and Turing. Here is the result of a test:
Test 1: test outcast() on WordNet digraph
* outcast2.txt
- nouns = Turing von_Neumann
- student outcast() = von_Neumann
- reference outcast() = Turing
It occurs that Turing was an outcast, not von_Neuman. Hmmm, according to the video by Bret Victor http://bit.ly/1d47YgE, if we had listened to all von_Neuman's theories, we all would write code in an assembly language ;)
Location:
United States
Sunday, 20 October 2013
Algorithms (graphs)
34.2-2 (Cormen, Leiserson, Rivest, and Stein, Introdution to Algorithms, 3rd edition)
Prove that if G is an undirected bipartite graph with an odd number of vertices, then G is nonhamiltonian.
Introduction to the problem
A bipartite graph is a graph whose vertices can be divided into two disjoint sets A and B such that every edge connects a vertex in A to one in B, that is, A and B are each independent sets.
Examples of bipartie graphs:
As we can see, in the upper picture the graph with odd number of vertices is nonhamiltonian. The second one is hamiltonian.
Proof
LetG=(A∣B,E) be a bipartite graph. To be Hamiltonian, a graph G needs to have a Hamilton cycle: that is, one which goes through all the vertices of G . As each edge in G connects a vertex in A with a vertex in B , any cycle alternately passes through a vertex in A then a vertex in B .
There are odd number of vertices, so |A|!= |B|. Suppose, without loss of generality, that|A|>|B | , that is, that there are more vertices in A than in B . Let |A|=m,|B|=n . Suppose G has a Hamilton cycle C .
Let that cycle start atu∈B . After 2n edges have been traversed, we will have arrived back at u again, and all the vertices of B will have been visited. But there will still be m−n vertices in A which have not been visited. Hence G cannot be hamiltonian.
QED
Prove that if G is an undirected bipartite graph with an odd number of vertices, then G is nonhamiltonian.
Introduction to the problem
A bipartite graph is a graph whose vertices can be divided into two disjoint sets A and B such that every edge connects a vertex in A to one in B, that is, A and B are each independent sets.
Examples of bipartie graphs:
As we can see, in the upper picture the graph with odd number of vertices is nonhamiltonian. The second one is hamiltonian.
Proof
Let
There are odd number of vertices, so |A|!= |B|. Suppose, without loss of generality, that
Let that cycle start at
QED
Saturday, 19 October 2013
Thus, there is limited but practical research at Google, blue-sky research at CERN and "the sky is the limit", sometimes useless research in academia.
http://www.youtube.com/watch?v=jJ-IwnnjBy0
http://www.youtube.com/watch?v=jJ-IwnnjBy0
Subscribe to:
Posts (Atom)

