April 3, 2010

Special Characters in HTML

left single quote ‘
right single quote ’
single low-9 quote ‚
left double quote “
right double quote ”
double low-9 quote „
dagger †
double dagger ‡
per mill sign ‰
single left-pointing angle quote ‹
single right-pointing angle quote ›
black spade suit ♠
black club suit ♣
black heart suit ♥
black diamond suit ♦
overline, = spacing overscore ‾
leftward arrow ←
upward arrow ↑
rightward arrow →
downward arrow ↓
trademark sign ™ ™
unused �-

horizontal tab 	
line feed 

unused 
space  
exclamation mark ! !
double quotation mark " "
number sign # #
dollar sign $ $
percent sign % %
ampersand & & &
apostrophe '
left parenthesis ( (
right parenthesis ) )
asterisk * *
plus sign + +
comma , ,
hyphen - -
period . .
slash / ⁄ /
digits 0-9 0-
9
colon : :
semicolon &#59; ;
less-than sign &#60; &lt; <
equals sign &#61; =
greater-than sign &#62; &gt; >
question mark &#63; ?
at sign &#64; @
uppercase letters A-Z &#65;-
&#90;
left square bracket &#91; [
backslash &#92; \
right square bracket &#93; ]
caret &#94; ^
horizontal bar (underscore) &#95; _
grave accent &#96; `
lowercase letters a-z &#97;-
&#122;
left curly brace &#123; {
vertical bar &#124; |
right curly brace &#125; }
tilde &#126; ~
unused &#127;-
&#149;
en dash &#150; &ndash;
em dash &#151; &mdash;
unused &#152;-
&#159;
nonbreaking space &#160; &nbsp;
inverted exclamation &#161; &iexcl; ¡
cent sign &#162; &cent; ¢
pound sterling &#163; &pound; £
general currency sign &#164; &curren; ¤
yen sign &#165; &yen; ¥
broken vertical bar &#166; &brvbar; or &brkbar; ¦
section sign &#167; &sect; §
umlaut &#168; &uml; or &die; ¨
copyright &#169; &copy; ©
feminine ordinal &#170; &ordf; ª
left angle quote &#171; &laquo; «
not sign &#172; &not; ¬
soft hyphen &#173; &shy; ­
registered trademark &#174; &reg; ®
macron accent &#175; &macr; or &hibar; ¯
degree sign &#176; &deg; °
plus or minus &#177; &plusmn; ±
superscript two &#178; &sup2; ²
superscript three &#179; &sup3; ³
acute accent &#180; &acute; ´
micro sign &#181; &micro; µ
paragraph sign &#182; &para;
middle dot &#183; &middot; ·
cedilla &#184; &cedil; ¸
superscript one &#185; &sup1; ¹
masculine ordinal &#186; &ordm; º
right angle quote &#187; &raquo; »
one-fourth &#188; &frac14; ¼
one-half &#189; &frac12; ½
three-fourths &#190; &frac34; ¾
inverted question mark &#191; &iquest; ¿
uppercase A, grave accent &#192; &Agrave; À
uppercase A, acute accent &#193; &Aacute; Á
uppercase A, circumflex accent &#194; &Acirc; Â
uppercase A, tilde &#195; &Atilde; Ã
uppercase A, umlaut &#196; &Auml; Ä
uppercase A, ring &#197; &Aring; Å
uppercase AE &#198; &AElig; Æ
uppercase C, cedilla &#199; &Ccedil; Ç
uppercase E, grave accent &#200; &Egrave; È
uppercase E, acute accent &#201; &Eacute; É
uppercase E, circumflex accent &#202; &Ecirc; Ê
uppercase E, umlaut &#203; &Euml; Ë
uppercase I, grave accent &#204; &Igrave; Ì
uppercase I, acute accent &#205; &Iacute; Í
uppercase I, circumflex accent &#206; &Icirc; Î
uppercase I, umlaut &#207; &Iuml; Ï
uppercase Eth, Icelandic &#208; &ETH; Ð
uppercase N, tilde &#209; &Ntilde; Ñ
uppercase O, grave accent &#210; &Ograve; Ò
uppercase O, acute accent &#211; &Oacute; Ó
uppercase O, circumflex accent &#212; &Ocirc; Ô
uppercase O, tilde &#213; &Otilde; Õ
uppercase O, umlaut &#214; &Ouml; Ö
multiplication sign &#215; &times; ×
uppercase O, slash &#216; &Oslash; Ø
uppercase U, grave accent &#217; &Ugrave; Ù
uppercase U, acute accent &#218; &Uacute; Ú
uppercase U, circumflex accent &#219; &Ucirc; Û
uppercase U, umlaut &#220; &Uuml; Ü
uppercase Y, acute accent &#221; &Yacute; Ý
uppercase THORN, Icelandic &#222; &THORN; Þ
lowercase sharps, German &#223; &szlig; ß
lowercase a, grave accent &#224; &agrave; à
lowercase a, acute accent &#225; &aacute; á
lowercase a, circumflex accent &#226; &acirc; â
lowercase a, tilde &#227; &atilde; ã
lowercase a, umlaut &#228; &auml; ä
lowercase a, ring &#229; &aring; å
lowercase ae &#230; &aelig; æ
lowercase c, cedilla &#231; &ccedil; ç
lowercase e, grave accent &#232; &egrave; è
lowercase e, acute accent &#233; &eacute; é
lowercase e, circumflex accent &#234; &ecirc; ê
lowercase e, umlaut &#235; &euml; ë
lowercase i, grave accent &#236; &igrave; ì
lowercase i, acute accent &#237; &iacute; í
lowercase i, circumflex accent &#238; &icirc; î
lowercase i, umlaut &#239; &iuml; ï
lowercase eth, Icelandic &#240; &eth; ð
lowercase n, tilde &#241; &ntilde; ñ
lowercase o, grave accent &#242; &ograve; ò
lowercase o, acute accent &#243; &oacute; ó
lowercase o, circumflex accent &#244; &ocirc; ô
lowercase o, tilde &#245; &otilde; õ
lowercase o, umlaut &#246; &ouml; ö
division sign &#247; &divide; ÷
lowercase o, slash &#248; &oslash; ø
lowercase u, grave accent &#249; &ugrave; ù
lowercase u, acute accent &#250; &uacute; ú
lowercase u, circumflex accent &#251; &ucirc; û
lowercase u, umlaut &#252; &uuml; ü
lowercase y, acute accent &#253; &yacute; ý
lowercase thorn, Icelandic &#254; &thorn; þ
lowercase y, umlaut &#255; &yuml; ÿ
Alpha &Alpha; Α
alpha &alpha; α
Beta &Beta; Β
beta &beta; β
Gamma &Gamma; Γ
gamma &gamma; γ
Delta &Delta; Δ
delta &delta; δ
Epsilon &Epsilon; Ε
epsilon &epsilon; ε
Zeta &Zeta; Ζ
zeta &zeta; ζ
Eta &Eta; Η
eta &eta; η
Theta &Theta; Θ
theta &theta; θ
Iota &Iota; Ι
iota &iota; ι
Kappa &Kappa; Κ
kappa &kappa; κ
Lambda &Lambda; Λ
lambda &lambda; λ
Mu &Mu; Μ
mu &mu; μ
Nu &Nu; Ν
nu &nu; ν
Xi &Xi; Ξ
xi &xi; ξ
Omicron &Omicron; Ο
omicron &omicron; ο
Pi &Pi; Π
pi &pi; π
Rho &Rho; Ρ
rho &rho; ρ
Sigma &Sigma; Σ
sigma &sigma; σ
Tau &Tau; Τ
tau &tau; τ
Upsilon &Upsilon; Υ
upsilon &upsilon; υ
Phi &Phi; Φ
phi &phi; φ
Chi &Chi; Χ
chi &chi; χ
Psi &Psi; Ψ
psi &psi; ψ
Omega &Omega; Ω
omega &omega; ω
password dot &#9679;
bullet &#8226;

Getting a 500 Internal Server Error when Creating a New File

I was having a problem trying to create new files inside my web server. Every file I created would display a 500 Internal Server Error. I thought it was a problem with my web hosting company. It turns out that it was an issue with my default file permission setting. Using Aptana, it would create a file with default permission of 666, which can cause php to not be able to parse the file. This is what causes the 500 Internal Server Error.

To fix this, simply change the file permission to 644, which is also (rw- r– r–). Now all your files will display normally.

Notes

This is how you change the default file permissions under Aptana Studio.
Window->Preferences->Aptana->Permission

Also, Aptana has the default directory permission set to 777 (rwx rwx rwx). It would be safer if you changed the default permission for directories to 755 (rwx r-x r-x).

April 2, 2010

Using A* Algorithm for solving 8-puzzle in C++

I recently had to do a project for my AI class that could solve an 8 puzzle using an A* search in C++. I have to admit that I wish I could have spent more time cleaning up my code. What’s good is my linked list structure. What’s a little sloppy are my computational methods. Regardless, I thought that this code could still be useful for people who are new or rusty on how to use classes and setting up a search tree.

This is an empty console project, with one source file (main.cpp), one input file (in.txt), and one output file (out.txt). This code has been tested, compiled, and executed under Visual Studio 2008 Professional Edition.

My Algorithm

I created a tree class that could handle linked lists. Every linked node could have up to 4 children. I would simply build the tree structure out. Using the first heuristic, I would build the tree according to which node had the lowest distance from the root node. This is pretty much creating a tree by a breadth depth search. My second heuristic added in a cost for how similar the current node’s state was to the goal state. This allowed the tree to be built smartly and not continue to expand down bad branches.

I also added a constraint that wouldn’t allow a node to be created if it was trying to make a bad move. A bad move is when the puzzle is backtracking. Backtracking is a sure sign that that branch is not an optimal solution.

My Results

I ran my program using two different heuristics. One was many times more efficient than the other. My first heuristic was simply just using the distance from the root node. It took 6.63 minutes to complete.

/**************OUTPUT******************/
Success!
n = 12
time: 663801 msecs
Press any key to continue . . .
/**************************************/

My second heuristic was adding a cost to the distance for how many numbers in the current state were in the same position as the numbers in the goal state. The output was significantly faster. It computed the the same path in under 1 second.

/**************OUTPUT******************/
Success!
n = 12
time: 858 msecs
Press any key to continue . . .
/**************************************/

Using this Code

If you are working on a similar assignment, feel free to use this code and expand on it. I would really appreciate it if someone could polish the code for me and send me an updated copy. It could use a better class structure, better name conventions, prettier computational methods, and some relevant comments. I simply didn’t have time. Feel free to leave a comment if you have any questions trying to get this to work on your computer. I hope this helps!